From 4aca804e868e4c5d2a187ad9be04ec33c079c9ba Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:47:41 +0530 Subject: [PATCH 01/41] #109 Demo app changes --- app/build.gradle | 4 +++- .../com/flipkart/batchdemo/CustomTagData.java | 4 ++-- .../java/com/flipkart/batchdemo/EventTag.java | 2 +- .../com/flipkart/batchdemo/MainActivity.java | 24 +++++++++---------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4751a83..4e05f52 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 24 - buildToolsVersion '24.0.0' + buildToolsVersion '24' defaultConfig { applicationId "com.flipkart.batchdemo" @@ -62,4 +62,6 @@ dependencies { compile 'com.android.support:appcompat-v7:24.0.0' compile 'com.android.support:design:24.0.0' compile project(':batching') + compile project(':batching-core') + compile project(':batching-gson') } diff --git a/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java b/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java index 67aeae8..3fdbf55 100644 --- a/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java +++ b/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java @@ -24,8 +24,8 @@ package com.flipkart.batchdemo; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import com.google.gson.annotations.SerializedName; import org.json.JSONObject; diff --git a/app/src/main/java/com/flipkart/batchdemo/EventTag.java b/app/src/main/java/com/flipkart/batchdemo/EventTag.java index c74bfb3..d86b99f 100644 --- a/app/src/main/java/com/flipkart/batchdemo/EventTag.java +++ b/app/src/main/java/com/flipkart/batchdemo/EventTag.java @@ -24,7 +24,7 @@ package com.flipkart.batchdemo; -import com.flipkart.batching.data.Tag; +import com.flipkart.batchingcore.data.Tag; import com.google.gson.annotations.SerializedName; public class EventTag extends Tag { diff --git a/app/src/main/java/com/flipkart/batchdemo/MainActivity.java b/app/src/main/java/com/flipkart/batchdemo/MainActivity.java index 7d19ffa..54a6ffd 100644 --- a/app/src/main/java/com/flipkart/batchdemo/MainActivity.java +++ b/app/src/main/java/com/flipkart/batchdemo/MainActivity.java @@ -41,18 +41,18 @@ import android.view.View; import android.webkit.ValueCallback; -import com.flipkart.batching.Batch; import com.flipkart.batching.TagBatchManager; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; import com.flipkart.batching.listener.NetworkPersistedBatchReadyListener; import com.flipkart.batching.listener.PersistedBatchCallback; import com.flipkart.batching.listener.TrimmedBatchCallback; -import com.flipkart.batching.persistence.GsonSerializationStrategy; -import com.flipkart.batching.persistence.SerializationStrategy; import com.flipkart.batching.persistence.TapePersistenceStrategy; import com.flipkart.batching.strategy.SizeBatchingStrategy; -import com.flipkart.batching.strategy.TagBatchingStrategy; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.batch.TagBatch; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import java.util.ArrayList; import java.util.Collections; @@ -133,14 +133,14 @@ public void onTrimmed(int oldSize, int newSize) { } }); - debugListener.setListener(new PersistedBatchCallback>() { + debugListener.setListener(new PersistedBatchCallback>() { @Override - public void onPersistFailure(TagBatchingStrategy.TagBatch batch, Exception e) { + public void onPersistFailure(TagBatch batch, Exception e) { } @Override - public void onPersistSuccess(TagBatchingStrategy.TagBatch batch) { + public void onPersistSuccess(TagBatch batch) { // SystemClock.sleep(2000); debugListener.finish(batch); Log.e("Debug", "Finish Called"); @@ -165,14 +165,14 @@ public void onTrimmed(int oldSize, int newSize) { } }); - dgListener.setListener(new PersistedBatchCallback>() { + dgListener.setListener(new PersistedBatchCallback>() { @Override - public void onPersistFailure(TagBatchingStrategy.TagBatch batch, Exception e) { + public void onPersistFailure(TagBatch batch, Exception e) { } @Override - public void onPersistSuccess(TagBatchingStrategy.TagBatch batch) { + public void onPersistSuccess(TagBatch batch) { //SystemClock.sleep(2000); dgListener.finish(batch); Log.e("Dg", "Finish Called"); From ad64463c1678eeba4cc48496cea3145b04d9a903 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:48:11 +0530 Subject: [PATCH 02/41] #109 gradle version changes --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index b38460e..3149bce 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.android.tools.build:gradle:2.2.0-beta1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 94c985f..574339f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Mar 14 17:53:58 GMT+05:30 2016 +#Thu Aug 11 10:43:03 IST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip From f129df386bdc35095c678257e313b38ecc1d564e Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:48:27 +0530 Subject: [PATCH 03/41] #109 added dependency of diff modules in gradle --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index ab38e5b..d308db5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,4 +22,4 @@ * THE SOFTWARE. */ -include ':app', ':batching' +include ':app', ':batching', ':batching-core', ':batching-gson' From 54bef7fdb01597c76afd9c036de07e8ef9d1ee6d Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:49:16 +0530 Subject: [PATCH 04/41] #109 moved these classes to gson module --- .../exception/DeserializeException.java | 45 --- .../exception/SerializeException.java | 46 --- .../GsonSerializationStrategy.java | 361 ------------------ .../persistence/SerializationStrategy.java | 82 ---- .../toolbox/RuntimeTypeAdapterFactory.java | 250 ------------ 5 files changed, 784 deletions(-) delete mode 100755 batching/src/main/java/com/flipkart/batching/exception/DeserializeException.java delete mode 100755 batching/src/main/java/com/flipkart/batching/exception/SerializeException.java delete mode 100644 batching/src/main/java/com/flipkart/batching/persistence/GsonSerializationStrategy.java delete mode 100644 batching/src/main/java/com/flipkart/batching/persistence/SerializationStrategy.java delete mode 100644 batching/src/main/java/com/flipkart/batching/toolbox/RuntimeTypeAdapterFactory.java diff --git a/batching/src/main/java/com/flipkart/batching/exception/DeserializeException.java b/batching/src/main/java/com/flipkart/batching/exception/DeserializeException.java deleted file mode 100755 index 97b5628..0000000 --- a/batching/src/main/java/com/flipkart/batching/exception/DeserializeException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching.exception; - -import java.io.IOException; - -/** - * DeserializationException class that extends {@link IOException}. - *

- * To get the real exception use {@link #getRealException()}. - */ -public class DeserializeException extends IOException { - private final Exception realException; - - public DeserializeException(Exception realException) { - super(realException.getCause()); - this.realException = realException; - } - - public Exception getRealException() { - return realException; - } -} diff --git a/batching/src/main/java/com/flipkart/batching/exception/SerializeException.java b/batching/src/main/java/com/flipkart/batching/exception/SerializeException.java deleted file mode 100755 index 3af2487..0000000 --- a/batching/src/main/java/com/flipkart/batching/exception/SerializeException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching.exception; - -import java.io.IOException; - -/** - * SerializationException class that extends {@link IOException}. - *

- * To get the real exception use {@link #getRealException()}. - */ -public class SerializeException extends IOException { - private final Exception realException; - - public SerializeException(Exception realException) { - super(realException.getCause()); - this.realException = realException; - } - - public Exception getRealException() { - return realException; - } -} - diff --git a/batching/src/main/java/com/flipkart/batching/persistence/GsonSerializationStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/GsonSerializationStrategy.java deleted file mode 100644 index 8c5452f..0000000 --- a/batching/src/main/java/com/flipkart/batching/persistence/GsonSerializationStrategy.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching.persistence; - -import com.flipkart.batching.Batch; -import com.flipkart.batching.Data; -import com.flipkart.batching.DataCollection; -import com.flipkart.batching.exception.DeserializeException; -import com.flipkart.batching.exception.SerializeException; -import com.flipkart.batching.toolbox.RuntimeTypeAdapterFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.internal.LinkedTreeMap; -import com.google.gson.reflect.TypeToken; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * Implementation of {@link SerializationStrategy}. - * - * @see SerializationStrategy - */ -public class GsonSerializationStrategy implements SerializationStrategy { - private static final String IS_JSON_OBJECT = "_com.flipkart.batching.isJsonObject"; - private static final String JSON_ARRAY_OBJECT = "_com.flipkart.batching.jsonArray"; - - Set> dataTypes = new HashSet<>(); - Set> batchInfoTypes = new HashSet<>(); - private Gson gson; - - public static JsonElement serializeJSONArray(JSONArray src, JsonSerializationContext context) { - JsonObject result = null; - try { - if (null != src) { - result = new JsonObject(); - JsonArray jsonArray = new JsonArray(); - for (int idx = 0; idx < src.length(); idx++) { - Object value = src.get(idx); - JsonElement element = forJSONGenericObject(value, context); - jsonArray.add(element); - } - result.add(JSON_ARRAY_OBJECT, jsonArray); - } - } catch (JSONException e) { - e.printStackTrace(); - } - - return result; - } - - public static JSONArray deserializeJSONArray(JsonElement json, JsonDeserializationContext context) throws JsonParseException { - JSONArray result = null; - if (null != json) { - result = new JSONArray(); - if (json.isJsonObject() && json.getAsJsonObject().has(JSON_ARRAY_OBJECT)) { - JsonArray jsonArray = json.getAsJsonObject().getAsJsonArray(JSON_ARRAY_OBJECT); - for (JsonElement element : jsonArray) { - if (null != element) { - result.put(getObjectFromJsonElement(element, context)); - } else { - result.put(null); - } - } - } - } - return result; - } - - public static JsonElement serializeJSONObject(JSONObject src, JsonSerializationContext context) { - JsonObject result = null; - if (null != src) { - try { - result = new JsonObject(); - Iterator iterator = src.keys(); - while (iterator.hasNext()) { - String key = iterator.next(); - Object value = src.get(key); - JsonElement element = forJSONGenericObject(value, context); - result.add(key, element); - result.addProperty(IS_JSON_OBJECT, true); - } - } catch (JSONException e) { - e.printStackTrace(); - } - } - return result; - - } - - public static JSONObject deserializeJSONObject(JsonElement json, JsonDeserializationContext context) throws JsonParseException { - JSONObject result = null; - if (null != json && json.isJsonObject()) { - try { - result = new JSONObject(); - JsonObject jsonObject = json.getAsJsonObject(); - for (Map.Entry entry : jsonObject.entrySet()) { - JsonElement value = entry.getValue(); - if (null != value) { - result.put(entry.getKey(), getObjectFromJsonElement(entry.getValue(), context)); - } else { - result.put(entry.getKey(), null); - } - } - result.remove(IS_JSON_OBJECT); - } catch (JSONException e) { - e.printStackTrace(); - } - - } - return result; - } - - - private static Object getObjectFromJsonElement(JsonElement value, JsonDeserializationContext context) { - Object result = null; - if (value.isJsonObject()) { - if (value.getAsJsonObject().has(IS_JSON_OBJECT)) { - JSONObject jsonObject = deserializeJSONObject(value, context); - if (null != jsonObject) { - jsonObject.remove(IS_JSON_OBJECT); - } - return jsonObject; - } else if (value.getAsJsonObject().has(JSON_ARRAY_OBJECT)) { - return deserializeJSONArray(value, context); - } else { - result = getMapFromJson(value.getAsJsonObject(), context); - } - - } else if (value.isJsonPrimitive()) { - JsonPrimitive primitiveValue = value.getAsJsonPrimitive(); - if (primitiveValue.isBoolean()) { - result = primitiveValue.getAsBoolean(); - } else if (primitiveValue.isNumber()) { - result = primitiveValue.getAsNumber(); - } else { - result = primitiveValue.getAsString(); - } - } else if (value.isJsonNull()) { - result = null; - } else if (value.isJsonArray()) { - JsonArray jsonArray = value.getAsJsonArray(); - ArrayList list = new ArrayList<>(jsonArray.size()); - for (JsonElement element : jsonArray) { - list.add(getObjectFromJsonElement(element, context)); - } - result = list; - } - return result; - } - - public static Map getMapFromJson(JsonObject data, JsonDeserializationContext context) { - Map result = null; - if (null != data) { - result = new LinkedTreeMap<>(); - for (Map.Entry entry : data.entrySet()) { - result.put(entry.getKey(), getObjectFromJsonElement(entry.getValue(), context)); - } - } - return result; - } - - public static JsonElement forJSONGenericObject(Object value, JsonSerializationContext context) { - JsonElement element; - if (null != value) { - if (value instanceof JSONObject) { - element = serializeJSONObject((JSONObject) value, context); - } else if (value instanceof JSONArray) { - element = serializeJSONArray((JSONArray) value, context); - } else if (value instanceof String) { - element = new JsonPrimitive((String) value); - } else if (value instanceof Number) { - element = new JsonPrimitive((Number) value); - } else if (value instanceof Boolean) { - element = new JsonPrimitive((Boolean) value); - } else { - element = context.serialize(value); - } - } else { - element = context.serialize(value); - } - return element; - } - - @Override - public void registerDataType(Class subClass) { - dataTypes.add(subClass); - } - - @Override - public void registerBatch(Class subClass) { - batchInfoTypes.add(subClass); - } - - @Override - public void build() { - RuntimeTypeAdapterFactory dataAdapter = (RuntimeTypeAdapterFactory) RuntimeTypeAdapterFactory.of(Data.class); - for (Class dataType : dataTypes) { - dataAdapter.registerSubtype(dataType); - } - - RuntimeTypeAdapterFactory batchInfoAdapter = (RuntimeTypeAdapterFactory) RuntimeTypeAdapterFactory.of(Batch.class); - for (Class batchInfoType : batchInfoTypes) { - batchInfoAdapter.registerSubtype(batchInfoType); - } - - RuntimeTypeAdapterFactory collectionAdapter = RuntimeTypeAdapterFactory.of(Collection.class); - collectionAdapter.registerSubtype(ArrayList.class); - - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapterFactory(dataAdapter); - gsonBuilder.registerTypeAdapterFactory(batchInfoAdapter); - gsonBuilder.registerTypeAdapter(DataCollection.class, new DataCollection.Serializer()); - gsonBuilder.registerTypeAdapter(DataCollection.class, new DataCollection.DeSerializer()); - gsonBuilder.registerTypeAdapter(JSONObject.class, new JSONObjectDeSerializer()); - gsonBuilder.registerTypeAdapter(JSONObject.class, new JSONObjectSerializer()); - gsonBuilder.registerTypeAdapter(JSONArray.class, new JSONArrayDeSerializer()); - gsonBuilder.registerTypeAdapter(JSONArray.class, new JSONArraySerializer()); - //gsonBuilder.registerTypeAdapterFactory(collectionAdapter); - gson = gsonBuilder.create(); - } - - private void checkIfBuildCalled() { - if (gson == null) { - throw new IllegalStateException("The build() method was not called on " + getClass()); - } - } - - @Override - public byte[] serializeData(E data) throws SerializeException { - checkIfBuildCalled(); - try { - return gson.toJson(data, Data.class).getBytes(); - } catch (JsonParseException e) { - throw new SerializeException(e); - } - } - - @Override - public byte[] serializeCollection(Collection data) throws SerializeException { - checkIfBuildCalled(); - Type type = new TypeToken>() { - }.getType(); - try { - return gson.toJson(data, type).getBytes(); - } catch (JsonParseException e) { - throw new SerializeException(e); - } - } - - @Override - public byte[] serializeBatch(T batch) throws SerializeException { - checkIfBuildCalled(); - try { - return gson.toJson(batch, Batch.class).getBytes(); - } catch (JsonParseException e) { - throw new SerializeException(e); - } - } - - @Override - public E deserializeData(byte[] data) throws DeserializeException { - checkIfBuildCalled(); - try { - return (E) gson.fromJson(new String(data), Data.class); - } catch (JsonParseException e) { - throw new DeserializeException(e); - } - } - - @Override - public Collection deserializeCollection(byte[] data) throws DeserializeException { - checkIfBuildCalled(); - Type type = new TypeToken>() { - }.getType(); - try { - return gson.fromJson(new String(data), type); - } catch (JsonParseException e) { - throw new DeserializeException(e); - } - } - - @Override - public T deserializeBatch(byte[] data) throws DeserializeException { - checkIfBuildCalled(); - try { - return (T) gson.fromJson(new String(data), Batch.class); - } catch (JsonParseException e) { - throw new DeserializeException(e); - } - } - - public static class JSONObjectSerializer implements JsonSerializer { - @Override - public JsonElement serialize(JSONObject src, Type typeOfSrc, JsonSerializationContext context) { - return serializeJSONObject(src, context); - } - } - - - public static class JSONObjectDeSerializer implements JsonDeserializer { - @Override - public JSONObject deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - return deserializeJSONObject(json, context); - } - } - - public static class JSONArraySerializer implements JsonSerializer { - @Override - public JsonElement serialize(JSONArray src, Type typeOfSrc, JsonSerializationContext context) { - return serializeJSONArray(src, context); - } - } - - public static class JSONArrayDeSerializer implements JsonDeserializer { - @Override - public JSONArray deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - return deserializeJSONArray(json, context); - } - } -} \ No newline at end of file diff --git a/batching/src/main/java/com/flipkart/batching/persistence/SerializationStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/SerializationStrategy.java deleted file mode 100644 index cf3ec26..0000000 --- a/batching/src/main/java/com/flipkart/batching/persistence/SerializationStrategy.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching.persistence; - -import com.flipkart.batching.Batch; -import com.flipkart.batching.Data; -import com.flipkart.batching.exception.DeserializeException; -import com.flipkart.batching.exception.SerializeException; - -import java.util.Collection; - -/** - * This is an interface for serialization strategy. An implementation of this class - * must override all it's methods. - * - * @see GsonSerializationStrategy - */ -public interface SerializationStrategy { - - /** - * Register sub classes of {@link Data} - * - * @param subClass The sub class of {@link Data} - */ - void registerDataType(Class subClass); - - void registerBatch(Class subClass); - - /** - * After registering subtypes using {@link #registerDataType(Class)}} & {@link #registerBatch(Class)}, this method has to be called. - * After build is called, no more register calls can happen. - */ - void build(); - - /** - * This method serialize the provided {@link Data} object. - * - * @param data {@link Data} object to be serialized - * @return byte array - * @throws SerializeException - */ - byte[] serializeData(E data) throws SerializeException; - - byte[] serializeCollection(Collection data) throws SerializeException; - - byte[] serializeBatch(T batch) throws SerializeException; - - /** - * This method deserialize the provided byte array of data. - * - * @param data byte[] type data - * @return {@link Object} type data - * @throws DeserializeException - */ - E deserializeData(byte[] data) throws DeserializeException; - - Collection deserializeCollection(byte[] data) throws DeserializeException; - - T deserializeBatch(byte[] data) throws DeserializeException; -} diff --git a/batching/src/main/java/com/flipkart/batching/toolbox/RuntimeTypeAdapterFactory.java b/batching/src/main/java/com/flipkart/batching/toolbox/RuntimeTypeAdapterFactory.java deleted file mode 100644 index 00fa99e..0000000 --- a/batching/src/main/java/com/flipkart/batching/toolbox/RuntimeTypeAdapterFactory.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching.toolbox; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.internal.Streams; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Adapts values whose runtime type may differ from their declaration type. This - * is necessary when a field's type is not the same type that GSON should create - * when deserializing that field. For example, consider these types: - *
   {@code
- *   abstract class Shape {
- *     int x;
- *     int y;
- *   }
- *   class Circle extends Shape {
- *     int radius;
- *   }
- *   class Rectangle extends Shape {
- *     int width;
- *     int height;
- *   }
- *   class Diamond extends Shape {
- *     int width;
- *     int height;
- *   }
- *   class Drawing {
- *     Shape bottomShape;
- *     Shape topShape;
- *   }
- * }
- *

Without additional type information, the serialized JSON is ambiguous. Is - * the bottom shape in this drawing a rectangle or a diamond?

   {@code
- *   {
- *     "bottomShape": {
- *       "width": 10,
- *       "height": 5,
- *       "x": 0,
- *       "y": 0
- *     },
- *     "topShape": {
- *       "radius": 2,
- *       "x": 4,
- *       "y": 1
- *     }
- *   }}
- * This class addresses this problem by adding type information to the - * serialized JSON and honoring that type information when the JSON is - * deserialized:
   {@code
- *   {
- *     "bottomShape": {
- *       "type": "Diamond",
- *       "width": 10,
- *       "height": 5,
- *       "x": 0,
- *       "y": 0
- *     },
- *     "topShape": {
- *       "type": "Circle",
- *       "radius": 2,
- *       "x": 4,
- *       "y": 1
- *     }
- *   }}
- * Both the type field name ({@code "type"}) and the type labels ({@code - * "Rectangle"}) are configurable. - *

- *

Registering Types

- * Create a {@code RuntimeTypeAdapterFactory} by passing the base type and type field - * name to the {@link #of} factory method. If you don't supply an explicit type - * field name, {@code "type"} will be used.
   {@code
- *   RuntimeTypeAdapterFactory shapeAdapter
- *       = RuntimeTypeAdapterFactory.of(Shape.class, "type");
- * }
- * Next register all of your subtypes. Every subtype must be explicitly - * registered. This protects your application from injection attacks. If you - * don't supply an explicit type label, the type's simple name will be used. - *
   {@code
- *   shapeAdapter.registerSubtype(Rectangle.class, "Rectangle");
- *   shapeAdapter.registerSubtype(Circle.class, "Circle");
- *   shapeAdapter.registerSubtype(Diamond.class, "Diamond");
- * }
- * Finally, register the type adapter in your application's GSON builder: - *
   {@code
- *   Gson gson = new GsonBuilder()
- *       .registerTypeAdapter(Shape.class, shapeAdapter)
- *       .create();
- * }
- * Like {@code GsonBuilder}, this API supports chaining:
   {@code
- *   RuntimeTypeAdapterFactory shapeAdapter = RuntimeTypeAdapterFactory.of(Shape.class)
- *       .registerSubtype(Rectangle.class)
- *       .registerSubtype(Circle.class)
- *       .registerSubtype(Diamond.class);
- * }
- */ -public final class RuntimeTypeAdapterFactory implements TypeAdapterFactory { - private final Class baseType; - private final String typeFieldName; - private final Map> labelToSubtype = new LinkedHashMap>(); - private final Map, String> subtypeToLabel = new LinkedHashMap, String>(); - - private RuntimeTypeAdapterFactory(Class baseType, String typeFieldName) { - if (typeFieldName == null || baseType == null) { - throw new NullPointerException(); - } - this.baseType = baseType; - this.typeFieldName = typeFieldName; - } - - /** - * Creates a new runtime type adapter using for {@code baseType} using {@code - * typeFieldName} as the type field name. Type field names are case sensitive. - */ - public static RuntimeTypeAdapterFactory of(Class baseType, String typeFieldName) { - return new RuntimeTypeAdapterFactory(baseType, typeFieldName); - } - - /** - * Creates a new runtime type adapter for {@code baseType} using {@code "type"} as - * the type field name. - */ - public static RuntimeTypeAdapterFactory of(Class baseType) { - return new RuntimeTypeAdapterFactory(baseType, "type"); - } - - /** - * Registers {@code type} identified by {@code label}. Labels are case - * sensitive. - * - * @throws IllegalArgumentException if either {@code type} or {@code label} - * have already been registered on this type adapter. - */ - public RuntimeTypeAdapterFactory registerSubtype(Class type, String label) { - if (type == null || label == null) { - throw new NullPointerException(); - } - if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) { - throw new IllegalArgumentException("types and labels must be unique"); - } - labelToSubtype.put(label, type); - subtypeToLabel.put(type, label); - return this; - } - - /** - * Registers {@code type} identified by its {@link Class#getSimpleName simple - * name}. Labels are case sensitive. - * - * @throws IllegalArgumentException if either {@code type} or its simple name - * have already been registered on this type adapter. - */ - public RuntimeTypeAdapterFactory registerSubtype(Class type) { - return registerSubtype(type, type.getSimpleName()); - } - - public TypeAdapter create(Gson gson, TypeToken type) { - if (type.getRawType() != baseType) { - return null; - } - - final Map> labelToDelegate - = new LinkedHashMap>(); - final Map, TypeAdapter> subtypeToDelegate - = new LinkedHashMap, TypeAdapter>(); - for (Map.Entry> entry : labelToSubtype.entrySet()) { - TypeAdapter delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue())); - labelToDelegate.put(entry.getKey(), delegate); - subtypeToDelegate.put(entry.getValue(), delegate); - } - - return new TypeAdapter() { - @Override - public R read(JsonReader in) throws IOException { - JsonElement jsonElement = Streams.parse(in); - JsonElement labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName); - if (labelJsonElement == null) { - throw new JsonParseException("cannot deserialize " + baseType - + " because it does not define a field named " + typeFieldName); - } - String label = labelJsonElement.getAsString(); - @SuppressWarnings("unchecked") // registration requires that subtype extends T - TypeAdapter delegate = (TypeAdapter) labelToDelegate.get(label); - if (delegate == null) { - throw new JsonParseException("cannot deserialize " + baseType + " subtype named " - + label + "; did you forget to register a subtype?"); - } - return delegate.fromJsonTree(jsonElement); - } - - @Override - public void write(JsonWriter out, R value) throws IOException { - Class srcType = value.getClass(); - String label = subtypeToLabel.get(srcType); - @SuppressWarnings("unchecked") // registration requires that subtype extends T - TypeAdapter delegate = (TypeAdapter) subtypeToDelegate.get(srcType); - if (delegate == null) { - throw new JsonParseException("cannot serialize " + srcType.getName() - + "; did you forget to register a subtype?"); - } - JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject(); - if (jsonObject.has(typeFieldName)) { - throw new JsonParseException("cannot serialize " + srcType.getName() - + " because it already defines a field named " + typeFieldName); - } - JsonObject clone = new JsonObject(); - clone.add(typeFieldName, new JsonPrimitive(label)); - for (Map.Entry e : jsonObject.entrySet()) { - clone.add(e.getKey(), e.getValue()); - } - Streams.write(clone, out); - } - }.nullSafe(); - } -} \ No newline at end of file From 324bfccfb34eb3a1963467a6e403fa86f8149c21 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:49:35 +0530 Subject: [PATCH 05/41] #109 moved these classes to core module --- .../java/com/flipkart/batching/Batch.java | 31 ------ .../java/com/flipkart/batching/BatchImpl.java | 61 ------------ .../main/java/com/flipkart/batching/Data.java | 76 --------------- .../com/flipkart/batching/DataCollection.java | 95 ------------------- .../com/flipkart/batching/data/EventData.java | 41 -------- .../java/com/flipkart/batching/data/Tag.java | 65 ------------- .../com/flipkart/batching/data/TagData.java | 61 ------------ 7 files changed, 430 deletions(-) delete mode 100644 batching/src/main/java/com/flipkart/batching/Batch.java delete mode 100644 batching/src/main/java/com/flipkart/batching/BatchImpl.java delete mode 100644 batching/src/main/java/com/flipkart/batching/Data.java delete mode 100644 batching/src/main/java/com/flipkart/batching/DataCollection.java delete mode 100644 batching/src/main/java/com/flipkart/batching/data/EventData.java delete mode 100644 batching/src/main/java/com/flipkart/batching/data/Tag.java delete mode 100644 batching/src/main/java/com/flipkart/batching/data/TagData.java diff --git a/batching/src/main/java/com/flipkart/batching/Batch.java b/batching/src/main/java/com/flipkart/batching/Batch.java deleted file mode 100644 index 9aaa0f5..0000000 --- a/batching/src/main/java/com/flipkart/batching/Batch.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching; - -import java.util.Collection; - -public interface Batch { - Collection getDataCollection(); -} diff --git a/batching/src/main/java/com/flipkart/batching/BatchImpl.java b/batching/src/main/java/com/flipkart/batching/BatchImpl.java deleted file mode 100644 index 9e9cf87..0000000 --- a/batching/src/main/java/com/flipkart/batching/BatchImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching; - -import com.google.gson.annotations.SerializedName; - -import java.util.Collection; - -/** - * A simple implementation of Batch interface - */ - -public class BatchImpl implements Batch { - - @SerializedName("dataCollection") - private DataCollection dataCollection; - - public BatchImpl(Collection dataCollection) { - this.dataCollection = new DataCollection<>(dataCollection); - } - - @Override - public Collection getDataCollection() { - return dataCollection.dataCollection; - } - - @Override - public boolean equals(Object o) { - if (o instanceof Batch) { - return dataCollection.equals(((BatchImpl) o).dataCollection); - } - return super.equals(o); - } - - @Override - public int hashCode() { - return dataCollection == null ? 0 : dataCollection.hashCode(); - } -} diff --git a/batching/src/main/java/com/flipkart/batching/Data.java b/batching/src/main/java/com/flipkart/batching/Data.java deleted file mode 100644 index ed288aa..0000000 --- a/batching/src/main/java/com/flipkart/batching/Data.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching; - -import com.flipkart.batching.data.Tag; -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -/** - * This is an abstract base class for storing data which implements {@link Serializable}. - *

- * A custom data class must extend this class and call the super in the constructor with - * {@link Tag} and {@link Object} as parameters. - * - * @see Tag - * @see Object - */ - -public abstract class Data implements Serializable { - @SerializedName("eventId") - private long eventId; - - /** - * Constructor for Data object. This constructor takes {@link Tag} and {@link Object} as - * parameter and generates an eventId = (System.currentTimeMillis() + System.nanoTime()) - */ - - public Data() { - this.eventId = System.currentTimeMillis() + System.nanoTime(); - } - - public long getEventId() { - return eventId; - } - - public void setEventId(long eventId) { - this.eventId = eventId; - } - - @Override - public boolean equals(Object o) { - if (o instanceof Data) { - return ((Data) o).getEventId() == getEventId(); - } else { - return super.equals(o); - } - } - - @Override - public int hashCode() { - return Long.valueOf(eventId).hashCode(); - } -} diff --git a/batching/src/main/java/com/flipkart/batching/DataCollection.java b/batching/src/main/java/com/flipkart/batching/DataCollection.java deleted file mode 100644 index 9850f9d..0000000 --- a/batching/src/main/java/com/flipkart/batching/DataCollection.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.Collection; - -/** - * DataCollection class - */ - -public class DataCollection { - @SerializedName("dataCollection") - Collection dataCollection; - - DataCollection(Collection dataCollection) { - this.dataCollection = dataCollection; - } - - @Override - public boolean equals(Object o) { - if (o instanceof DataCollection) { - return dataCollection.equals(((DataCollection) o).dataCollection); - } - return super.equals(o); - } - - @Override - public int hashCode() { - return dataCollection == null ? 0 : dataCollection.hashCode(); - } - - public static class Serializer implements JsonSerializer { - @Override - public JsonElement serialize(DataCollection src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject result = new JsonObject(); - JsonElement dataCollectionArray = null; - if (null != src.dataCollection) { - Type type = new TypeToken>() { - }.getType(); - dataCollectionArray = context.serialize(src.dataCollection, type); - } - result.add("dataCollection", dataCollectionArray); - return result; - } - } - - public static class DeSerializer implements JsonDeserializer { - @Override - public DataCollection deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - if (null != json && json.isJsonObject()) { - JsonElement dataCollectionJson = json.getAsJsonObject().get("dataCollection"); - if (null != dataCollectionJson) { - Type type = new TypeToken>() { - }.getType(); - Collection dataCollection = context.deserialize(dataCollectionJson, type); - return new DataCollection(dataCollection); - } - } - return null; - } - } -} diff --git a/batching/src/main/java/com/flipkart/batching/data/EventData.java b/batching/src/main/java/com/flipkart/batching/data/EventData.java deleted file mode 100644 index e1cbc6c..0000000 --- a/batching/src/main/java/com/flipkart/batching/data/EventData.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching.data; - -import com.flipkart.batching.Data; - -/** - * EventData class that extends {@link Data}. - */ -public class EventData extends Data { - public EventData() { - super(); - } - - @Override - public String toString() { - return super.toString() + ":" + getEventId(); - } -} diff --git a/batching/src/main/java/com/flipkart/batching/data/Tag.java b/batching/src/main/java/com/flipkart/batching/data/Tag.java deleted file mode 100644 index 5e307ab..0000000 --- a/batching/src/main/java/com/flipkart/batching/data/Tag.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching.data; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -/** - * Tag represents a group of {@link com.flipkart.batching.Data} objects to batch together. - * It takes a {@link String} type ID as parameter in constructor. - */ -public class Tag implements Serializable { - - @SerializedName("id") - private String id; - - public Tag(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - @Override - public boolean equals(Object o) { - if (o instanceof Tag) { - return id.equals(((Tag) o).getId()); - } else { - return super.equals(o); - } - } - - @Override - public int hashCode() { - return id.hashCode(); - } -} diff --git a/batching/src/main/java/com/flipkart/batching/data/TagData.java b/batching/src/main/java/com/flipkart/batching/data/TagData.java deleted file mode 100644 index 4f31890..0000000 --- a/batching/src/main/java/com/flipkart/batching/data/TagData.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. - * - * 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. - */ - -package com.flipkart.batching.data; - -import com.flipkart.batching.Data; -import com.google.gson.annotations.SerializedName; - -/** - * TagData Class that extends {@link Data}. - * It takes {@link Tag} as a parameter in constructor. - */ -public class TagData extends Data { - - @SerializedName("tag") - private final Tag tag; - - public TagData(Tag tag) { - super(); - this.tag = tag; - } - - public Tag getTag() { - return tag; - } - - @Override - public boolean equals(Object o) { - if (o instanceof TagData) { - return ((TagData) o).getTag().equals(tag) && super.equals(o); - } else { - return super.equals(o); - } - } - - @Override - public int hashCode() { - return 31 * super.hashCode() + (getTag() == null ? 0 : getTag().hashCode()); - } -} From 9e6bc612d3d403e40b6a8c890a8fffb6fb4e40e1 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:50:02 +0530 Subject: [PATCH 06/41] #109 added dependency of batching core --- batching/build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/batching/build.gradle b/batching/build.gradle index f1d213c..729b015 100644 --- a/batching/build.gradle +++ b/batching/build.gradle @@ -23,12 +23,11 @@ */ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' apply plugin: "net.ltgt.errorprone" android { compileSdkVersion 24 - buildToolsVersion '24.0.0' + buildToolsVersion '24' lintOptions { abortOnError false @@ -63,7 +62,8 @@ dependencies { testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.robolectric:robolectric:3.1' - compile 'com.google.code.gson:gson:2.4' + + compile project(':batching-core') compile 'org.jetbrains:annotations-java5:15.0' compile 'org.slf4j:slf4j-api:1.7.6' errorprone 'com.google.errorprone:error_prone_core:2.0.9' @@ -75,7 +75,7 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.android.tools.build:gradle:2.2.0-beta1' classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.8" From 68f6ebfa09894c6b0171f79a86abd464edbb2c59 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:50:25 +0530 Subject: [PATCH 07/41] #109 import fixes in listener package --- .../NetworkPersistedBatchReadyListener.java | 7 ++++--- .../listener/PersistedBatchCallback.java | 4 ++-- .../listener/PersistedBatchReadyListener.java | 8 ++++---- .../listener/TagBatchReadyListener.java | 20 +++++++++---------- .../TrimPersistedBatchReadyListener.java | 6 +++--- .../listener/TrimmedBatchCallback.java | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java index 7efca83..5b9406b 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java @@ -33,10 +33,10 @@ import android.os.Handler; import android.webkit.ValueCallback; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching.Data; -import com.flipkart.batching.persistence.SerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import org.slf4j.LoggerFactory; @@ -81,6 +81,7 @@ public void onFinish() { unregisterReceiver(); } }; + public NetworkPersistedBatchReadyListener(final Context context, String filePath, SerializationStrategy serializationStrategy, final Handler handler, NetworkBatchListener listener, diff --git a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java index 380b4d6..bf61dc4 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java +++ b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java @@ -24,7 +24,7 @@ package com.flipkart.batching.listener; -import com.flipkart.batching.Batch; +import com.flipkart.batchingcore.Batch; /** * Persisted Batch Callback @@ -35,4 +35,4 @@ public interface PersistedBatchCallback { void onPersistSuccess(T batch); void onFinish(); -} +} \ No newline at end of file diff --git a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java index ec1c33e..a392238 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java @@ -26,16 +26,16 @@ import android.os.Handler; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.BatchObjectConverter; -import com.flipkart.batching.persistence.SerializationStrategy; import com.flipkart.batching.tape.InMemoryObjectQueue; import com.flipkart.batching.tape.ObjectQueue; import com.flipkart.batching.toolbox.LenientFileObjectQueue; import com.flipkart.batching.toolbox.LenientQueueFile; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import org.jetbrains.annotations.Nullable; import org.slf4j.LoggerFactory; @@ -259,4 +259,4 @@ private void callQueueEnd() { listener.onFinish(); } } -} +} \ No newline at end of file diff --git a/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java index 6d2abac..391ebe9 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java @@ -26,9 +26,9 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; -import com.flipkart.batching.strategy.TagBatchingStrategy; +import com.flipkart.batchingcore.batch.TagBatch; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import java.util.HashMap; import java.util.Map; @@ -36,27 +36,27 @@ /** * TagBatchReadyListener that implements {@link OnBatchReadyListener}. */ -public class TagBatchReadyListener implements OnBatchReadyListener> { - private Map>> tagOnBatchReadyListenerMap; +public class TagBatchReadyListener implements OnBatchReadyListener> { + private Map>> tagOnBatchReadyListenerMap; public TagBatchReadyListener() { tagOnBatchReadyListenerMap = new HashMap<>(); } - public Map>> getTagOnBatchReadyListenerMap() { + public Map>> getTagOnBatchReadyListenerMap() { return tagOnBatchReadyListenerMap; } - public void addListenerForTag(Tag tag, OnBatchReadyListener> listener) { + public void addListenerForTag(Tag tag, OnBatchReadyListener> listener) { tagOnBatchReadyListenerMap.put(tag, listener); } - private OnBatchReadyListener> getListenerByTag(Tag tag) { + private OnBatchReadyListener> getListenerByTag(Tag tag) { return tagOnBatchReadyListenerMap.get(tag); } @Override - public void onReady(BatchingStrategy> causingStrategy, TagBatchingStrategy.TagBatch batch) { + public void onReady(BatchingStrategy> causingStrategy, TagBatch batch) { getListenerByTag(batch.getTag()).onReady(causingStrategy, batch); } -} +} \ No newline at end of file diff --git a/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java index 87d68bb..a1bec2e 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java @@ -26,10 +26,10 @@ import android.os.Handler; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching.Data; -import com.flipkart.batching.persistence.SerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/listener/TrimmedBatchCallback.java b/batching/src/main/java/com/flipkart/batching/listener/TrimmedBatchCallback.java index 4b3fc18..d18ee1b 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/TrimmedBatchCallback.java +++ b/batching/src/main/java/com/flipkart/batching/listener/TrimmedBatchCallback.java @@ -29,4 +29,4 @@ */ public interface TrimmedBatchCallback { void onTrimmed(int oldSize, int newSize); -} +} \ No newline at end of file From 32be7b73bf6f001af44fd7a54a1ee3884d43eeba Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:50:38 +0530 Subject: [PATCH 08/41] #109 import fixes in persistence package --- .../batching/persistence/BatchObjectConverter.java | 5 +++-- .../batching/persistence/DataObjectConverter.java | 5 +++-- .../flipkart/batching/persistence/DatabaseHelper.java | 9 +++++---- .../persistence/InMemoryPersistenceStrategy.java | 2 +- .../batching/persistence/PersistenceStrategy.java | 2 +- .../batching/persistence/SQLPersistenceStrategy.java | 9 +++++---- .../persistence/TagBasedPersistenceStrategy.java | 6 +++--- .../batching/persistence/TapePersistenceStrategy.java | 5 +++-- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java b/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java index acbf7b9..a3314a2 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java @@ -24,9 +24,10 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching.Batch; -import com.flipkart.batching.Data; import com.flipkart.batching.tape.FileObjectQueue; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import java.io.IOException; import java.io.OutputStream; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java b/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java index a50ac10..369f2a7 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java @@ -24,9 +24,10 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching.Batch; -import com.flipkart.batching.Data; import com.flipkart.batching.tape.FileObjectQueue; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import java.io.IOException; import java.io.OutputStream; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java b/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java index efe7021..bf89dd1 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java @@ -31,10 +31,11 @@ import android.database.sqlite.SQLiteOpenHelper; import android.text.TextUtils; -import com.flipkart.batching.Batch; -import com.flipkart.batching.Data; -import com.flipkart.batching.exception.DeserializeException; -import com.flipkart.batching.exception.SerializeException; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.exception.DeserializeException; +import com.flipkart.batchingcore.exception.SerializeException; import java.util.ArrayList; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java index 54978f1..6154685 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java @@ -24,7 +24,7 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching.Data; +import com.flipkart.batchingcore.Data; import java.util.ArrayList; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java index d0d8d50..c3a302a 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java @@ -24,7 +24,7 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching.Data; +import com.flipkart.batchingcore.Data; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java index b288acb..a586c64 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java @@ -26,10 +26,11 @@ import android.content.Context; -import com.flipkart.batching.Batch; -import com.flipkart.batching.Data; -import com.flipkart.batching.exception.DeserializeException; -import com.flipkart.batching.exception.SerializeException; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.exception.DeserializeException; +import com.flipkart.batchingcore.exception.SerializeException; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java index 6010a06..d4017df 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java @@ -24,9 +24,9 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching.Data; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import java.util.Collection; import java.util.Iterator; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java index 66f93a3..e9d312a 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java @@ -24,13 +24,14 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching.Batch; -import com.flipkart.batching.Data; import com.flipkart.batching.tape.FileObjectQueue; import com.flipkart.batching.tape.InMemoryObjectQueue; import com.flipkart.batching.tape.ObjectQueue; import com.flipkart.batching.toolbox.LenientFileObjectQueue; import com.flipkart.batching.toolbox.LenientQueueFile; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import org.slf4j.LoggerFactory; From 6c165fbe3acd7778ade8c3203b087b8c127fd12e Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:50:55 +0530 Subject: [PATCH 09/41] #109 import fixes in strategy package --- .../strategy/BaseBatchingStrategy.java | 4 +- .../strategy/SizeBatchingStrategy.java | 37 ++------------ .../strategy/SizeTimeBatchingStrategy.java | 48 ++----------------- .../strategy/TagBatchingStrategy.java | 41 +++------------- .../strategy/TimeBatchingStrategy.java | 35 ++------------ 5 files changed, 18 insertions(+), 147 deletions(-) diff --git a/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java index 5a6898c..654c908 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java @@ -27,12 +27,12 @@ import android.content.Context; import android.os.Handler; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchController; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java index 8311f3b..8abfa3d 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java @@ -27,12 +27,11 @@ import android.content.Context; import android.os.Handler; -import com.flipkart.batching.BatchImpl; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.google.gson.annotations.SerializedName; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.SizeBatch; import java.util.Collection; @@ -43,7 +42,7 @@ * {@link PersistenceStrategy} and calls {@link #onReadyListener} when the batch reaches the * maxBatchSize limit. */ -public class SizeBatchingStrategy extends BaseBatchingStrategy> { +public class SizeBatchingStrategy extends BaseBatchingStrategy> { private int currentBatchSize; private int maxBatchSize; @@ -75,8 +74,7 @@ public void flush(boolean forced) { } @Override - public void onInitialized(Context context, - OnBatchReadyListener> onBatchReadyListener, Handler handler) { + public void onInitialized(Context context, OnBatchReadyListener> onBatchReadyListener, Handler handler) { super.onInitialized(context, onBatchReadyListener, handler); } @@ -88,31 +86,4 @@ public void onInitialized(Context context, protected boolean isBatchReady() { return currentBatchSize >= maxBatchSize; } - - public static class SizeBatch extends BatchImpl { - @SerializedName("maxBatchSize") - private int maxBatchSize; - - public SizeBatch(Collection dataCollection, int maxBatchSize) { - super(dataCollection); - this.maxBatchSize = maxBatchSize; - } - - public int getMaxBatchSize() { - return maxBatchSize; - } - - @Override - public boolean equals(Object o) { - if (o instanceof SizeBatch) { - return ((SizeBatch) o).getMaxBatchSize() == maxBatchSize && super.equals(o); - } - return super.equals(o); - } - - @Override - public int hashCode() { - return 31 * super.hashCode() + maxBatchSize; - } - } } diff --git a/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java index 3137e23..0173710 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java @@ -27,12 +27,10 @@ import android.content.Context; import android.os.Handler; -import com.flipkart.batching.Batch; -import com.flipkart.batching.BatchImpl; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.google.gson.annotations.SerializedName; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.SizeTimeBatch; import java.util.Collection; @@ -40,7 +38,7 @@ * Created by kushal.sharma on 18/04/16. * Time Size Batching Strategy */ -public class SizeTimeBatchingStrategy extends BaseBatchingStrategy> { +public class SizeTimeBatchingStrategy extends BaseBatchingStrategy> { private int currentBatchSize; private int maxBatchSize; private long timeOut; @@ -118,44 +116,4 @@ private void startTimer() { private void stopTimer() { handler.removeCallbacks(runnable); } - - public static class SizeTimeBatch extends BatchImpl { - @SerializedName("maxBatchSize") - private int maxBatchSize; - @SerializedName("timeOut") - private long timeOut; - - public SizeTimeBatch(Collection dataCollection, int maxBatchSize, long timeOut) { - super(dataCollection); - this.maxBatchSize = maxBatchSize; - this.timeOut = timeOut; - } - - public int getMaxBatchSize() { - return maxBatchSize; - } - - public long getTimeOut() { - return timeOut; - } - - @Override - public boolean equals(Object o) { - if (o instanceof SizeTimeBatch) { - return (((SizeTimeBatch) o).getMaxBatchSize() == maxBatchSize - && ((SizeTimeBatch) o).getTimeOut() == timeOut - && super.equals(o)); - - } - return super.equals(o); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + maxBatchSize; - result = 31 * result + Long.valueOf(timeOut).hashCode(); - return result; - } - } } diff --git a/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java index 25e45a3..ff27458 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java @@ -27,14 +27,13 @@ import android.content.Context; import android.os.Handler; -import com.flipkart.batching.Batch; -import com.flipkart.batching.BatchImpl; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; -import com.google.gson.annotations.SerializedName; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.TagBatch; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import java.util.Collection; import java.util.Collections; @@ -53,7 +52,7 @@ * @see TimeBatchingStrategy * @see TagBatchingStrategy */ -public class TagBatchingStrategy implements BatchingStrategy> { +public class TagBatchingStrategy implements BatchingStrategy> { private Map>> batchingStrategyMap = new HashMap<>(); private boolean initialized = false; @@ -119,32 +118,4 @@ public void flush(boolean forced) { public void addTagStrategy(Tag tag, BatchingStrategy> strategy) { batchingStrategyMap.put(tag, strategy); } - - - public static class TagBatch extends BatchImpl { - @SerializedName("tag") - private Tag tag; - - public TagBatch(Tag tag, Batch batch) { - super(batch.getDataCollection()); - this.tag = tag; - } - - public Tag getTag() { - return tag; - } - - @Override - public boolean equals(Object o) { - if (o instanceof TagBatch) { - return ((TagBatch) o).getTag().equals(tag) && super.equals(o); - } - return super.equals(o); - } - - @Override - public int hashCode() { - return 31 * super.hashCode() + (getTag() == null ? 0 : getTag().hashCode()); - } - } } diff --git a/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java index 89f08ab..d6329b9 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java @@ -27,13 +27,11 @@ import android.content.Context; import android.os.Handler; -import com.flipkart.batching.Batch; -import com.flipkart.batching.BatchImpl; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.google.gson.annotations.SerializedName; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.TimeBatch; import java.util.Collection; @@ -44,7 +42,7 @@ * {@link PersistenceStrategy}, starts/reset the timer whenever {@link Data} objects are pushed * and calls {@link #onReadyListener} when timeOut happens. */ -public class TimeBatchingStrategy extends BaseBatchingStrategy> { +public class TimeBatchingStrategy extends BaseBatchingStrategy> { private long timeOut; private Handler handler; private Runnable runnable = new Runnable() { @@ -112,32 +110,5 @@ private void startTimer() { private void stopTimer() { handler.removeCallbacks(runnable); } - - public static class TimeBatch extends BatchImpl { - @SerializedName("timeOut") - private long timeOut; - - public TimeBatch(Collection dataCollection, long timeOut) { - super(dataCollection); - this.timeOut = timeOut; - } - - public long getTimeOut() { - return timeOut; - } - - @Override - public boolean equals(Object o) { - if (o instanceof TimeBatch) { - return ((TimeBatch) o).getTimeOut() == timeOut && super.equals(o); - } - return super.equals(o); - } - - @Override - public int hashCode() { - return 31 * super.hashCode() + Long.valueOf(timeOut).hashCode(); - } - } } From 0e32482f91a285e4a3f82f09edcd4ae77efaf90f Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:51:12 +0530 Subject: [PATCH 10/41] #109 import fixes in toolbox package --- .../flipkart/batching/BatchController.java | 4 ++- .../com/flipkart/batching/BatchManager.java | 21 ++++++++++----- .../flipkart/batching/BatchingStrategy.java | 3 +++ .../batching/OnBatchReadyListener.java | 3 +++ .../flipkart/batching/TagBatchManager.java | 27 ++++++++++--------- .../toolbox/SizeTimeStrategyFactory.java | 6 ++--- 6 files changed, 41 insertions(+), 23 deletions(-) diff --git a/batching/src/main/java/com/flipkart/batching/BatchController.java b/batching/src/main/java/com/flipkart/batching/BatchController.java index 2c5a360..84be9b6 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchController.java +++ b/batching/src/main/java/com/flipkart/batching/BatchController.java @@ -26,7 +26,9 @@ import android.os.Handler; -import com.flipkart.batching.persistence.SerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/BatchManager.java b/batching/src/main/java/com/flipkart/batching/BatchManager.java index ccd2550..475128e 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchManager.java +++ b/batching/src/main/java/com/flipkart/batching/BatchManager.java @@ -28,13 +28,20 @@ import android.os.Handler; import android.os.HandlerThread; -import com.flipkart.batching.data.EventData; -import com.flipkart.batching.data.TagData; -import com.flipkart.batching.persistence.SerializationStrategy; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; import com.flipkart.batching.strategy.TagBatchingStrategy; import com.flipkart.batching.strategy.TimeBatchingStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batchingcore.batch.SizeTimeBatch; +import com.flipkart.batchingcore.batch.TagBatch; +import com.flipkart.batchingcore.batch.TimeBatch; +import com.flipkart.batchingcore.data.EventData; +import com.flipkart.batchingcore.data.TagData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,10 +100,10 @@ public static void registerBuiltInTypes(SerializationStrategy serializationStrat serializationStrategy.registerDataType(TagData.class); serializationStrategy.registerBatch(BatchImpl.class); serializationStrategy.registerDataType(EventData.class); - serializationStrategy.registerBatch(SizeBatchingStrategy.SizeBatch.class); - serializationStrategy.registerBatch(TimeBatchingStrategy.TimeBatch.class); - serializationStrategy.registerBatch(TagBatchingStrategy.TagBatch.class); - serializationStrategy.registerBatch(SizeTimeBatchingStrategy.SizeTimeBatch.class); + serializationStrategy.registerBatch(SizeBatch.class); + serializationStrategy.registerBatch(TimeBatch.class); + serializationStrategy.registerBatch(TagBatch.class); + serializationStrategy.registerBatch(SizeTimeBatch.class); } private void registerSuppliedTypes(Builder builder, SerializationStrategy serializationStrategy) { diff --git a/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java index 7647dc6..0b4670c 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java @@ -27,6 +27,9 @@ import android.content.Context; import android.os.Handler; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; + import java.util.Collection; /** diff --git a/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java index 8860e87..5c30898 100644 --- a/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java @@ -25,6 +25,9 @@ package com.flipkart.batching; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; + public interface OnBatchReadyListener> { void onReady(BatchingStrategy causingStrategy, T batch); } diff --git a/batching/src/main/java/com/flipkart/batching/TagBatchManager.java b/batching/src/main/java/com/flipkart/batching/TagBatchManager.java index d57da2e..6d83577 100644 --- a/batching/src/main/java/com/flipkart/batching/TagBatchManager.java +++ b/batching/src/main/java/com/flipkart/batching/TagBatchManager.java @@ -28,16 +28,20 @@ import android.os.Handler; import android.os.HandlerThread; -import com.flipkart.batching.data.EventData; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; import com.flipkart.batching.listener.NetworkPersistedBatchReadyListener; import com.flipkart.batching.listener.TagBatchReadyListener; -import com.flipkart.batching.persistence.SerializationStrategy; -import com.flipkart.batching.strategy.SizeBatchingStrategy; -import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; import com.flipkart.batching.strategy.TagBatchingStrategy; -import com.flipkart.batching.strategy.TimeBatchingStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batchingcore.batch.SizeTimeBatch; +import com.flipkart.batchingcore.batch.TagBatch; +import com.flipkart.batchingcore.batch.TimeBatch; +import com.flipkart.batchingcore.data.EventData; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import java.util.ArrayList; import java.util.Collection; @@ -93,10 +97,10 @@ public static void registerBuiltInTypes(SerializationStrategy serializationStrat serializationStrategy.registerDataType(TagData.class); serializationStrategy.registerBatch(BatchImpl.class); serializationStrategy.registerDataType(EventData.class); - serializationStrategy.registerBatch(SizeBatchingStrategy.SizeBatch.class); - serializationStrategy.registerBatch(TimeBatchingStrategy.TimeBatch.class); - serializationStrategy.registerBatch(TagBatchingStrategy.TagBatch.class); - serializationStrategy.registerBatch(SizeTimeBatchingStrategy.SizeTimeBatch.class); + serializationStrategy.registerBatch(SizeBatch.class); + serializationStrategy.registerBatch(TimeBatch.class); + serializationStrategy.registerBatch(TagBatch.class); + serializationStrategy.registerBatch(SizeTimeBatch.class); } private void initialize(TagBatchManager tagBatchManager, Context context, OnBatchReadyListener onBatchReadyListener, Handler handler) { @@ -136,7 +140,6 @@ private void assignEventIds(Collection dataCollection) { } } - @Override public Handler getHandler() { return this.handler; diff --git a/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java b/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java index fa8a932..e3c5c99 100644 --- a/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java +++ b/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java @@ -26,14 +26,14 @@ import android.content.Context; -import com.flipkart.batching.Data; -import com.flipkart.batching.data.Tag; import com.flipkart.batching.persistence.InMemoryPersistenceStrategy; import com.flipkart.batching.persistence.SQLPersistenceStrategy; -import com.flipkart.batching.persistence.SerializationStrategy; import com.flipkart.batching.persistence.TagBasedPersistenceStrategy; import com.flipkart.batching.persistence.TapePersistenceStrategy; import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.data.Tag; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; From 2f5bc4c6fb8426ae42636731519a93e7557e1d02 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:51:27 +0530 Subject: [PATCH 11/41] #109 unit test fixes --- .../src/test/java/com/flipkart/batching/BatchManagerTest.java | 2 -- .../batching/listener/NetworkPersistedBatchReadyTest.java | 2 -- .../com/flipkart/batching/listener/PersistedBatchReadyTest.java | 2 -- .../flipkart/batching/listener/TrimPersistedBatchReadyTest.java | 1 - 4 files changed, 7 deletions(-) diff --git a/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java b/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java index 49c9206..5525ba5 100644 --- a/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java +++ b/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java @@ -34,9 +34,7 @@ import com.flipkart.batching.listener.NetworkPersistedBatchReadyListener; import com.flipkart.batching.listener.NetworkPersistedBatchReadyListener.NetworkBatchListener; import com.flipkart.batching.listener.TrimPersistedBatchReadyListener; -import com.flipkart.batching.persistence.GsonSerializationStrategy; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching.persistence.SerializationStrategy; import com.flipkart.batching.persistence.TapePersistenceStrategy; import com.flipkart.batching.strategy.BaseBatchingStrategy; import com.flipkart.batching.strategy.SizeBatchingStrategy; diff --git a/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java index 284a321..338a83c 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java @@ -39,8 +39,6 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.Data; import com.flipkart.batching.exception.SerializeException; -import com.flipkart.batching.persistence.GsonSerializationStrategy; -import com.flipkart.batching.persistence.SerializationStrategy; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.tape.ObjectQueue; diff --git a/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java index dc66aec..ab3b411 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java @@ -35,8 +35,6 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.Data; import com.flipkart.batching.exception.SerializeException; -import com.flipkart.batching.persistence.GsonSerializationStrategy; -import com.flipkart.batching.persistence.SerializationStrategy; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.tape.QueueFile; diff --git a/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java index 39b1aa7..aedb089 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java @@ -35,7 +35,6 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.Data; import com.flipkart.batching.exception.SerializeException; -import com.flipkart.batching.persistence.GsonSerializationStrategy; import com.flipkart.batching.strategy.SizeBatchingStrategy; import org.junit.After; From 6e306a656b149dfe2070aa25c2d14ad079e3501e Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:52:27 +0530 Subject: [PATCH 12/41] #109 created new module + moved core files here --- batching-core/.gitignore | 1 + batching-core/build.gradle | 31 ++++++++ batching-core/proguard-rules.pro | 17 ++++ .../batchingcore/ExampleInstrumentedTest.java | 26 +++++++ batching-core/src/main/AndroidManifest.xml | 9 +++ .../java/com/flipkart/batchingcore/Batch.java | 31 ++++++++ .../com/flipkart/batchingcore/BatchImpl.java | 58 ++++++++++++++ .../java/com/flipkart/batchingcore/Data.java | 75 ++++++++++++++++++ .../flipkart/batchingcore/DataCollection.java | 52 +++++++++++++ .../batchingcore/SerializationStrategy.java | 78 +++++++++++++++++++ .../batchingcore/batch/SizeBatch.java | 33 ++++++++ .../batchingcore/batch/SizeTimeBatch.java | 44 +++++++++++ .../flipkart/batchingcore/batch/TagBatch.java | 32 ++++++++ .../batchingcore/batch/TimeBatch.java | 32 ++++++++ .../flipkart/batchingcore/data/EventData.java | 41 ++++++++++ .../com/flipkart/batchingcore/data/Tag.java | 64 +++++++++++++++ .../flipkart/batchingcore/data/TagData.java | 59 ++++++++++++++ .../exception/DeserializeException.java | 45 +++++++++++ .../exception/SerializeException.java | 46 +++++++++++ batching-core/src/main/res/values/strings.xml | 3 + .../batchingcore/ExampleUnitTest.java | 17 ++++ 21 files changed, 794 insertions(+) create mode 100644 batching-core/.gitignore create mode 100644 batching-core/build.gradle create mode 100644 batching-core/proguard-rules.pro create mode 100644 batching-core/src/androidTest/java/com/flipkart/batchingcore/ExampleInstrumentedTest.java create mode 100644 batching-core/src/main/AndroidManifest.xml create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/Batch.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/BatchImpl.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/Data.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/DataCollection.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/SerializationStrategy.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeBatch.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeTimeBatch.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/batch/TagBatch.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/batch/TimeBatch.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/data/EventData.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/data/Tag.java create mode 100644 batching-core/src/main/java/com/flipkart/batchingcore/data/TagData.java create mode 100755 batching-core/src/main/java/com/flipkart/batchingcore/exception/DeserializeException.java create mode 100755 batching-core/src/main/java/com/flipkart/batchingcore/exception/SerializeException.java create mode 100644 batching-core/src/main/res/values/strings.xml create mode 100644 batching-core/src/test/java/com/flipkart/batchingcore/ExampleUnitTest.java diff --git a/batching-core/.gitignore b/batching-core/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/batching-core/.gitignore @@ -0,0 +1 @@ +/build diff --git a/batching-core/build.gradle b/batching-core/build.gradle new file mode 100644 index 0000000..a42ac84 --- /dev/null +++ b/batching-core/build.gradle @@ -0,0 +1,31 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 24 + buildToolsVersion '24' + + defaultConfig { + minSdkVersion 14 + targetSdkVersion 24 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:24.1.1' + testCompile 'junit:junit:4.12' +} diff --git a/batching-core/proguard-rules.pro b/batching-core/proguard-rules.pro new file mode 100644 index 0000000..3356a4c --- /dev/null +++ b/batching-core/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/anirudh.r/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/batching-core/src/androidTest/java/com/flipkart/batchingcore/ExampleInstrumentedTest.java b/batching-core/src/androidTest/java/com/flipkart/batchingcore/ExampleInstrumentedTest.java new file mode 100644 index 0000000..c8b9e59 --- /dev/null +++ b/batching-core/src/androidTest/java/com/flipkart/batchingcore/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.flipkart.batchingcore; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.flipkart.batchingcore.test", appContext.getPackageName()); + } +} diff --git a/batching-core/src/main/AndroidManifest.xml b/batching-core/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0335046 --- /dev/null +++ b/batching-core/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/Batch.java b/batching-core/src/main/java/com/flipkart/batchingcore/Batch.java new file mode 100644 index 0000000..f04da98 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/Batch.java @@ -0,0 +1,31 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore; + +import java.util.Collection; + +public interface Batch { + Collection getDataCollection(); +} \ No newline at end of file diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/BatchImpl.java b/batching-core/src/main/java/com/flipkart/batchingcore/BatchImpl.java new file mode 100644 index 0000000..979d833 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/BatchImpl.java @@ -0,0 +1,58 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore; + +import java.util.Collection; + +/** + * A simple implementation of Batch interface + */ + +public class BatchImpl implements Batch { + + private DataCollection dataCollection; + + public BatchImpl(Collection dataCollection) { + this.dataCollection = new DataCollection<>(dataCollection); + } + + @Override + public Collection getDataCollection() { + return dataCollection.dataCollection; + } + + @Override + public boolean equals(Object o) { + if (o instanceof Batch) { + return dataCollection.equals(((BatchImpl) o).dataCollection); + } + return super.equals(o); + } + + @Override + public int hashCode() { + return dataCollection == null ? 0 : dataCollection.hashCode(); + } +} diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/Data.java b/batching-core/src/main/java/com/flipkart/batchingcore/Data.java new file mode 100644 index 0000000..6b24b1d --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/Data.java @@ -0,0 +1,75 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore; + + +import com.flipkart.batchingcore.data.Tag; + +import java.io.Serializable; + +/** + * This is an abstract base class for storing data which implements {@link Serializable}. + *

+ * A custom data class must extend this class and call the super in the constructor with + * {@link Tag} and {@link Object} as parameters. + * + * @see Tag + * @see Object + */ + +public abstract class Data implements Serializable { + private long eventId; + + /** + * Constructor for Data object. This constructor takes {@link Tag} and {@link Object} as + * parameter and generates an eventId = (System.currentTimeMillis() + System.nanoTime()) + */ + + public Data() { + this.eventId = System.currentTimeMillis() + System.nanoTime(); + } + + public long getEventId() { + return eventId; + } + + public void setEventId(long eventId) { + this.eventId = eventId; + } + + @Override + public boolean equals(Object o) { + if (o instanceof Data) { + return ((Data) o).getEventId() == getEventId(); + } else { + return super.equals(o); + } + } + + @Override + public int hashCode() { + return Long.valueOf(eventId).hashCode(); + } +} diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/DataCollection.java b/batching-core/src/main/java/com/flipkart/batchingcore/DataCollection.java new file mode 100644 index 0000000..7f483ed --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/DataCollection.java @@ -0,0 +1,52 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore; + +import java.util.Collection; + +/** + * DataCollection class + */ + +public class DataCollection { + public Collection dataCollection; + + public DataCollection(Collection dataCollection) { + this.dataCollection = dataCollection; + } + + @Override + public boolean equals(Object o) { + if (o instanceof DataCollection) { + return dataCollection.equals(((DataCollection) o).dataCollection); + } + return super.equals(o); + } + + @Override + public int hashCode() { + return dataCollection == null ? 0 : dataCollection.hashCode(); + } +} diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/SerializationStrategy.java b/batching-core/src/main/java/com/flipkart/batchingcore/SerializationStrategy.java new file mode 100644 index 0000000..a2acb33 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/SerializationStrategy.java @@ -0,0 +1,78 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore; + +import com.flipkart.batchingcore.exception.DeserializeException; +import com.flipkart.batchingcore.exception.SerializeException; + +import java.util.Collection; + +/** + * This is an interface for serialization strategy. An implementation of this class + * must override all it's methods. + */ +public interface SerializationStrategy { + + /** + * Register sub classes of {@link Data} + * + * @param subClass The sub class of {@link Data} + */ + void registerDataType(Class subClass); + + void registerBatch(Class subClass); + + /** + * After registering subtypes using {@link #registerDataType(Class)}} & {@link #registerBatch(Class)}, this method has to be called. + * After build is called, no more register calls can happen. + */ + void build(); + + /** + * This method serialize the provided {@link Data} object. + * + * @param data {@link Data} object to be serialized + * @return byte array + * @throws SerializeException + */ + byte[] serializeData(E data) throws SerializeException; + + byte[] serializeCollection(Collection data) throws SerializeException; + + byte[] serializeBatch(T batch) throws SerializeException; + + /** + * This method deserialize the provided byte array of data. + * + * @param data byte[] type data + * @return {@link Object} type data + * @throws DeserializeException + */ + E deserializeData(byte[] data) throws DeserializeException; + + Collection deserializeCollection(byte[] data) throws DeserializeException; + + T deserializeBatch(byte[] data) throws DeserializeException; +} \ No newline at end of file diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeBatch.java b/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeBatch.java new file mode 100644 index 0000000..588aff4 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeBatch.java @@ -0,0 +1,33 @@ +package com.flipkart.batchingcore.batch; + + +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.Data; + +import java.util.Collection; + +public class SizeBatch extends BatchImpl { + private int maxBatchSize; + + public SizeBatch(Collection dataCollection, int maxBatchSize) { + super(dataCollection); + this.maxBatchSize = maxBatchSize; + } + + public int getMaxBatchSize() { + return maxBatchSize; + } + + @Override + public boolean equals(Object o) { + if (o instanceof SizeBatch) { + return ((SizeBatch) o).getMaxBatchSize() == maxBatchSize && super.equals(o); + } + return super.equals(o); + } + + @Override + public int hashCode() { + return 31 * super.hashCode() + maxBatchSize; + } +} \ No newline at end of file diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeTimeBatch.java b/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeTimeBatch.java new file mode 100644 index 0000000..b3272d6 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeTimeBatch.java @@ -0,0 +1,44 @@ +package com.flipkart.batchingcore.batch; + +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.Data; + +import java.util.Collection; + +public class SizeTimeBatch extends BatchImpl { + private int maxBatchSize; + private long timeOut; + + public SizeTimeBatch(Collection dataCollection, int maxBatchSize, long timeOut) { + super(dataCollection); + this.maxBatchSize = maxBatchSize; + this.timeOut = timeOut; + } + + public int getMaxBatchSize() { + return maxBatchSize; + } + + public long getTimeOut() { + return timeOut; + } + + @Override + public boolean equals(Object o) { + if (o instanceof SizeTimeBatch) { + return (((SizeTimeBatch) o).getMaxBatchSize() == maxBatchSize + && ((SizeTimeBatch) o).getTimeOut() == timeOut + && super.equals(o)); + + } + return super.equals(o); + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + maxBatchSize; + result = 31 * result + Long.valueOf(timeOut).hashCode(); + return result; + } +} \ No newline at end of file diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/batch/TagBatch.java b/batching-core/src/main/java/com/flipkart/batchingcore/batch/TagBatch.java new file mode 100644 index 0000000..098f73c --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/batch/TagBatch.java @@ -0,0 +1,32 @@ +package com.flipkart.batchingcore.batch; + +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; + +public class TagBatch extends BatchImpl { + private Tag tag; + + public TagBatch(Tag tag, Batch batch) { + super(batch.getDataCollection()); + this.tag = tag; + } + + public Tag getTag() { + return tag; + } + + @Override + public boolean equals(Object o) { + if (o instanceof TagBatch) { + return ((TagBatch) o).getTag().equals(tag) && super.equals(o); + } + return super.equals(o); + } + + @Override + public int hashCode() { + return 31 * super.hashCode() + (getTag() == null ? 0 : getTag().hashCode()); + } +} \ No newline at end of file diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/batch/TimeBatch.java b/batching-core/src/main/java/com/flipkart/batchingcore/batch/TimeBatch.java new file mode 100644 index 0000000..1999fe3 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/batch/TimeBatch.java @@ -0,0 +1,32 @@ +package com.flipkart.batchingcore.batch; + +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.Data; + +import java.util.Collection; + +public class TimeBatch extends BatchImpl { + private long timeOut; + + public TimeBatch(Collection dataCollection, long timeOut) { + super(dataCollection); + this.timeOut = timeOut; + } + + public long getTimeOut() { + return timeOut; + } + + @Override + public boolean equals(Object o) { + if (o instanceof TimeBatch) { + return ((TimeBatch) o).getTimeOut() == timeOut && super.equals(o); + } + return super.equals(o); + } + + @Override + public int hashCode() { + return 31 * super.hashCode() + Long.valueOf(timeOut).hashCode(); + } +} \ No newline at end of file diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/data/EventData.java b/batching-core/src/main/java/com/flipkart/batchingcore/data/EventData.java new file mode 100644 index 0000000..d12a2a1 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/data/EventData.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore.data; + +import com.flipkart.batchingcore.Data; + +/** + * EventData class that extends {@link Data}. + */ +public class EventData extends Data { + public EventData() { + super(); + } + + @Override + public String toString() { + return super.toString() + ":" + getEventId(); + } +} diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/data/Tag.java b/batching-core/src/main/java/com/flipkart/batchingcore/data/Tag.java new file mode 100644 index 0000000..904d041 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/data/Tag.java @@ -0,0 +1,64 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore.data; + +import com.flipkart.batchingcore.Data; + +import java.io.Serializable; + +/** + * Tag represents a group of {@link Data} objects to batch together. + * It takes a {@link String} type ID as parameter in constructor. + */ +public class Tag implements Serializable { + + private String id; + + public Tag(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public boolean equals(Object o) { + if (o instanceof Tag) { + return id.equals(((Tag) o).getId()); + } else { + return super.equals(o); + } + } + + @Override + public int hashCode() { + return id.hashCode(); + } +} \ No newline at end of file diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/data/TagData.java b/batching-core/src/main/java/com/flipkart/batchingcore/data/TagData.java new file mode 100644 index 0000000..97d98c8 --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/data/TagData.java @@ -0,0 +1,59 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore.data; + +import com.flipkart.batchingcore.Data; + +/** + * TagData Class that extends {@link Data}. + * It takes {@link Tag} as a parameter in constructor. + */ +public class TagData extends Data { + + private final Tag tag; + + public TagData(Tag tag) { + super(); + this.tag = tag; + } + + public Tag getTag() { + return tag; + } + + @Override + public boolean equals(Object o) { + if (o instanceof TagData) { + return ((TagData) o).getTag().equals(tag) && super.equals(o); + } else { + return super.equals(o); + } + } + + @Override + public int hashCode() { + return 31 * super.hashCode() + (getTag() == null ? 0 : getTag().hashCode()); + } +} diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/exception/DeserializeException.java b/batching-core/src/main/java/com/flipkart/batchingcore/exception/DeserializeException.java new file mode 100755 index 0000000..4571e7a --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/exception/DeserializeException.java @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore.exception; + +import java.io.IOException; + +/** + * DeserializationException class that extends {@link IOException}. + *

+ * To get the real exception use {@link #getRealException()}. + */ +public class DeserializeException extends IOException { + private final Exception realException; + + public DeserializeException(Exception realException) { + super(realException.getCause()); + this.realException = realException; + } + + public Exception getRealException() { + return realException; + } +} diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/exception/SerializeException.java b/batching-core/src/main/java/com/flipkart/batchingcore/exception/SerializeException.java new file mode 100755 index 0000000..71a15eb --- /dev/null +++ b/batching-core/src/main/java/com/flipkart/batchingcore/exception/SerializeException.java @@ -0,0 +1,46 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore.exception; + +import java.io.IOException; + +/** + * SerializationException class that extends {@link IOException}. + *

+ * To get the real exception use {@link #getRealException()}. + */ +public class SerializeException extends IOException { + private final Exception realException; + + public SerializeException(Exception realException) { + super(realException.getCause()); + this.realException = realException; + } + + public Exception getRealException() { + return realException; + } +} + diff --git a/batching-core/src/main/res/values/strings.xml b/batching-core/src/main/res/values/strings.xml new file mode 100644 index 0000000..0072300 --- /dev/null +++ b/batching-core/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Batching Core + diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/ExampleUnitTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/ExampleUnitTest.java new file mode 100644 index 0000000..14cbd7f --- /dev/null +++ b/batching-core/src/test/java/com/flipkart/batchingcore/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.flipkart.batchingcore; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file From e9c1167f7b9f6983f07f3f5aa7022aea37e57d6a Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 10:52:58 +0530 Subject: [PATCH 13/41] #109 created new module + moved gson specific files here --- batching-gson/.gitignore | 1 + batching-gson/build.gradle | 30 ++ batching-gson/proguard-rules.pro | 17 + .../ExampleInstrumentedTest.java | 26 ++ batching-gson/src/main/AndroidManifest.xml | 9 + .../utils/GsonSerializationStrategy.java | 362 ++++++++++++++++++ .../utils/RuntimeTypeAdapterFactory.java | 250 ++++++++++++ .../utils/utils/Deserializer.java | 28 ++ .../batching_gson/utils/utils/Serializer.java | 27 ++ batching-gson/src/main/res/values/strings.xml | 3 + .../batching_gson/ExampleUnitTest.java | 17 + 11 files changed, 770 insertions(+) create mode 100644 batching-gson/.gitignore create mode 100644 batching-gson/build.gradle create mode 100644 batching-gson/proguard-rules.pro create mode 100644 batching-gson/src/androidTest/java/com/flipkart/batching_gson/ExampleInstrumentedTest.java create mode 100644 batching-gson/src/main/AndroidManifest.xml create mode 100644 batching-gson/src/main/java/com/flipkart/batching_gson/utils/GsonSerializationStrategy.java create mode 100644 batching-gson/src/main/java/com/flipkart/batching_gson/utils/RuntimeTypeAdapterFactory.java create mode 100644 batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Deserializer.java create mode 100644 batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Serializer.java create mode 100644 batching-gson/src/main/res/values/strings.xml create mode 100644 batching-gson/src/test/java/com/flipkart/batching_gson/ExampleUnitTest.java diff --git a/batching-gson/.gitignore b/batching-gson/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/batching-gson/.gitignore @@ -0,0 +1 @@ +/build diff --git a/batching-gson/build.gradle b/batching-gson/build.gradle new file mode 100644 index 0000000..2eb225f --- /dev/null +++ b/batching-gson/build.gradle @@ -0,0 +1,30 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 24 + buildToolsVersion '24' + + defaultConfig { + minSdkVersion 14 + targetSdkVersion 24 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.google.code.gson:gson:2.4' + compile 'com.android.support:appcompat-v7:24.1.1' + compile project(':batching-core') + testCompile 'junit:junit:4.12' +} \ No newline at end of file diff --git a/batching-gson/proguard-rules.pro b/batching-gson/proguard-rules.pro new file mode 100644 index 0000000..3356a4c --- /dev/null +++ b/batching-gson/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/anirudh.r/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/batching-gson/src/androidTest/java/com/flipkart/batching_gson/ExampleInstrumentedTest.java b/batching-gson/src/androidTest/java/com/flipkart/batching_gson/ExampleInstrumentedTest.java new file mode 100644 index 0000000..b68ddd9 --- /dev/null +++ b/batching-gson/src/androidTest/java/com/flipkart/batching_gson/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.flipkart.batching_gson; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.flipkart.batching_gson.test", appContext.getPackageName()); + } +} diff --git a/batching-gson/src/main/AndroidManifest.xml b/batching-gson/src/main/AndroidManifest.xml new file mode 100644 index 0000000..37f7942 --- /dev/null +++ b/batching-gson/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/GsonSerializationStrategy.java b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/GsonSerializationStrategy.java new file mode 100644 index 0000000..a0a277a --- /dev/null +++ b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/GsonSerializationStrategy.java @@ -0,0 +1,362 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batching_gson.utils; + +import com.flipkart.batching_gson.utils.utils.Deserializer; +import com.flipkart.batching_gson.utils.utils.Serializer; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.DataCollection; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.exception.DeserializeException; +import com.flipkart.batchingcore.exception.SerializeException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.internal.LinkedTreeMap; +import com.google.gson.reflect.TypeToken; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * Implementation of {@link SerializationStrategy}. + * + * @see SerializationStrategy + */ +public class GsonSerializationStrategy implements SerializationStrategy { + private static final String IS_JSON_OBJECT = "_com.flipkart.batching.isJsonObject"; + private static final String JSON_ARRAY_OBJECT = "_com.flipkart.batching.jsonArray"; + + Set> dataTypes = new HashSet<>(); + Set> batchInfoTypes = new HashSet<>(); + private Gson gson; + + public static JsonElement serializeJSONArray(JSONArray src, JsonSerializationContext context) { + JsonObject result = null; + try { + if (null != src) { + result = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + for (int idx = 0; idx < src.length(); idx++) { + Object value = src.get(idx); + JsonElement element = forJSONGenericObject(value, context); + jsonArray.add(element); + } + result.add(JSON_ARRAY_OBJECT, jsonArray); + } + } catch (JSONException e) { + e.printStackTrace(); + } + + return result; + } + + public static JSONArray deserializeJSONArray(JsonElement json, JsonDeserializationContext context) throws JsonParseException { + JSONArray result = null; + if (null != json) { + result = new JSONArray(); + if (json.isJsonObject() && json.getAsJsonObject().has(JSON_ARRAY_OBJECT)) { + JsonArray jsonArray = json.getAsJsonObject().getAsJsonArray(JSON_ARRAY_OBJECT); + for (JsonElement element : jsonArray) { + if (null != element) { + result.put(getObjectFromJsonElement(element, context)); + } else { + result.put(null); + } + } + } + } + return result; + } + + public static JsonElement serializeJSONObject(JSONObject src, JsonSerializationContext context) { + JsonObject result = null; + if (null != src) { + try { + result = new JsonObject(); + Iterator iterator = src.keys(); + while (iterator.hasNext()) { + String key = iterator.next(); + Object value = src.get(key); + JsonElement element = forJSONGenericObject(value, context); + result.add(key, element); + result.addProperty(IS_JSON_OBJECT, true); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + return result; + + } + + public static JSONObject deserializeJSONObject(JsonElement json, JsonDeserializationContext context) throws JsonParseException { + JSONObject result = null; + if (null != json && json.isJsonObject()) { + try { + result = new JSONObject(); + JsonObject jsonObject = json.getAsJsonObject(); + for (Map.Entry entry : jsonObject.entrySet()) { + JsonElement value = entry.getValue(); + if (null != value) { + result.put(entry.getKey(), getObjectFromJsonElement(entry.getValue(), context)); + } else { + result.put(entry.getKey(), null); + } + } + result.remove(IS_JSON_OBJECT); + } catch (JSONException e) { + e.printStackTrace(); + } + + } + return result; + } + + + private static Object getObjectFromJsonElement(JsonElement value, JsonDeserializationContext context) { + Object result = null; + if (value.isJsonObject()) { + if (value.getAsJsonObject().has(IS_JSON_OBJECT)) { + JSONObject jsonObject = deserializeJSONObject(value, context); + if (null != jsonObject) { + jsonObject.remove(IS_JSON_OBJECT); + } + return jsonObject; + } else if (value.getAsJsonObject().has(JSON_ARRAY_OBJECT)) { + return deserializeJSONArray(value, context); + } else { + result = getMapFromJson(value.getAsJsonObject(), context); + } + + } else if (value.isJsonPrimitive()) { + JsonPrimitive primitiveValue = value.getAsJsonPrimitive(); + if (primitiveValue.isBoolean()) { + result = primitiveValue.getAsBoolean(); + } else if (primitiveValue.isNumber()) { + result = primitiveValue.getAsNumber(); + } else { + result = primitiveValue.getAsString(); + } + } else if (value.isJsonNull()) { + result = null; + } else if (value.isJsonArray()) { + JsonArray jsonArray = value.getAsJsonArray(); + ArrayList list = new ArrayList<>(jsonArray.size()); + for (JsonElement element : jsonArray) { + list.add(getObjectFromJsonElement(element, context)); + } + result = list; + } + return result; + } + + public static Map getMapFromJson(JsonObject data, JsonDeserializationContext context) { + Map result = null; + if (null != data) { + result = new LinkedTreeMap<>(); + for (Map.Entry entry : data.entrySet()) { + result.put(entry.getKey(), getObjectFromJsonElement(entry.getValue(), context)); + } + } + return result; + } + + public static JsonElement forJSONGenericObject(Object value, JsonSerializationContext context) { + JsonElement element; + if (null != value) { + if (value instanceof JSONObject) { + element = serializeJSONObject((JSONObject) value, context); + } else if (value instanceof JSONArray) { + element = serializeJSONArray((JSONArray) value, context); + } else if (value instanceof String) { + element = new JsonPrimitive((String) value); + } else if (value instanceof Number) { + element = new JsonPrimitive((Number) value); + } else if (value instanceof Boolean) { + element = new JsonPrimitive((Boolean) value); + } else { + element = context.serialize(value); + } + } else { + element = context.serialize(value); + } + return element; + } + + @Override + public void registerDataType(Class subClass) { + dataTypes.add(subClass); + } + + @Override + public void registerBatch(Class subClass) { + batchInfoTypes.add(subClass); + } + + @Override + public void build() { + RuntimeTypeAdapterFactory dataAdapter = (RuntimeTypeAdapterFactory) RuntimeTypeAdapterFactory.of(Data.class); + for (Class dataType : dataTypes) { + dataAdapter.registerSubtype(dataType); + } + + RuntimeTypeAdapterFactory batchInfoAdapter = (RuntimeTypeAdapterFactory) RuntimeTypeAdapterFactory.of(Batch.class); + for (Class batchInfoType : batchInfoTypes) { + batchInfoAdapter.registerSubtype(batchInfoType); + } + + RuntimeTypeAdapterFactory collectionAdapter = RuntimeTypeAdapterFactory.of(Collection.class); + collectionAdapter.registerSubtype(ArrayList.class); + + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.registerTypeAdapterFactory(dataAdapter); + gsonBuilder.registerTypeAdapterFactory(batchInfoAdapter); + gsonBuilder.registerTypeAdapter(DataCollection.class, new Serializer()); + gsonBuilder.registerTypeAdapter(DataCollection.class, new Deserializer()); + gsonBuilder.registerTypeAdapter(JSONObject.class, new JSONObjectDeSerializer()); + gsonBuilder.registerTypeAdapter(JSONObject.class, new JSONObjectSerializer()); + gsonBuilder.registerTypeAdapter(JSONArray.class, new JSONArrayDeSerializer()); + gsonBuilder.registerTypeAdapter(JSONArray.class, new JSONArraySerializer()); + gson = gsonBuilder.create(); + } + + private void checkIfBuildCalled() { + if (gson == null) { + throw new IllegalStateException("The build() method was not called on " + getClass()); + } + } + + @Override + public byte[] serializeData(E data) throws SerializeException { + checkIfBuildCalled(); + try { + return gson.toJson(data, Data.class).getBytes(); + } catch (JsonParseException e) { + throw new SerializeException(e); + } + } + + @Override + public byte[] serializeCollection(Collection data) throws SerializeException { + checkIfBuildCalled(); + Type type = new TypeToken>() { + }.getType(); + try { + return gson.toJson(data, type).getBytes(); + } catch (JsonParseException e) { + throw new SerializeException(e); + } + } + + @Override + public byte[] serializeBatch(T batch) throws SerializeException { + checkIfBuildCalled(); + try { + return gson.toJson(batch, Batch.class).getBytes(); + } catch (JsonParseException e) { + throw new SerializeException(e); + } + } + + @Override + public E deserializeData(byte[] data) throws DeserializeException { + checkIfBuildCalled(); + try { + return (E) gson.fromJson(new String(data), Data.class); + } catch (JsonParseException e) { + throw new DeserializeException(e); + } + } + + @Override + public Collection deserializeCollection(byte[] data) throws DeserializeException { + checkIfBuildCalled(); + Type type = new TypeToken>() { + }.getType(); + try { + return gson.fromJson(new String(data), type); + } catch (JsonParseException e) { + throw new DeserializeException(e); + } + } + + @Override + public T deserializeBatch(byte[] data) throws DeserializeException { + checkIfBuildCalled(); + try { + return (T) gson.fromJson(new String(data), Batch.class); + } catch (JsonParseException e) { + throw new DeserializeException(e); + } + } + + public static class JSONObjectSerializer implements JsonSerializer { + @Override + public JsonElement serialize(JSONObject src, Type typeOfSrc, JsonSerializationContext context) { + return serializeJSONObject(src, context); + } + } + + + public static class JSONObjectDeSerializer implements JsonDeserializer { + @Override + public JSONObject deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + return deserializeJSONObject(json, context); + } + } + + public static class JSONArraySerializer implements JsonSerializer { + @Override + public JsonElement serialize(JSONArray src, Type typeOfSrc, JsonSerializationContext context) { + return serializeJSONArray(src, context); + } + } + + public static class JSONArrayDeSerializer implements JsonDeserializer { + @Override + public JSONArray deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + return deserializeJSONArray(json, context); + } + } +} \ No newline at end of file diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/RuntimeTypeAdapterFactory.java b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/RuntimeTypeAdapterFactory.java new file mode 100644 index 0000000..dbb7fe0 --- /dev/null +++ b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/RuntimeTypeAdapterFactory.java @@ -0,0 +1,250 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batching_gson.utils; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.internal.Streams; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Adapts values whose runtime type may differ from their declaration type. This + * is necessary when a field's type is not the same type that GSON should create + * when deserializing that field. For example, consider these types: + *
   {@code
+ *   abstract class Shape {
+ *     int x;
+ *     int y;
+ *   }
+ *   class Circle extends Shape {
+ *     int radius;
+ *   }
+ *   class Rectangle extends Shape {
+ *     int width;
+ *     int height;
+ *   }
+ *   class Diamond extends Shape {
+ *     int width;
+ *     int height;
+ *   }
+ *   class Drawing {
+ *     Shape bottomShape;
+ *     Shape topShape;
+ *   }
+ * }
+ *

Without additional type information, the serialized JSON is ambiguous. Is + * the bottom shape in this drawing a rectangle or a diamond?

   {@code
+ *   {
+ *     "bottomShape": {
+ *       "width": 10,
+ *       "height": 5,
+ *       "x": 0,
+ *       "y": 0
+ *     },
+ *     "topShape": {
+ *       "radius": 2,
+ *       "x": 4,
+ *       "y": 1
+ *     }
+ *   }}
+ * This class addresses this problem by adding type information to the + * serialized JSON and honoring that type information when the JSON is + * deserialized:
   {@code
+ *   {
+ *     "bottomShape": {
+ *       "type": "Diamond",
+ *       "width": 10,
+ *       "height": 5,
+ *       "x": 0,
+ *       "y": 0
+ *     },
+ *     "topShape": {
+ *       "type": "Circle",
+ *       "radius": 2,
+ *       "x": 4,
+ *       "y": 1
+ *     }
+ *   }}
+ * Both the type field name ({@code "type"}) and the type labels ({@code + * "Rectangle"}) are configurable. + *

+ *

Registering Types

+ * Create a {@code RuntimeTypeAdapterFactory} by passing the base type and type field + * name to the {@link #of} factory method. If you don't supply an explicit type + * field name, {@code "type"} will be used.
   {@code
+ *   RuntimeTypeAdapterFactory shapeAdapter
+ *       = RuntimeTypeAdapterFactory.of(Shape.class, "type");
+ * }
+ * Next register all of your subtypes. Every subtype must be explicitly + * registered. This protects your application from injection attacks. If you + * don't supply an explicit type label, the type's simple name will be used. + *
   {@code
+ *   shapeAdapter.registerSubtype(Rectangle.class, "Rectangle");
+ *   shapeAdapter.registerSubtype(Circle.class, "Circle");
+ *   shapeAdapter.registerSubtype(Diamond.class, "Diamond");
+ * }
+ * Finally, register the type adapter in your application's GSON builder: + *
   {@code
+ *   Gson gson = new GsonBuilder()
+ *       .registerTypeAdapter(Shape.class, shapeAdapter)
+ *       .create();
+ * }
+ * Like {@code GsonBuilder}, this API supports chaining:
   {@code
+ *   RuntimeTypeAdapterFactory shapeAdapter = RuntimeTypeAdapterFactory.of(Shape.class)
+ *       .registerSubtype(Rectangle.class)
+ *       .registerSubtype(Circle.class)
+ *       .registerSubtype(Diamond.class);
+ * }
+ */ +public final class RuntimeTypeAdapterFactory implements TypeAdapterFactory { + private final Class baseType; + private final String typeFieldName; + private final Map> labelToSubtype = new LinkedHashMap>(); + private final Map, String> subtypeToLabel = new LinkedHashMap, String>(); + + private RuntimeTypeAdapterFactory(Class baseType, String typeFieldName) { + if (typeFieldName == null || baseType == null) { + throw new NullPointerException(); + } + this.baseType = baseType; + this.typeFieldName = typeFieldName; + } + + /** + * Creates a new runtime type adapter using for {@code baseType} using {@code + * typeFieldName} as the type field name. Type field names are case sensitive. + */ + public static RuntimeTypeAdapterFactory of(Class baseType, String typeFieldName) { + return new RuntimeTypeAdapterFactory(baseType, typeFieldName); + } + + /** + * Creates a new runtime type adapter for {@code baseType} using {@code "type"} as + * the type field name. + */ + public static RuntimeTypeAdapterFactory of(Class baseType) { + return new RuntimeTypeAdapterFactory(baseType, "type"); + } + + /** + * Registers {@code type} identified by {@code label}. Labels are case + * sensitive. + * + * @throws IllegalArgumentException if either {@code type} or {@code label} + * have already been registered on this type adapter. + */ + public RuntimeTypeAdapterFactory registerSubtype(Class type, String label) { + if (type == null || label == null) { + throw new NullPointerException(); + } + if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) { + throw new IllegalArgumentException("types and labels must be unique"); + } + labelToSubtype.put(label, type); + subtypeToLabel.put(type, label); + return this; + } + + /** + * Registers {@code type} identified by its {@link Class#getSimpleName simple + * name}. Labels are case sensitive. + * + * @throws IllegalArgumentException if either {@code type} or its simple name + * have already been registered on this type adapter. + */ + public RuntimeTypeAdapterFactory registerSubtype(Class type) { + return registerSubtype(type, type.getSimpleName()); + } + + public TypeAdapter create(Gson gson, TypeToken type) { + if (type.getRawType() != baseType) { + return null; + } + + final Map> labelToDelegate + = new LinkedHashMap>(); + final Map, TypeAdapter> subtypeToDelegate + = new LinkedHashMap, TypeAdapter>(); + for (Map.Entry> entry : labelToSubtype.entrySet()) { + TypeAdapter delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue())); + labelToDelegate.put(entry.getKey(), delegate); + subtypeToDelegate.put(entry.getValue(), delegate); + } + + return new TypeAdapter() { + @Override + public R read(JsonReader in) throws IOException { + JsonElement jsonElement = Streams.parse(in); + JsonElement labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName); + if (labelJsonElement == null) { + throw new JsonParseException("cannot deserialize " + baseType + + " because it does not define a field named " + typeFieldName); + } + String label = labelJsonElement.getAsString(); + @SuppressWarnings("unchecked") // registration requires that subtype extends T + TypeAdapter delegate = (TypeAdapter) labelToDelegate.get(label); + if (delegate == null) { + throw new JsonParseException("cannot deserialize " + baseType + " subtype named " + + label + "; did you forget to register a subtype?"); + } + return delegate.fromJsonTree(jsonElement); + } + + @Override + public void write(JsonWriter out, R value) throws IOException { + Class srcType = value.getClass(); + String label = subtypeToLabel.get(srcType); + @SuppressWarnings("unchecked") // registration requires that subtype extends T + TypeAdapter delegate = (TypeAdapter) subtypeToDelegate.get(srcType); + if (delegate == null) { + throw new JsonParseException("cannot serialize " + srcType.getName() + + "; did you forget to register a subtype?"); + } + JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject(); + if (jsonObject.has(typeFieldName)) { + throw new JsonParseException("cannot serialize " + srcType.getName() + + " because it already defines a field named " + typeFieldName); + } + JsonObject clone = new JsonObject(); + clone.add(typeFieldName, new JsonPrimitive(label)); + for (Map.Entry e : jsonObject.entrySet()) { + clone.add(e.getKey(), e.getValue()); + } + Streams.write(clone, out); + } + }.nullSafe(); + } +} \ No newline at end of file diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Deserializer.java b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Deserializer.java new file mode 100644 index 0000000..aa2d7e9 --- /dev/null +++ b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Deserializer.java @@ -0,0 +1,28 @@ +package com.flipkart.batching_gson.utils.utils; + +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.DataCollection; +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 java.lang.reflect.Type; +import java.util.Collection; + +public class Deserializer implements JsonDeserializer { + @Override + public DataCollection deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + if (null != json && json.isJsonObject()) { + JsonElement dataCollectionJson = json.getAsJsonObject().get("dataCollection"); + if (null != dataCollectionJson) { + Type type = new TypeToken>() { + }.getType(); + Collection dataCollection = context.deserialize(dataCollectionJson, type); + return new DataCollection(dataCollection); + } + } + return null; + } +} \ No newline at end of file diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Serializer.java b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Serializer.java new file mode 100644 index 0000000..426043f --- /dev/null +++ b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Serializer.java @@ -0,0 +1,27 @@ +package com.flipkart.batching_gson.utils.utils; + +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.DataCollection; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.Collection; + +public class Serializer implements JsonSerializer { + @Override + public JsonElement serialize(DataCollection src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject result = new JsonObject(); + JsonElement dataCollectionArray = null; + if (null != src.dataCollection) { + Type type = new TypeToken>() { + }.getType(); + dataCollectionArray = context.serialize(src.dataCollection, type); + } + result.add("dataCollection", dataCollectionArray); + return result; + } +} \ No newline at end of file diff --git a/batching-gson/src/main/res/values/strings.xml b/batching-gson/src/main/res/values/strings.xml new file mode 100644 index 0000000..3e0630c --- /dev/null +++ b/batching-gson/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Batching Gson + diff --git a/batching-gson/src/test/java/com/flipkart/batching_gson/ExampleUnitTest.java b/batching-gson/src/test/java/com/flipkart/batching_gson/ExampleUnitTest.java new file mode 100644 index 0000000..69abe53 --- /dev/null +++ b/batching-gson/src/test/java/com/flipkart/batching_gson/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.flipkart.batching_gson; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file From 21a35a219b271155dc3fd8f6597b7a672d0d3633 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:21:44 +0530 Subject: [PATCH 14/41] #109 moved these test from prev module --- .../com/flipkart/batchingcore}/data/BatchTest.java | 11 ++++++----- .../com/flipkart/batchingcore}/data/DataTest.java | 4 ++-- .../java/com/flipkart/batchingcore}/data/TagTest.java | 2 +- .../exception/DeserializeExceptionTest.java | 2 +- .../exception/SerializeExceptionTest.java | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) rename {batching/src/test/java/com/flipkart/batching => batching-core/src/test/java/com/flipkart/batchingcore}/data/BatchTest.java (90%) rename {batching/src/test/java/com/flipkart/batching => batching-core/src/test/java/com/flipkart/batchingcore}/data/DataTest.java (96%) rename {batching/src/test/java/com/flipkart/batching => batching-core/src/test/java/com/flipkart/batchingcore}/data/TagTest.java (98%) rename {batching/src/test/java/com/flipkart/batching => batching-core/src/test/java/com/flipkart/batchingcore}/exception/DeserializeExceptionTest.java (97%) rename {batching/src/test/java/com/flipkart/batching => batching-core/src/test/java/com/flipkart/batchingcore}/exception/SerializeExceptionTest.java (97%) diff --git a/batching/src/test/java/com/flipkart/batching/data/BatchTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/data/BatchTest.java similarity index 90% rename from batching/src/test/java/com/flipkart/batching/data/BatchTest.java rename to batching-core/src/test/java/com/flipkart/batchingcore/data/BatchTest.java index a68e27f..051a143 100644 --- a/batching/src/test/java/com/flipkart/batching/data/BatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batchingcore/data/BatchTest.java @@ -22,12 +22,13 @@ * THE SOFTWARE. */ -package com.flipkart.batching.data; +package com.flipkart.batchingcore.data; -import com.flipkart.Utils; -import com.flipkart.batching.Batch; -import com.flipkart.batching.BatchImpl; -import com.flipkart.batching.Data; + +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.Utils; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/data/DataTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/data/DataTest.java similarity index 96% rename from batching/src/test/java/com/flipkart/batching/data/DataTest.java rename to batching-core/src/test/java/com/flipkart/batchingcore/data/DataTest.java index 9e1c0d1..1e20549 100644 --- a/batching/src/test/java/com/flipkart/batching/data/DataTest.java +++ b/batching-core/src/test/java/com/flipkart/batchingcore/data/DataTest.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batching.data; +package com.flipkart.batchingcore.data; -import com.flipkart.batching.Data; +import com.flipkart.batchingcore.Data; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/data/TagTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/data/TagTest.java similarity index 98% rename from batching/src/test/java/com/flipkart/batching/data/TagTest.java rename to batching-core/src/test/java/com/flipkart/batchingcore/data/TagTest.java index adb61c3..8c022ba 100644 --- a/batching/src/test/java/com/flipkart/batching/data/TagTest.java +++ b/batching-core/src/test/java/com/flipkart/batchingcore/data/TagTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching.data; +package com.flipkart.batchingcore.data; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/exception/DeserializeExceptionTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/exception/DeserializeExceptionTest.java similarity index 97% rename from batching/src/test/java/com/flipkart/batching/exception/DeserializeExceptionTest.java rename to batching-core/src/test/java/com/flipkart/batchingcore/exception/DeserializeExceptionTest.java index 424d761..cd1d4ad 100644 --- a/batching/src/test/java/com/flipkart/batching/exception/DeserializeExceptionTest.java +++ b/batching-core/src/test/java/com/flipkart/batchingcore/exception/DeserializeExceptionTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching.exception; +package com.flipkart.batchingcore.exception; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/exception/SerializeExceptionTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/exception/SerializeExceptionTest.java similarity index 97% rename from batching/src/test/java/com/flipkart/batching/exception/SerializeExceptionTest.java rename to batching-core/src/test/java/com/flipkart/batchingcore/exception/SerializeExceptionTest.java index a5c903b..0409d95 100644 --- a/batching/src/test/java/com/flipkart/batching/exception/SerializeExceptionTest.java +++ b/batching-core/src/test/java/com/flipkart/batchingcore/exception/SerializeExceptionTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching.exception; +package com.flipkart.batchingcore.exception; import junit.framework.Assert; From 22c2cc0d3c0b486ae2310f60c83b5df2d0152413 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:22:01 +0530 Subject: [PATCH 15/41] #109 deleted example test --- .../flipkart/batchingcore/ExampleUnitTest.java | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 batching-core/src/test/java/com/flipkart/batchingcore/ExampleUnitTest.java diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/ExampleUnitTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/ExampleUnitTest.java deleted file mode 100644 index 14cbd7f..0000000 --- a/batching-core/src/test/java/com/flipkart/batchingcore/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.flipkart.batchingcore; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file From 95ad5bfd83d454c529b168b1d3201fc1ca6b5d79 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:22:26 +0530 Subject: [PATCH 16/41] #109 utility method for testing --- .../java/com/flipkart/batchingcore/Utils.java | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 batching-core/src/test/java/com/flipkart/batchingcore/Utils.java diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/Utils.java b/batching-core/src/test/java/com/flipkart/batchingcore/Utils.java new file mode 100644 index 0000000..f932d4f --- /dev/null +++ b/batching-core/src/test/java/com/flipkart/batchingcore/Utils.java @@ -0,0 +1,106 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batchingcore; + +import com.flipkart.batchingcore.data.EventData; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; + +import java.util.ArrayList; + +/** + * Utils class for Test + */ +public class Utils { + + /** + * Method to create fake array list of Data. + * + * @param size + * @return dataList + */ + static Data eventData; + + public static ArrayList fakeCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + eventData = new EventData(); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeAdsCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + eventData = new EventData(); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeDebugCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + eventData = new EventData(); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeBuisnessCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + eventData = new EventData(); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeTagAdsCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + TagData eventData = new TagData(new Tag("ADS")); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeTagDebugCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + TagData eventData = new TagData(new Tag("DEBUG")); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + +} From 43da6906f542d5e6bfa27e9b7cea57d805b2b572 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:22:42 +0530 Subject: [PATCH 17/41] #109 test for SizeBatch --- .../batchingcore/batch/SizeBatchTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeBatchTest.java diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeBatchTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeBatchTest.java new file mode 100644 index 0000000..fd35b19 --- /dev/null +++ b/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeBatchTest.java @@ -0,0 +1,41 @@ +package com.flipkart.batchingcore.batch; + +import junit.framework.Assert; + +import org.junit.Test; + +import java.util.Collections; + +/** + * Created by anirudh.r on 11/08/16. + * Test for {@link SizeBatch} + */ +public class SizeBatchTest { + + /** + * Test to verify the max batch size getters + * + * @throws Exception + */ + @Test + public void testMaxSize() throws Exception { + SizeBatch sizeBatch = new SizeBatch(Collections.EMPTY_LIST, 10); + int maxBatchSize = sizeBatch.getMaxBatchSize(); + Assert.assertTrue(maxBatchSize == 10); + } + + @Test + public void testSizeBatchEqualsMethod() throws Exception { + SizeBatch sizeBatch = new SizeBatch(Collections.EMPTY_LIST, 10); + SizeBatch sizeBatch1 = new SizeBatch(Collections.EMPTY_LIST, 10); + + //assert that both are equal since the sizes are same + Assert.assertTrue(sizeBatch.equals(sizeBatch1)); + + sizeBatch = new SizeBatch(Collections.EMPTY_LIST, 10); + sizeBatch1 = new SizeBatch(Collections.EMPTY_LIST, 11); + + //assert that both are not equal since the sizes are not same + Assert.assertTrue(!sizeBatch.equals(sizeBatch1)); + } +} From 1fcf19a9071623c18513f3159cba91e9fbc946d0 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:22:54 +0530 Subject: [PATCH 18/41] #109 test for SizeTimeBatch --- .../batchingcore/batch/SizeTimeBatchTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeTimeBatchTest.java diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeTimeBatchTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeTimeBatchTest.java new file mode 100644 index 0000000..94e3113 --- /dev/null +++ b/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeTimeBatchTest.java @@ -0,0 +1,62 @@ +package com.flipkart.batchingcore.batch; + +import junit.framework.Assert; + +import org.junit.Test; + +import java.util.Collections; + +/** + * Created by anirudh.r on 11/08/16. + * Test for {@link SizeTimeBatch} + */ +public class SizeTimeBatchTest { + + /** + * Test for max size batch + * + * @throws Exception + */ + @Test + public void testMaxSize() throws Exception { + SizeTimeBatch sizeTimeBatch = new SizeTimeBatch(Collections.EMPTY_LIST, 10, 1000); + int maxBatchSize = sizeTimeBatch.getMaxBatchSize(); + + //assert that the max batch size is 10 + Assert.assertTrue(maxBatchSize == 10); + } + + /** + * Test for timeout + * + * @throws Exception + */ + @Test + public void testTimeout() throws Exception { + SizeTimeBatch sizeTimeBatch = new SizeTimeBatch(Collections.EMPTY_LIST, 10, 1000); + long timeOut = sizeTimeBatch.getTimeOut(); + + //assert that the timeout is 1000 + Assert.assertTrue(timeOut == 1000); + } + + /** + * Test for equals method + * + * @throws Exception + */ + @Test + public void testSizeTimeBatchEqualsMethod() throws Exception { + SizeTimeBatch sizeTimeBatch = new SizeTimeBatch(Collections.EMPTY_LIST, 10, 100); + SizeTimeBatch sizeTimeBatch1 = new SizeTimeBatch(Collections.EMPTY_LIST, 10, 100); + + //assert that both are equal since the sizes and timeout are same + Assert.assertTrue(sizeTimeBatch.equals(sizeTimeBatch1)); + + sizeTimeBatch = new SizeTimeBatch(Collections.EMPTY_LIST, 10, 100); + sizeTimeBatch1 = new SizeTimeBatch(Collections.EMPTY_LIST, 10, 200); + + //assert that both are not equal since the time out are not same + Assert.assertTrue(!sizeTimeBatch.equals(sizeTimeBatch1)); + } +} From c366f89f83f65e4a527d765871a38ce37a0f328b Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:23:06 +0530 Subject: [PATCH 19/41] #109 test for TagBatch --- .../batchingcore/batch/TagBatchTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 batching-core/src/test/java/com/flipkart/batchingcore/batch/TagBatchTest.java diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/batch/TagBatchTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/batch/TagBatchTest.java new file mode 100644 index 0000000..00ad690 --- /dev/null +++ b/batching-core/src/test/java/com/flipkart/batchingcore/batch/TagBatchTest.java @@ -0,0 +1,51 @@ +package com.flipkart.batchingcore.batch; + +import com.flipkart.batchingcore.data.Tag; + +import junit.framework.Assert; + +import org.junit.Test; + +import java.util.Collections; + +/** + * Created by anirudh.r on 11/08/16. + * Test for {@link TagBatch} + */ +public class TagBatchTest { + + /** + * Test for get tag + * + * @throws Exception + */ + @Test + public void testGetTag() throws Exception { + TagBatch tagBatch = new TagBatch(new Tag("test"), new SizeBatch(Collections.EMPTY_LIST, 10)); + Tag tag = tagBatch.getTag(); + String id = tag.getId(); + + //assert that the id are same + Assert.assertTrue(id.equals("test")); + } + + /** + * Test for equals method + * + * @throws Exception + */ + @Test + public void testEqualsMethod() throws Exception { + TagBatch tagBatch = new TagBatch(new Tag("test"), new SizeBatch(Collections.EMPTY_LIST, 10)); + TagBatch tagBatch1 = new TagBatch(new Tag("test"), new SizeBatch(Collections.EMPTY_LIST, 10)); + + //assert that both tag batch are same + Assert.assertTrue(tagBatch.equals(tagBatch1)); + + tagBatch = new TagBatch(new Tag("test"), new SizeBatch(Collections.EMPTY_LIST, 10)); + tagBatch1 = new TagBatch(new Tag("test1"), new SizeBatch(Collections.EMPTY_LIST, 10)); + + //assert that both tag batch are not same since they have diff tag + Assert.assertTrue(!tagBatch.equals(tagBatch1)); + } +} From b63071c12b679af6cef0869ed4bd481ab97fdd9c Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:23:32 +0530 Subject: [PATCH 20/41] #109 test for TimeBatch --- .../batchingcore/batch/TimeBatchTest.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 batching-core/src/test/java/com/flipkart/batchingcore/batch/TimeBatchTest.java diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/batch/TimeBatchTest.java b/batching-core/src/test/java/com/flipkart/batchingcore/batch/TimeBatchTest.java new file mode 100644 index 0000000..1d32835 --- /dev/null +++ b/batching-core/src/test/java/com/flipkart/batchingcore/batch/TimeBatchTest.java @@ -0,0 +1,48 @@ +package com.flipkart.batchingcore.batch; + +import junit.framework.Assert; + +import org.junit.Test; + +import java.util.Collections; + +/** + * Created by anirudh.r on 11/08/16. + * Test for {@link TimeBatch} + */ +public class TimeBatchTest { + + /** + * Test for time out getters + * + * @throws Exception + */ + @Test + public void testTimeOut() throws Exception { + TimeBatch timeBatch = new TimeBatch(Collections.EMPTY_LIST, 1000); + long timeOut = timeBatch.getTimeOut(); + + //assert that time out is equal to 1000 + Assert.assertTrue(timeOut == 1000); + } + + /** + * Test for equals method in TimeBatch + * + * @throws Exception + */ + @Test + public void testEqualsMethod() throws Exception { + TimeBatch timeBatch = new TimeBatch(Collections.EMPTY_LIST, 1000); + TimeBatch timeBatch1 = new TimeBatch(Collections.EMPTY_LIST, 1000); + + //assert that both the batches are same + Assert.assertTrue(timeBatch.equals(timeBatch1)); + + timeBatch = new TimeBatch(Collections.EMPTY_LIST, 2000); + timeBatch1 = new TimeBatch(Collections.EMPTY_LIST, 1000); + + //assert that both the batches are not same + Assert.assertTrue(!timeBatch.equals(timeBatch1)); + } +} From 10f30b67759b34668b774964cb57c4c13f81e300 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:35:44 +0530 Subject: [PATCH 21/41] #109 deleted example test in gson --- .../flipkart/batching_gson/ExampleUnitTest.java | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 batching-gson/src/test/java/com/flipkart/batching_gson/ExampleUnitTest.java diff --git a/batching-gson/src/test/java/com/flipkart/batching_gson/ExampleUnitTest.java b/batching-gson/src/test/java/com/flipkart/batching_gson/ExampleUnitTest.java deleted file mode 100644 index 69abe53..0000000 --- a/batching-gson/src/test/java/com/flipkart/batching_gson/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.flipkart.batching_gson; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file From e8518d8bec8cf8da716f74fa9022e493979423c4 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:36:00 +0530 Subject: [PATCH 22/41] #109 added utils method --- .../com/flipkart/batching_gson/Utils.java | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java diff --git a/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java b/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java new file mode 100644 index 0000000..a350802 --- /dev/null +++ b/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java @@ -0,0 +1,107 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Flipkart Internet Pvt. Ltd. + * + * 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. + */ + +package com.flipkart.batching_gson; + +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.data.EventData; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; + +import java.util.ArrayList; + +/** + * Utils class for Test + */ +public class Utils { + + /** + * Method to create fake array list of Data. + * + * @param size + * @return dataList + */ + static Data eventData; + + public static ArrayList fakeCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + eventData = new EventData(); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeAdsCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + eventData = new EventData(); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeDebugCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + eventData = new EventData(); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeBuisnessCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + eventData = new EventData(); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeTagAdsCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + TagData eventData = new TagData(new Tag("ADS")); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + + public static ArrayList fakeTagDebugCollection(int size) { + ArrayList dataList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + TagData eventData = new TagData(new Tag("DEBUG")); + eventData.setEventId(System.currentTimeMillis() + System.nanoTime() + i); + dataList.add(eventData); + } + return dataList; + } + +} From 4e179a0900c3dd9b8909268003e94abb5a9cc7ef Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 11:36:17 +0530 Subject: [PATCH 23/41] #109 moved GsonSerializationTest --- .../batching_gson}/GsonSerializationTest.java | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) rename {batching/src/test/java/com/flipkart/batching/persistence => batching-gson/src/test/java/com/flipkart/batching_gson}/GsonSerializationTest.java (81%) diff --git a/batching/src/test/java/com/flipkart/batching/persistence/GsonSerializationTest.java b/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java similarity index 81% rename from batching/src/test/java/com/flipkart/batching/persistence/GsonSerializationTest.java rename to batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java index a0e3f3b..8b75afa 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/GsonSerializationTest.java +++ b/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java @@ -22,16 +22,21 @@ * THE SOFTWARE. */ -package com.flipkart.batching.persistence; - -import com.flipkart.Utils; -import com.flipkart.batching.Batch; -import com.flipkart.batching.BatchImpl; -import com.flipkart.batching.BatchManager; -import com.flipkart.batching.Data; -import com.flipkart.batching.data.EventData; -import com.flipkart.batching.exception.DeserializeException; -import com.flipkart.batching.exception.SerializeException; +package com.flipkart.batching_gson; + +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batchingcore.batch.SizeTimeBatch; +import com.flipkart.batchingcore.batch.TagBatch; +import com.flipkart.batchingcore.batch.TimeBatch; +import com.flipkart.batchingcore.data.EventData; +import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batchingcore.exception.DeserializeException; +import com.flipkart.batchingcore.exception.SerializeException; import com.google.gson.JsonSyntaxException; import junit.framework.Assert; @@ -48,7 +53,6 @@ */ public class GsonSerializationTest { - /** * Test the working of {@link GsonSerializationStrategy#serializeBatch(Batch)} * and {@link GsonSerializationStrategy#deserializeBatch(byte[])} @@ -57,7 +61,7 @@ public class GsonSerializationTest { public void testGSONSerialization() { GsonSerializationStrategy> serializationStrategy; serializationStrategy = new GsonSerializationStrategy<>(); - BatchManager.registerBuiltInTypes(serializationStrategy); + registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); ArrayList dataCollection = Utils.fakeCollection(4); @@ -85,7 +89,7 @@ public void testIfExceptionThrownWhenCorrupt() throws SerializeException, Deseri GsonSerializationStrategy> serializationStrategy; ArrayList dataCollection = Utils.fakeCollection(4); serializationStrategy = new GsonSerializationStrategy<>(); - BatchManager.registerBuiltInTypes(serializationStrategy); + registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); Batch batch = new BatchImpl<>(dataCollection); @@ -109,7 +113,7 @@ public void testCollectionSerialization() { GsonSerializationStrategy> serializationStrategy; ArrayList dataCollection = Utils.fakeCollection(4); serializationStrategy = new GsonSerializationStrategy<>(); - BatchManager.registerBuiltInTypes(serializationStrategy); + registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); Collection fakeCollection = Utils.fakeCollection(4); @@ -133,7 +137,7 @@ public void testIfBuildNotCalled() { GsonSerializationStrategy> serializationStrategy; ArrayList dataCollection = Utils.fakeCollection(4); serializationStrategy = new GsonSerializationStrategy<>(); - BatchManager.registerBuiltInTypes(serializationStrategy); + registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); Batch batch = new BatchImpl<>(dataCollection); @@ -157,7 +161,7 @@ public void testGSONSerializationForData() throws SerializeException, Deserializ //test to serialize hashmap GsonSerializationStrategy> serializationStrategy = new GsonSerializationStrategy<>(); serializationStrategy.registerDataType(Data.class); - BatchManager.registerBuiltInTypes(serializationStrategy); + registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); HashMap hashMap = new HashMap<>(); @@ -176,4 +180,14 @@ public void testGSONSerializationForData() throws SerializeException, Deserializ data = serializationStrategy.deserializeData(serializedData); Assert.assertEquals(eventData, data); } + + private void registerBuiltInTypes(SerializationStrategy serializationStrategy) { + serializationStrategy.registerDataType(TagData.class); + serializationStrategy.registerBatch(BatchImpl.class); + serializationStrategy.registerDataType(EventData.class); + serializationStrategy.registerBatch(SizeBatch.class); + serializationStrategy.registerBatch(TimeBatch.class); + serializationStrategy.registerBatch(TagBatch.class); + serializationStrategy.registerBatch(SizeTimeBatch.class); + } } From c288f84f2c607a260d61c2b52a504718bd1f9482 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 14:59:20 +0530 Subject: [PATCH 24/41] #109 refactor --- batching-gson/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batching-gson/build.gradle b/batching-gson/build.gradle index 2eb225f..52e4965 100644 --- a/batching-gson/build.gradle +++ b/batching-gson/build.gradle @@ -22,7 +22,7 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.google.code.gson:gson:2.4' compile 'com.android.support:appcompat-v7:24.1.1' compile project(':batching-core') From bc23fd6af70769a0602708ab551e363dcea3ebc0 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 14:59:42 +0530 Subject: [PATCH 25/41] #109 added batching-gson dependency --- batching/build.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/batching/build.gradle b/batching/build.gradle index 729b015..72a33f9 100644 --- a/batching/build.gradle +++ b/batching/build.gradle @@ -61,7 +61,10 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' - testCompile 'org.robolectric:robolectric:3.1' + testCompile 'org.robolectric:robolectric:3.1.1' + testCompile project(':batching-gson') + //temp fix, will need to look into this dependency since batching-gson already has this dependency + testCompile 'com.google.code.gson:gson:2.4' compile project(':batching-core') compile 'org.jetbrains:annotations-java5:15.0' From 0cb6b4333f2a0f12aad58183ebffbe885c389f3d Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:00:04 +0530 Subject: [PATCH 26/41] #109 utils method for testing --- batching/src/test/java/com/flipkart/Utils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/batching/src/test/java/com/flipkart/Utils.java b/batching/src/test/java/com/flipkart/Utils.java index 70c5893..25f66ca 100644 --- a/batching/src/test/java/com/flipkart/Utils.java +++ b/batching/src/test/java/com/flipkart/Utils.java @@ -24,10 +24,10 @@ package com.flipkart; -import com.flipkart.batching.Data; -import com.flipkart.batching.data.EventData; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.data.EventData; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import java.util.ArrayList; From f7e479c1ce295560664e117099f769f24cd46200 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:01:59 +0530 Subject: [PATCH 27/41] #109 refactored listener test --- .../NetworkPersistedBatchReadyTest.java | 59 ++++++++++--------- .../listener/PersistedBatchReadyTest.java | 51 ++++++++-------- .../batching/listener/TagBatchReadyTest.java | 16 ++--- .../listener/TrimPersistedBatchReadyTest.java | 26 ++++---- 4 files changed, 80 insertions(+), 72 deletions(-) diff --git a/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java index 338a83c..3c93793 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java @@ -34,11 +34,14 @@ import com.flipkart.Utils; import com.flipkart.batching.BaseTestClass; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; -import com.flipkart.batching.exception.SerializeException; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batchingcore.exception.SerializeException; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.tape.ObjectQueue; @@ -96,14 +99,14 @@ public void test5XXRetryPolicy() throws IOException { Handler handler = new Handler(looper); ShadowLooper shadowLooper = Shadows.shadowOf(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(new NetworkPersistedBatchReadyListener.NetworkRequestResponse(true, ERROR_CODE_5XX), handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, maxRetryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, maxRetryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); networkPersistedBatchReadyListener.onReady(strategy, firstBatch); shadowLooper.runToEndOfTasks(); @@ -166,14 +169,14 @@ public void test4XXRetryPolicy() throws IOException { Handler handler = new Handler(looper); ShadowLooper shadowLooper = Shadows.shadowOf(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(new NetworkPersistedBatchReadyListener.NetworkRequestResponse(true, ERROR_CODE_4XX), handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, maxRetryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, maxRetryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); networkPersistedBatchReadyListener.onReady(strategy, firstBatch); shadowLooper.runToEndOfTasks(); //verify that it gets called once @@ -202,14 +205,14 @@ public void test2XXRetryPolicy() throws IOException { Handler handler = new Handler(looper); ShadowLooper shadowLooper = Shadows.shadowOf(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(new NetworkPersistedBatchReadyListener.NetworkRequestResponse(true, ERROR_CODE_2XX), handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, 5, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, 5, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); networkPersistedBatchReadyListener.onReady(strategy, firstBatch); shadowLooper.runToEndOfTasks(); //verify that it gets called once @@ -235,14 +238,14 @@ public void testNetworkBroadcast() throws IOException { Handler handler = new Handler(looper); ShadowLooper shadowLooper = Shadows.shadowOf(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 3); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 3); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(new NetworkPersistedBatchReadyListener.NetworkRequestResponse(true, ERROR_CODE_2XX), handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, 5, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, 5, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); networkPersistedBatchReadyListener.onReady(strategy, firstBatch); shadowLooper.runToEndOfTasks(); @@ -256,7 +259,7 @@ public void testNetworkBroadcast() throws IOException { //PURPOSE : if network broadcast is received, perform any pending requests which were paused due to no network networkBatchListener.setMockedNetworkConnected(false); //simulating network not connected - SizeBatchingStrategy.SizeBatch secondBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 4); + SizeBatch secondBatch = new SizeBatch<>(Utils.fakeCollection(5), 4); networkPersistedBatchReadyListener.onReady(strategy, secondBatch); shadowLooper.idle(100); // no new request is sent since no network exists @@ -294,22 +297,22 @@ public void testReinitialize() { NetworkPersistedBatchReadyListener.NetworkRequestResponse networkRequestResponse = new NetworkPersistedBatchReadyListener.NetworkRequestResponse(false, 500); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(networkRequestResponse, handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, 1, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 3); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, 1, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 3); networkPersistedBatchReadyListener.onReady(strategy, firstBatch); shadowLooper.runToEndOfTasks(); - SizeBatchingStrategy.SizeBatch secondBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 3); + SizeBatch secondBatch = new SizeBatch<>(Utils.fakeCollection(5), 3); networkPersistedBatchReadyListener.onReady(strategy, secondBatch); shadowLooper.runToEndOfTasks(); ObjectQueue> oldQueueFile = networkPersistedBatchReadyListener.getQueueFile(); //reinitialize - networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, 5, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, 5, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); networkPersistedBatchReadyListener.setQueueFile(oldQueueFile); //since 2 queuefiles cannot point to same disk file, we had to do this networkRequestResponse.complete = true; networkRequestResponse.httpErrorCode = 200; - SizeBatchingStrategy.SizeBatch thirdBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 3); + SizeBatch thirdBatch = new SizeBatch<>(Utils.fakeCollection(5), 3); networkPersistedBatchReadyListener.onReady(strategy, thirdBatch); shadowLooper.runToEndOfTasks(); //all retries finished @@ -330,7 +333,7 @@ public void testRetryPolicy() { ShadowLooper shadowLooper = Shadows.shadowOf(Looper.getMainLooper()); Handler handler = new Handler(); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); @@ -338,7 +341,7 @@ public void testRetryPolicy() { TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(requestResponse, handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, retryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, retryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); networkPersistedBatchReadyListener.onReady(strategy, firstBatch); shadowLooper.runToEndOfTasks(); @@ -360,7 +363,7 @@ public void testRetryPolicy() { verify(networkBatchListener, times(4)).performNetworkRequest(eq(firstBatch), any(ValueCallback.class)); sendFakeNetworkBroadcast(context); - SizeBatchingStrategy.SizeBatch secondBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch secondBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); networkPersistedBatchReadyListener.onReady(strategy, secondBatch); shadowLooper.idle(); @@ -393,7 +396,7 @@ public void testFinishCalledIfRemoveAfterMaxRetryTrue() { ShadowLooper shadowLooper = Shadows.shadowOf(Looper.getMainLooper()); Handler handler = new Handler(); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); @@ -401,7 +404,7 @@ public void testFinishCalledIfRemoveAfterMaxRetryTrue() { TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(requestResponse, handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, retryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, retryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); networkPersistedBatchReadyListener.onReady(strategy, firstBatch); networkPersistedBatchReadyListener.setCallFinishAfterMaxRetry(true); shadowLooper.runToEndOfTasks(); @@ -445,7 +448,7 @@ public void testRetryTimeOut() { ShadowLooper shadowLooper = Shadows.shadowOf(Looper.getMainLooper()); Handler handler = new Handler(); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); @@ -453,7 +456,7 @@ public void testRetryTimeOut() { TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(requestResponse, handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, retryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, retryCount, 50, 10, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, trimmedBatchCallback); networkPersistedBatchReadyListener.setDefaultTimeoutMs(timeOut); networkPersistedBatchReadyListener.setDefaultBackoffMultiplier(backOffMultiplier); @@ -524,18 +527,18 @@ public void testDoNotTrimmingIfWaitingForFinish() throws Exception { TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); SizeBatchingStrategy sizeBatchingStrategy = mock(SizeBatchingStrategy.class); final ArrayList dataList1 = Utils.fakeAdsCollection(10); - SizeBatchingStrategy.SizeBatch sizeBatch1 = new SizeBatchingStrategy.SizeBatch<>(dataList1, 3); + SizeBatch sizeBatch1 = new SizeBatch<>(dataList1, 3); MockNetworkPersistedBatchReadyListener networkBatchListener = spy(new MockNetworkPersistedBatchReadyListener(new NetworkPersistedBatchReadyListener.NetworkRequestResponse(true, ERROR_CODE_2XX), handler, callbackIdle, context)); - NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomString(), serializationStrategy, handler, networkBatchListener, 1, 2, 1, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START | TrimPersistedBatchReadyListener.MODE_TRIM_ON_READY, trimmedBatchCallback); + NetworkPersistedBatchReadyListener networkPersistedBatchReadyListener = new NetworkPersistedBatchReadyListener(context, createRandomFile().getPath(), serializationStrategy, handler, networkBatchListener, 1, 2, 1, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START | TrimPersistedBatchReadyListener.MODE_TRIM_ON_READY, trimmedBatchCallback); networkPersistedBatchReadyListener.onReady(sizeBatchingStrategy, sizeBatch1); shadowLooper.idle(100); //this will start waiting for finish callback final ArrayList dataList2 = Utils.fakeAdsCollection(10); - SizeBatchingStrategy.SizeBatch sizeBatch2 = new SizeBatchingStrategy.SizeBatch<>(dataList2, 3); + SizeBatch sizeBatch2 = new SizeBatch<>(dataList2, 3); networkPersistedBatchReadyListener.onReady(sizeBatchingStrategy,sizeBatch2); shadowLooper.idle(100); // this will initiate a trim since size is 2 final ArrayList dataList3 = Utils.fakeAdsCollection(10); - SizeBatchingStrategy.SizeBatch sizeBatch3 = new SizeBatchingStrategy.SizeBatch<>(dataList2, 3); + SizeBatch sizeBatch3 = new SizeBatch<>(dataList2, 3); networkPersistedBatchReadyListener.onReady(sizeBatchingStrategy,sizeBatch2); shadowLooper.idle(100); // this will fire onReady once more diff --git a/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java index ab3b411..a1a6599 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java @@ -30,13 +30,16 @@ import com.flipkart.Utils; import com.flipkart.batching.BaseTestClass; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; -import com.flipkart.batching.exception.SerializeException; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.tape.QueueFile; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batchingcore.exception.SerializeException; import junit.framework.Assert; @@ -78,13 +81,13 @@ public void testIfInitializedCalled() { Handler handler = new Handler(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatchInfo = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch sizeBatchInfo = new SizeBatch<>(Utils.fakeCollection(5), 5); PersistedBatchCallback persistedBatchCallback = mock(PersistedBatchCallback.class); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); - PersistedBatchReadyListener> persistedBatchReadyListener = new PersistedBatchReadyListener<>(createRandomString(), serializationStrategy, handler, persistedBatchCallback); + PersistedBatchReadyListener> persistedBatchReadyListener = new PersistedBatchReadyListener<>(createRandomFile().getPath(), serializationStrategy, handler, persistedBatchCallback); persistedBatchReadyListener.onReady(strategy, sizeBatchInfo); shadowLooper.runToEndOfTasks(); //should be initialized first time @@ -104,13 +107,13 @@ public void testIfPersistSuccessCalled() { ShadowLooper shadowLooper = Shadows.shadowOf(looper); Handler handler = new Handler(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatchInfo = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch sizeBatchInfo = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); PersistedBatchCallback persistedBatchCallback = mock(PersistedBatchCallback.class); - PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomString(), serializationStrategy, handler, persistedBatchCallback); + PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomFile().getPath(), serializationStrategy, handler, persistedBatchCallback); persistedBatchReadyListener.onReady(strategy, sizeBatchInfo); shadowLooper.runToEndOfTasks(); @@ -134,13 +137,13 @@ public void testFinishCalled() throws IOException { ShadowLooper shadowLooper = Shadows.shadowOf(looper); Handler handler = new Handler(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatchInfo = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch sizeBatchInfo = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); PersistedBatchCallback persistedBatchCallback = mock(PersistedBatchCallback.class); - PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomString(), serializationStrategy, handler, persistedBatchCallback); + PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomFile().getPath(), serializationStrategy, handler, persistedBatchCallback); ArrayList arrayList = Utils.fakeCollection(4); when(queueFile.peek()).thenReturn(serializationStrategy.serializeCollection(arrayList)); @@ -178,15 +181,15 @@ public void testPersistSuccessNotCalledMoreThanOnce() throws IOException { BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); PersistedBatchCallback persistedBatchCallback = mock(PersistedBatchCallback.class); - PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomString(), serializationStrategy, handler, persistedBatchCallback); + PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomFile().getPath(), serializationStrategy, handler, persistedBatchCallback); - SizeBatchingStrategy.SizeBatch firstBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch firstBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); persistedBatchReadyListener.onReady(strategy, firstBatch); - SizeBatchingStrategy.SizeBatch secondBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch secondBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); persistedBatchReadyListener.onReady(strategy, secondBatch); - SizeBatchingStrategy.SizeBatch thirdBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch thirdBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); persistedBatchReadyListener.onReady(strategy, thirdBatch); - SizeBatchingStrategy.SizeBatch fourthBatch = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch fourthBatch = new SizeBatch<>(Utils.fakeCollection(5), 5); persistedBatchReadyListener.onReady(strategy, fourthBatch); shadowLooper.runToEndOfTasks(); @@ -208,7 +211,7 @@ public void testPersistSuccessNotCalledMoreThanOnce() throws IOException { /** * Test to verify that finish throws an {@link IllegalStateException} when it gets called with a different batch. * Ignoring this test because we are catching this exception and logging it now. - * + *

* UPDATE : not throwing this exception anymore, thus ignore. * * @throws SerializeException @@ -225,20 +228,20 @@ public void testFinishException() throws IOException { ShadowLooper shadowLooper = Shadows.shadowOf(looper); Handler handler = new Handler(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatchInfo = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch sizeBatchInfo = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); PersistedBatchCallback persistedBatchCallback = mock(PersistedBatchCallback.class); - PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomString(), serializationStrategy, handler, persistedBatchCallback); + PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomFile().getPath(), serializationStrategy, handler, persistedBatchCallback); byte[] peeked = serializationStrategy.serializeBatch(sizeBatchInfo); when(queueFile.peek()).thenReturn(peeked); persistedBatchReadyListener.onReady(strategy, sizeBatchInfo); shadowLooper.runToEndOfTasks(); - SizeBatchingStrategy.SizeBatch sizeBatchInfo1 = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeAdsCollection(4), 5); + SizeBatch sizeBatchInfo1 = new SizeBatch<>(Utils.fakeAdsCollection(4), 5); try { persistedBatchReadyListener.finish(sizeBatchInfo1); } catch (Exception e) { @@ -263,12 +266,12 @@ public void testIfPersistFailureCalled() throws IOException { ShadowLooper shadowLooper = Shadows.shadowOf(looper); Handler handler = new Handler(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatchInfo = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch sizeBatchInfo = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); PersistedBatchCallback persistedBatchCallback = mock(PersistedBatchCallback.class); - PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomString(), serializationStrategy, handler, persistedBatchCallback); + PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomFile().getPath(), serializationStrategy, handler, persistedBatchCallback); byte[] data = serializationStrategy.serializeCollection(Utils.fakeAdsCollection(4)); doThrow(new IOException()).when(queueFile).add(data); @@ -288,21 +291,19 @@ public void testListenerNotNull() { ShadowLooper shadowLooper = Shadows.shadowOf(looper); Handler handler = new Handler(looper); SizeBatchingStrategy strategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatchInfo = new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5), 5); + SizeBatch sizeBatchInfo = new SizeBatch<>(Utils.fakeCollection(5), 5); SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); PersistedBatchCallback persistedBatchCallback = mock(PersistedBatchCallback.class); - PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomString(), serializationStrategy, handler, persistedBatchCallback); + PersistedBatchReadyListener persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomFile().getPath(), serializationStrategy, handler, persistedBatchCallback); persistedBatchReadyListener.onReady(strategy, sizeBatchInfo); Assert.assertTrue(persistedBatchReadyListener.getListener() != null); - persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomString(), serializationStrategy, handler, null); + persistedBatchReadyListener = new PersistedBatchReadyListener(createRandomFile().getPath(), serializationStrategy, handler, null); persistedBatchReadyListener.setListener(persistedBatchCallback); Assert.assertTrue(persistedBatchReadyListener.getListener() != null); - - } diff --git a/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java index b0af10a..7b8c9e6 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java @@ -28,8 +28,10 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; +import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batchingcore.batch.TagBatch; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.strategy.TagBatchingStrategy; @@ -63,7 +65,7 @@ public void testAddTagListener() { Tag BUSINESS = new Tag("BUSINESS"); Tag DEBUG = new Tag("DEBUG"); - OnBatchReadyListener> onBatchReadyListener = mock(OnBatchReadyListener.class); + OnBatchReadyListener> onBatchReadyListener = mock(OnBatchReadyListener.class); tagBatchReadyListener = new TagBatchReadyListener<>(); tagBatchReadyListener.addListenerForTag(AD, onBatchReadyListener); tagBatchReadyListener.addListenerForTag(DEBUG, onBatchReadyListener); @@ -75,7 +77,7 @@ public void testAddTagListener() { /** - * Test to verify {@link TagBatchReadyListener#onReady(BatchingStrategy, TagBatchingStrategy.TagBatch)} + * Test to verify {@link TagBatchReadyListener#onReady(BatchingStrategy, TagBatch)} */ @Test public void testOnReady() { @@ -84,14 +86,14 @@ public void testOnReady() { Tag BUSINESS = new Tag("BUSINESS"); Tag DEBUG = new Tag("DEBUG"); - OnBatchReadyListener> onBatchReadyListener = mock(OnBatchReadyListener.class); + OnBatchReadyListener> onBatchReadyListener = mock(OnBatchReadyListener.class); tagBatchReadyListener = new TagBatchReadyListener<>(); tagBatchReadyListener.addListenerForTag(AD, onBatchReadyListener); tagBatchReadyListener.addListenerForTag(DEBUG, onBatchReadyListener); tagBatchReadyListener.addListenerForTag(BUSINESS, onBatchReadyListener); - tagBatchReadyListener.onReady(new TagBatchingStrategy<>(), new TagBatchingStrategy.TagBatch<>(new Tag("ADS"), new SizeBatchingStrategy.SizeBatch(Utils.fakeCollection(2), 4))); + tagBatchReadyListener.onReady(new TagBatchingStrategy<>(), new TagBatch<>(new Tag("ADS"), new SizeBatch(Utils.fakeCollection(2), 4))); //verify that it gets called once , when tagBatchReadyListener's onReady gets called - verify(onBatchReadyListener, times(1)).onReady(any(BatchingStrategy.class), any(TagBatchingStrategy.TagBatch.class)); + verify(onBatchReadyListener, times(1)).onReady(any(BatchingStrategy.class), any(TagBatch.class)); } } diff --git a/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java index aedb089..a2e4b1f 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java @@ -30,12 +30,14 @@ import com.flipkart.Utils; import com.flipkart.batching.BaseTestClass; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; -import com.flipkart.batching.exception.SerializeException; import com.flipkart.batching.strategy.SizeBatchingStrategy; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batchingcore.exception.SerializeException; import org.junit.After; import org.junit.Test; @@ -87,9 +89,9 @@ public void testOnTrimmedCalled() throws IOException { TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); SizeBatchingStrategy sizeBatchingStrategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatch = new SizeBatchingStrategy.SizeBatch<>(dataList, 3); + SizeBatch sizeBatch = new SizeBatch<>(dataList, 3); - TrimPersistedBatchReadyListener> trimPersistedBatchReadyListener = new TrimPersistedBatchReadyListener>(createRandomString(), serializationStrategy, + TrimPersistedBatchReadyListener> trimPersistedBatchReadyListener = new TrimPersistedBatchReadyListener>(createRandomFile().getPath(), serializationStrategy, handler, MAX_QUEUE_SIZE, TRIM_TO_SIZE, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START | TrimPersistedBatchReadyListener.MODE_TRIM_ON_READY, null, trimmedBatchCallback); trimPersistedBatchReadyListener.onReady(sizeBatchingStrategy, sizeBatch); @@ -125,9 +127,9 @@ public void testTrimmedNotCalled() throws IOException { TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); SizeBatchingStrategy sizeBatchingStrategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatch = new SizeBatchingStrategy.SizeBatch<>(dataList, 3); + SizeBatch sizeBatch = new SizeBatch<>(dataList, 3); - TrimPersistedBatchReadyListener> trimPersistedBatchReadyListener = new TrimPersistedBatchReadyListener>(createRandomString(), serializationStrategy, + TrimPersistedBatchReadyListener> trimPersistedBatchReadyListener = new TrimPersistedBatchReadyListener>(createRandomFile().getPath(), serializationStrategy, handler, MAX_QUEUE_SIZE, TRIM_TO_SIZE, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START | TrimPersistedBatchReadyListener.MODE_TRIM_ON_READY, null, trimmedBatchCallback); trimPersistedBatchReadyListener.onReady(sizeBatchingStrategy, sizeBatch); @@ -159,11 +161,11 @@ public void testTrimMode() throws IOException { Looper looper = handlerThread.getLooper(); ShadowLooper shadowLooper = Shadows.shadowOf(looper); Handler handler = new Handler(looper); - String filePath = createRandomString(); + String filePath = createRandomFile().getPath(); TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); SizeBatchingStrategy sizeBatchingStrategy = mock(SizeBatchingStrategy.class); - SizeBatchingStrategy.SizeBatch sizeBatch = new SizeBatchingStrategy.SizeBatch<>(dataList, 3); + SizeBatch sizeBatch = new SizeBatch<>(dataList, 3); TrimPersistedBatchReadyListener> trimPersistedBatchReadyListener = new TrimPersistedBatchReadyListener>(filePath, serializationStrategy, handler, MAX_QUEUE_SIZE, TRIM_TO_SIZE, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, null, trimmedBatchCallback); @@ -177,7 +179,7 @@ public void testTrimMode() throws IOException { trimPersistedBatchReadyListener = new TrimPersistedBatchReadyListener>(filePath, serializationStrategy, handler, MAX_QUEUE_SIZE, TRIM_TO_SIZE, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, null, trimmedBatchCallback); - SizeBatchingStrategy.SizeBatch sizeBatch2 = new SizeBatchingStrategy.SizeBatch<>(dataList, 1); + SizeBatch sizeBatch2 = new SizeBatch<>(dataList, 1); trimPersistedBatchReadyListener.onReady(sizeBatchingStrategy, sizeBatch2); shadowLooper.runToEndOfTasks(); //verify that onTrimmed gets called @@ -186,7 +188,7 @@ public void testTrimMode() throws IOException { /** * Test to verify that exception is thrown - * when {@link TrimPersistedBatchReadyListener#trimSize} > {@link TrimPersistedBatchReadyListener#queueSize} + * when {@link TrimPersistedBatchReadyListener#trimSize} > {@link TrimPersistedBatchReadyListener#maxQueueSize} */ @Test(expected = IllegalArgumentException.class) public void testThrowException() { @@ -207,7 +209,7 @@ public void testThrowException() { TrimmedBatchCallback trimmedBatchCallback = mock(TrimmedBatchCallback.class); //throw exception as TrimToSize is greater than MaxQueueSize - TrimPersistedBatchReadyListener> trimPersistedBatchReadyListener = new TrimPersistedBatchReadyListener>(createRandomString(), serializationStrategy, + TrimPersistedBatchReadyListener> trimPersistedBatchReadyListener = new TrimPersistedBatchReadyListener>(createRandomFile().getPath(), serializationStrategy, handler, MAX_QUEUE_SIZE, 5, TrimPersistedBatchReadyListener.MODE_TRIM_AT_START, null, trimmedBatchCallback); } From eff50a00be83d5120a8454bd3ee0e4ff6c8e99d5 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:02:11 +0530 Subject: [PATCH 28/41] #109 refactored persistence test --- .../batching/persistence/DatabaseHelperTest.java | 11 ++++++----- .../batching/persistence/InMemoryPersistenceTest.java | 2 +- .../batching/persistence/SQLPersistenceTest.java | 6 ++++-- .../batching/persistence/TagBasedPersistenceTest.java | 8 +++++--- .../batching/persistence/TapePersistenceTest.java | 6 ++++-- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java b/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java index d3464ea..3e0c8f0 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java @@ -28,13 +28,14 @@ import android.database.sqlite.SQLiteDatabase; import com.flipkart.Utils; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; -import com.flipkart.batching.data.EventData; -import com.flipkart.batching.exception.DeserializeException; -import com.flipkart.batching.exception.SerializeException; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.data.EventData; +import com.flipkart.batchingcore.exception.DeserializeException; +import com.flipkart.batchingcore.exception.SerializeException; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java index 9928cd9..38b2d24 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java @@ -25,7 +25,7 @@ package com.flipkart.batching.persistence; import com.flipkart.Utils; -import com.flipkart.batching.Data; +import com.flipkart.batchingcore.Data; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java index 95dcf9f..97c2181 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java @@ -30,7 +30,9 @@ import com.flipkart.batching.BaseTestClass; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import junit.framework.Assert; @@ -108,7 +110,7 @@ public void testSerializeException() { PersistenceStrategy persistenceStrategy; Context context; context = RuntimeEnvironment.application; - persistenceStrategy = new SQLPersistenceStrategy<>(new GsonSerializationStrategy<>(), createRandomString(), context); + persistenceStrategy = new SQLPersistenceStrategy<>(new GsonSerializationStrategy<>(), createRandomFile().getPath(), context); persistenceStrategy.onInitialized(); persistenceStrategy.add(Utils.fakeCollection(4)); } diff --git a/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java index afa51fa..3f4d63f 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java @@ -27,11 +27,13 @@ import android.content.Context; import com.flipkart.Utils; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import org.junit.Assert; import org.junit.Test; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java index bd6d3f5..0668d04 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java @@ -28,7 +28,9 @@ import com.flipkart.batching.BaseTestClass; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import junit.framework.Assert; @@ -106,7 +108,7 @@ private PersistenceStrategy initializeTapePersistence() { SerializationStrategy serializationStrategy = new GsonSerializationStrategy(); BatchManager.registerBuiltInTypes(serializationStrategy); serializationStrategy.build(); - TapePersistenceStrategy persistenceStrategy = new TapePersistenceStrategy<>(createRandomString(), serializationStrategy); + TapePersistenceStrategy persistenceStrategy = new TapePersistenceStrategy<>(createRandomFile().getPath(), serializationStrategy); persistenceStrategy.onInitialized(); return persistenceStrategy; From 9a5ffb2e5baed4df672874e09d05d6955f0794be Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:02:22 +0530 Subject: [PATCH 29/41] #109 refactored strategy test --- .../strategy/BaseBatchingStrategyTest.java | 4 ++-- .../batching/strategy/SizeBatchingTest.java | 9 ++++---- .../strategy/SizeTimeBatchingTest.java | 9 ++++---- .../batching/strategy/TagBatchingTest.java | 22 ++++++++++--------- .../batching/strategy/TimeBatchingTest.java | 19 ++++++++-------- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java b/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java index 11a1fc7..bdeaa11 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java @@ -28,13 +28,13 @@ import android.os.Handler; import com.flipkart.Utils; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchController; import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java index 9dce370..2311180 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java @@ -28,11 +28,12 @@ import android.os.Handler; import com.flipkart.Utils; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching.Data; import com.flipkart.batching.listener.PersistedBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.SizeBatch; import junit.framework.Assert; @@ -295,8 +296,8 @@ public void testIfPersistenceNull() { public void testSizeBatchInfo() { ArrayList list1 = Utils.fakeCollection(5); ArrayList list2 = new ArrayList<>(list1); - SizeBatchingStrategy.SizeBatch sizeBatchInfo = new SizeBatchingStrategy.SizeBatch<>(list1, 5); - SizeBatchingStrategy.SizeBatch sizeBatchInfo1 = new SizeBatchingStrategy.SizeBatch<>(list2, 5); + SizeBatch sizeBatchInfo = new SizeBatch<>(list1, 5); + SizeBatch sizeBatchInfo1 = new SizeBatch<>(list2, 5); Assert.assertTrue(sizeBatchInfo.equals(sizeBatchInfo1)); Assert.assertTrue(!sizeBatchInfo.equals("event")); diff --git a/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java index 7968e3f..01f116f 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java @@ -30,13 +30,14 @@ import android.os.Looper; import com.flipkart.Utils; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchController; import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.SizeTimeBatch; import junit.framework.Assert; @@ -241,8 +242,8 @@ public void testOnInitialized() { public void testComboBatchInfo() { ArrayList list1 = Utils.fakeCollection(5); ArrayList list2 = new ArrayList<>(list1); - SizeTimeBatchingStrategy.SizeTimeBatch sizeTimeBatch = new SizeTimeBatchingStrategy.SizeTimeBatch(list1, 5, 5000); - SizeTimeBatchingStrategy.SizeTimeBatch sizeTimeBatch1 = new SizeTimeBatchingStrategy.SizeTimeBatch(list2, 5, 5000); + SizeTimeBatch sizeTimeBatch = new SizeTimeBatch(list1, 5, 5000); + SizeTimeBatch sizeTimeBatch1 = new SizeTimeBatch(list2, 5, 5000); Assert.assertTrue(sizeTimeBatch.equals(sizeTimeBatch1)); Assert.assertTrue(!sizeTimeBatch.equals("event")); diff --git a/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java index 48a48cc..03f3207 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java @@ -30,13 +30,15 @@ import android.os.Looper; import com.flipkart.Utils; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batching.data.Tag; -import com.flipkart.batching.data.TagData; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batchingcore.batch.TagBatch; +import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batchingcore.data.TagData; import com.flipkart.batching.persistence.InMemoryPersistenceStrategy; import com.flipkart.batching.persistence.SQLPersistenceStrategy; import com.flipkart.batching.persistence.TagBasedPersistenceStrategy; @@ -193,7 +195,7 @@ public void testOnReadyCallbackFlushTrue() { tagBatchingStrategy.flush(true); //verify that onReady is called, as flush force is true - verify(onBatchReadyListener, times(2)).onReady(eq(tagBatchingStrategy), any(TagBatchingStrategy.TagBatch.class)); + verify(onBatchReadyListener, times(2)).onReady(eq(tagBatchingStrategy), any(TagBatch.class)); } /** @@ -227,7 +229,7 @@ public void testOnReadyCallbackDataForSize() { when(inMemoryPersistenceStrategy.getData()).thenReturn(adsTagDataList); when(inMemoryPersistenceStrategy.getDataSize()).thenReturn(adsTagDataList.size()); tagBatchingStrategy.flush(false); - verify(onBatchReadyListener, times(1)).onReady(eq(tagBatchingStrategy), any(TagBatchingStrategy.TagBatch.class)); + verify(onBatchReadyListener, times(1)).onReady(eq(tagBatchingStrategy), any(TagBatch.class)); } /** @@ -263,7 +265,7 @@ public void testOnReadyCallbackDataForTime() { tagBatchingStrategy.flush(false); shadowLooper.idle(5000); //verify it gets called after 5000ms - verify(onBatchReadyListener, times(1)).onReady(eq(tagBatchingStrategy), any(TagBatchingStrategy.TagBatch.class)); + verify(onBatchReadyListener, times(1)).onReady(eq(tagBatchingStrategy), any(TagBatch.class)); } /** @@ -351,8 +353,8 @@ public void testTagBatchEquals() { ArrayList list1 = Utils.fakeCollection(5); ArrayList list2 = new ArrayList<>(list1); - TagBatchingStrategy.TagBatch tagBatchInfo = new TagBatchingStrategy.TagBatch(AD_TAG, new SizeBatchingStrategy.SizeBatch<>(list1, 5)); - TagBatchingStrategy.TagBatch tagBatchInfo1 = new TagBatchingStrategy.TagBatch(AD_TAG, new SizeBatchingStrategy.SizeBatch<>(list2, 5)); + TagBatch tagBatchInfo = new TagBatch(AD_TAG, new SizeBatch<>(list1, 5)); + TagBatch tagBatchInfo1 = new TagBatch(AD_TAG, new SizeBatch<>(list2, 5)); Assert.assertNotNull(tagBatchInfo.getTag()); Assert.assertTrue(tagBatchInfo.equals(tagBatchInfo1)); @@ -366,7 +368,7 @@ public void testTagBatchEquals() { public void testTagBatchCollection() { Tag AD_TAG = new Tag("ADS"); ArrayList tagDatas = Utils.fakeTagAdsCollection(4); - TagBatchingStrategy.TagBatch tagBatch = new TagBatchingStrategy.TagBatch(AD_TAG, new SizeBatchingStrategy.SizeBatch(tagDatas, 4)); + TagBatch tagBatch = new TagBatch(AD_TAG, new SizeBatch(tagDatas, 4)); Assert.assertTrue(tagDatas == tagBatch.getDataCollection()); } } diff --git a/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java index 44a981f..20996b9 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java @@ -30,12 +30,13 @@ import android.os.Looper; import com.flipkart.Utils; -import com.flipkart.batching.Batch; import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching.Data; import com.flipkart.batching.listener.PersistedBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.batch.TimeBatch; import junit.framework.Assert; @@ -139,7 +140,7 @@ public void testOnReadyCallbackFlushTrue() { when(persistenceStrategy.getDataSize()).thenReturn(data.size()); timeBatchingStrategy.flush(true); //verify that it gets called once - verify(onBatchReadyListener, times(1)).onReady(eq(timeBatchingStrategy), any(TimeBatchingStrategy.TimeBatch.class)); + verify(onBatchReadyListener, times(1)).onReady(eq(timeBatchingStrategy), any(TimeBatch.class)); data.clear(); data = Utils.fakeCollection(5); @@ -149,7 +150,7 @@ public void testOnReadyCallbackFlushTrue() { when(persistenceStrategy.getDataSize()).thenReturn(data.size()); timeBatchingStrategy.flush(true); //verify that it gets called once - verify(onBatchReadyListener, times(1)).onReady(eq(timeBatchingStrategy), any(TimeBatchingStrategy.TimeBatch.class)); + verify(onBatchReadyListener, times(1)).onReady(eq(timeBatchingStrategy), any(TimeBatch.class)); } /** @@ -175,7 +176,7 @@ public void testOnReadyCallbackData() { timeBatchingStrategy.flush(false); shadowLooper.idle(TIME_OUT); //verify that it gets called once - verify(onBatchReadyListener, times(1)).onReady(eq(timeBatchingStrategy), any(TimeBatchingStrategy.TimeBatch.class)); + verify(onBatchReadyListener, times(1)).onReady(eq(timeBatchingStrategy), any(TimeBatch.class)); reset(onBatchReadyListener); data.clear(); @@ -187,7 +188,7 @@ public void testOnReadyCallbackData() { timeBatchingStrategy.flush(false); shadowLooper.idle(TIME_OUT); //verify that it gets called once - verify(onBatchReadyListener, times(1)).onReady(eq(timeBatchingStrategy), any(TimeBatchingStrategy.TimeBatch.class)); + verify(onBatchReadyListener, times(1)).onReady(eq(timeBatchingStrategy), any(TimeBatch.class)); } /** @@ -212,7 +213,7 @@ public void testOnReadyForEmptyData() { when(persistenceStrategy.getDataSize()).thenReturn(data.size()); timeBatchingStrategy.flush(false); //verify that onReady is NOT called since the data list is empty. - verify(onBatchReadyListener, times(0)).onReady(eq(timeBatchingStrategy), any(TimeBatchingStrategy.TimeBatch.class)); + verify(onBatchReadyListener, times(0)).onReady(eq(timeBatchingStrategy), any(TimeBatch.class)); } /** @@ -222,8 +223,8 @@ public void testOnReadyForEmptyData() { public void testTimeBatch() { ArrayList list1 = Utils.fakeCollection(2); ArrayList list2 = new ArrayList<>(list1); - TimeBatchingStrategy.TimeBatch timeBatchInfo = new TimeBatchingStrategy.TimeBatch<>(list1, 5000); - TimeBatchingStrategy.TimeBatch timeBatchInfo1 = new TimeBatchingStrategy.TimeBatch<>(list2, 5000); + TimeBatch timeBatchInfo = new TimeBatch<>(list1, 5000); + TimeBatch timeBatchInfo1 = new TimeBatch<>(list2, 5000); Assert.assertTrue(timeBatchInfo.equals(timeBatchInfo1)); Assert.assertTrue(!timeBatchInfo.equals("a")); From d0a117624684072f66fd86470736c225fbd4bff3 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:02:36 +0530 Subject: [PATCH 30/41] #109 base test class refactor --- .../com/flipkart/batching/BaseTestClass.java | 20 ++++++++++++++++++- .../flipkart/batching/BatchManagerTest.java | 11 ++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/batching/src/test/java/com/flipkart/batching/BaseTestClass.java b/batching/src/test/java/com/flipkart/batching/BaseTestClass.java index 41be4d2..a638389 100644 --- a/batching/src/test/java/com/flipkart/batching/BaseTestClass.java +++ b/batching/src/test/java/com/flipkart/batching/BaseTestClass.java @@ -24,6 +24,8 @@ package com.flipkart.batching; +import org.junit.After; + import java.io.File; /** @@ -40,7 +42,7 @@ public class BaseTestClass { */ public String createRandomString() { double random = Math.random(); - return "Random" + random; + return "Random" + random + TEST_FILE_SUFFIX; } /** @@ -77,5 +79,21 @@ public void deleteRandomFiles() { } } folder.delete(); + + folder = new File(""); + fList = folder.listFiles(); + if (fList != null) { + for (File testFile : fList) { + if (testFile.getName().endsWith(TEST_FILE_SUFFIX)) { + testFile.delete(); + } + } + } } + + @After + public void tearDownBase() { + deleteRandomFiles(); + } + } diff --git a/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java b/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java index 5525ba5..d410998 100644 --- a/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java +++ b/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java @@ -40,6 +40,11 @@ import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; import com.flipkart.batching.tape.ObjectQueue; +import com.flipkart.batching_gson.utils.GsonSerializationStrategy; +import com.flipkart.batchingcore.Batch; +import com.flipkart.batchingcore.BatchImpl; +import com.flipkart.batchingcore.Data; +import com.flipkart.batchingcore.SerializationStrategy; import junit.framework.Assert; @@ -284,8 +289,8 @@ public void testReInitialized() { ShadowLooper shadowLooper = Shadows.shadowOf(Looper.getMainLooper()); Handler handler = new Handler(); - String filePath = createRandomString(); - String filePath1 = createRandomString(); + String filePath = createRandomFile().getPath(); + String filePath1 = createRandomFile().getPath(); SerializationStrategy> serializationStrategy = new GsonSerializationStrategy<>(); TapePersistenceStrategy persistenceStrategy = new TapePersistenceStrategy<>(filePath1, serializationStrategy); Context context = RuntimeEnvironment.application; @@ -358,4 +363,6 @@ public boolean isNetworkConnected(Context context) { Assert.assertTrue(outputData.size() == 6); } + + } \ No newline at end of file From b911672b0afc680c49f71040a3453e0d2411cd1b Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:10:13 +0530 Subject: [PATCH 31/41] #109 maven plugin fix --- batching-core/build.gradle | 1 + batching-gson/build.gradle | 1 + batching/build.gradle | 1 + 3 files changed, 3 insertions(+) diff --git a/batching-core/build.gradle b/batching-core/build.gradle index a42ac84..4950a0c 100644 --- a/batching-core/build.gradle +++ b/batching-core/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion 24 diff --git a/batching-gson/build.gradle b/batching-gson/build.gradle index 52e4965..baa643c 100644 --- a/batching-gson/build.gradle +++ b/batching-gson/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion 24 diff --git a/batching/build.gradle b/batching/build.gradle index 72a33f9..a5c576d 100644 --- a/batching/build.gradle +++ b/batching/build.gradle @@ -24,6 +24,7 @@ apply plugin: 'com.android.library' apply plugin: "net.ltgt.errorprone" +apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion 24 From b10d91145cadb3caa771b6455cb24bc0cd7871c1 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:15:44 +0530 Subject: [PATCH 32/41] #109 moved back to older gradle wrapper --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 574339f..9b0d547 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip From 65ca829e9d1918e5450f0b287663986e28329474 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:16:29 +0530 Subject: [PATCH 33/41] #109 moved back to older gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3149bce..b38460e 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0-beta1' + classpath 'com.android.tools.build:gradle:2.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From 1ff8d14b4e6291a77e3863644ecdec3ef5e60613 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:16:42 +0530 Subject: [PATCH 34/41] #109 maven plugin applied --- batching-core/build.gradle | 1 - batching-gson/build.gradle | 1 - batching/build.gradle | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/batching-core/build.gradle b/batching-core/build.gradle index 4950a0c..a42ac84 100644 --- a/batching-core/build.gradle +++ b/batching-core/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion 24 diff --git a/batching-gson/build.gradle b/batching-gson/build.gradle index baa643c..52e4965 100644 --- a/batching-gson/build.gradle +++ b/batching-gson/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion 24 diff --git a/batching/build.gradle b/batching/build.gradle index a5c576d..eebb75d 100644 --- a/batching/build.gradle +++ b/batching/build.gradle @@ -23,8 +23,8 @@ */ apply plugin: 'com.android.library' -apply plugin: "net.ltgt.errorprone" apply plugin: 'com.github.dcendents.android-maven' +apply plugin: "net.ltgt.errorprone" android { compileSdkVersion 24 @@ -84,4 +84,4 @@ buildscript { classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.8" } -} \ No newline at end of file +} From e56e174ae6fe53558b5dd9bde5f53fc71195eb9b Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 15:33:05 +0530 Subject: [PATCH 35/41] #109 moved to android-maven --- batching/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batching/build.gradle b/batching/build.gradle index eebb75d..a496c14 100644 --- a/batching/build.gradle +++ b/batching/build.gradle @@ -23,7 +23,7 @@ */ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'android-maven' apply plugin: "net.ltgt.errorprone" android { From 41c6c1b6b74f4bd628608f4efab336ee56405ae1 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Thu, 11 Aug 2016 16:23:41 +0530 Subject: [PATCH 36/41] #109 applied maven plugin --- batching-core/build.gradle | 13 +++++++++++++ batching-gson/build.gradle | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/batching-core/build.gradle b/batching-core/build.gradle index a42ac84..dab1a27 100644 --- a/batching-core/build.gradle +++ b/batching-core/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply plugin: 'android-maven' android { compileSdkVersion 24 @@ -21,6 +22,18 @@ android { } } +buildscript { + repositories { + maven { url 'http://repo1.maven.org/maven2' } + maven { url "https://plugins.gradle.org/m2/" } + } + dependencies { + classpath 'com.android.tools.build:gradle:2.2.0-beta1' + classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + } +} + dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { diff --git a/batching-gson/build.gradle b/batching-gson/build.gradle index 52e4965..e911834 100644 --- a/batching-gson/build.gradle +++ b/batching-gson/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply plugin: 'android-maven' android { compileSdkVersion 24 @@ -21,6 +22,18 @@ android { } } +buildscript { + repositories { + maven { url 'http://repo1.maven.org/maven2' } + maven { url "https://plugins.gradle.org/m2/" } + } + dependencies { + classpath 'com.android.tools.build:gradle:2.2.0-beta1' + classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + } +} + dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.google.code.gson:gson:2.4' From f9dff05575e33cc05a9460979861daa9cfc90f00 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Sat, 26 Nov 2016 16:33:33 +0530 Subject: [PATCH 37/41] #109 gradle version bump --- batching-core/build.gradle | 30 ++++------------- batching-gson/build.gradle | 42 ++++++++++++------------ batching/build.gradle | 12 +++---- build.gradle | 3 +- gradle/wrapper/gradle-wrapper.properties | 4 +-- 5 files changed, 38 insertions(+), 53 deletions(-) diff --git a/batching-core/build.gradle b/batching-core/build.gradle index dab1a27..c45da78 100644 --- a/batching-core/build.gradle +++ b/batching-core/build.gradle @@ -1,5 +1,10 @@ apply plugin: 'com.android.library' -apply plugin: 'android-maven' + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:25.0.1' + testCompile 'junit:junit:4.12' +} android { compileSdkVersion 24 @@ -20,25 +25,4 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } -} - -buildscript { - repositories { - maven { url 'http://repo1.maven.org/maven2' } - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - classpath 'com.android.tools.build:gradle:2.2.0-beta1' - classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) - compile 'com.android.support:appcompat-v7:24.1.1' - testCompile 'junit:junit:4.12' -} +} \ No newline at end of file diff --git a/batching-gson/build.gradle b/batching-gson/build.gradle index e911834..fe88497 100644 --- a/batching-gson/build.gradle +++ b/batching-gson/build.gradle @@ -1,5 +1,25 @@ apply plugin: 'com.android.library' -apply plugin: 'android-maven' +apply plugin: 'com.github.dcendents.android-maven' + +buildscript { + repositories { + maven { url 'http://repo1.maven.org/maven2' } + maven { url "https://plugins.gradle.org/m2/" } + } + dependencies { + classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + compile 'com.google.code.gson:gson:2.4' + compile 'com.android.support:appcompat-v7:25.0.1' + compile 'com.github.flipkart-incubator.batchman:batching-core:1.1.8' + testCompile 'junit:junit:4.12' +} android { compileSdkVersion 24 @@ -21,23 +41,3 @@ android { } } } - -buildscript { - repositories { - maven { url 'http://repo1.maven.org/maven2' } - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - classpath 'com.android.tools.build:gradle:2.2.0-beta1' - classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' - } -} - -dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.google.code.gson:gson:2.4' - compile 'com.android.support:appcompat-v7:24.1.1' - compile project(':batching-core') - testCompile 'junit:junit:4.12' -} \ No newline at end of file diff --git a/batching/build.gradle b/batching/build.gradle index a496c14..df0b4f6 100644 --- a/batching/build.gradle +++ b/batching/build.gradle @@ -23,7 +23,7 @@ */ apply plugin: 'com.android.library' -apply plugin: 'android-maven' +apply plugin: 'com.github.dcendents.android-maven' apply plugin: "net.ltgt.errorprone" android { @@ -63,11 +63,11 @@ dependencies { testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.robolectric:robolectric:3.1.1' - testCompile project(':batching-gson') + testCompile 'com.github.flipkart-incubator.batchman:batching-gson:1.1.8' //temp fix, will need to look into this dependency since batching-gson already has this dependency testCompile 'com.google.code.gson:gson:2.4' - compile project(':batching-core') + compile 'com.github.flipkart-incubator.batchman:batching-core:1.1.8' compile 'org.jetbrains:annotations-java5:15.0' compile 'org.slf4j:slf4j-api:1.7.6' errorprone 'com.google.errorprone:error_prone_core:2.0.9' @@ -79,9 +79,9 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0-beta1' + classpath 'com.android.tools.build:gradle:2.2.2' classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.8" } -} +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index b38460e..958a73e 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.android.tools.build:gradle:2.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -39,6 +39,7 @@ buildscript { allprojects { repositories { jcenter() + maven { url "https://jitpack.io" } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9b0d547..23384c2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Aug 11 10:43:03 IST 2016 +#Sat Nov 26 16:20:47 IST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip From 6993b4a7e3540033c14e80734bf12f5ce3f45427 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Sat, 26 Nov 2016 17:22:14 +0530 Subject: [PATCH 38/41] #109 change batching-core pakcage name --- batching-gson/build.gradle | 2 +- .../GsonSerializationStrategy.java | 20 +++++++------- .../RuntimeTypeAdapterFactory.java | 2 +- .../utils/{utils => }/Deserializer.java | 6 ++--- .../utils/{utils => }/Serializer.java | 6 ++--- .../batching_gson/GsonSerializationTest.java | 26 +++++++++---------- .../com/flipkart/batching_gson/Utils.java | 8 +++--- 7 files changed, 35 insertions(+), 35 deletions(-) rename batching-gson/src/main/java/com/flipkart/batching_gson/{utils => }/GsonSerializationStrategy.java (96%) rename batching-gson/src/main/java/com/flipkart/batching_gson/{utils => }/RuntimeTypeAdapterFactory.java (99%) rename batching-gson/src/main/java/com/flipkart/batching_gson/utils/{utils => }/Deserializer.java (87%) rename batching-gson/src/main/java/com/flipkart/batching_gson/utils/{utils => }/Serializer.java (86%) diff --git a/batching-gson/build.gradle b/batching-gson/build.gradle index fe88497..1834c4c 100644 --- a/batching-gson/build.gradle +++ b/batching-gson/build.gradle @@ -17,7 +17,7 @@ dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.google.code.gson:gson:2.4' compile 'com.android.support:appcompat-v7:25.0.1' - compile 'com.github.flipkart-incubator.batchman:batching-core:1.1.8' + compile project(':batching-core') testCompile 'junit:junit:4.12' } diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/GsonSerializationStrategy.java b/batching-gson/src/main/java/com/flipkart/batching_gson/GsonSerializationStrategy.java similarity index 96% rename from batching-gson/src/main/java/com/flipkart/batching_gson/utils/GsonSerializationStrategy.java rename to batching-gson/src/main/java/com/flipkart/batching_gson/GsonSerializationStrategy.java index a0a277a..df07e69 100644 --- a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/GsonSerializationStrategy.java +++ b/batching-gson/src/main/java/com/flipkart/batching_gson/GsonSerializationStrategy.java @@ -22,16 +22,16 @@ * THE SOFTWARE. */ -package com.flipkart.batching_gson.utils; - -import com.flipkart.batching_gson.utils.utils.Deserializer; -import com.flipkart.batching_gson.utils.utils.Serializer; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.DataCollection; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.exception.DeserializeException; -import com.flipkart.batchingcore.exception.SerializeException; +package com.flipkart.batching_gson; + +import com.flipkart.batching_gson.utils.Deserializer; +import com.flipkart.batching_gson.utils.Serializer; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.DataCollection; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.exception.DeserializeException; +import com.flipkart.batching_core.exception.SerializeException; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/RuntimeTypeAdapterFactory.java b/batching-gson/src/main/java/com/flipkart/batching_gson/RuntimeTypeAdapterFactory.java similarity index 99% rename from batching-gson/src/main/java/com/flipkart/batching_gson/utils/RuntimeTypeAdapterFactory.java rename to batching-gson/src/main/java/com/flipkart/batching_gson/RuntimeTypeAdapterFactory.java index 88334c8..a7bee91 100644 --- a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/RuntimeTypeAdapterFactory.java +++ b/batching-gson/src/main/java/com/flipkart/batching_gson/RuntimeTypeAdapterFactory.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_gson.utils; +package com.flipkart.batching_gson; import com.google.gson.Gson; import com.google.gson.JsonElement; diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Deserializer.java b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/Deserializer.java similarity index 87% rename from batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Deserializer.java rename to batching-gson/src/main/java/com/flipkart/batching_gson/utils/Deserializer.java index aa2d7e9..75e83fb 100644 --- a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Deserializer.java +++ b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/Deserializer.java @@ -1,7 +1,7 @@ -package com.flipkart.batching_gson.utils.utils; +package com.flipkart.batching_gson.utils; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.DataCollection; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.DataCollection; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Serializer.java b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/Serializer.java similarity index 86% rename from batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Serializer.java rename to batching-gson/src/main/java/com/flipkart/batching_gson/utils/Serializer.java index 426043f..ce2afab 100644 --- a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/utils/Serializer.java +++ b/batching-gson/src/main/java/com/flipkart/batching_gson/utils/Serializer.java @@ -1,7 +1,7 @@ -package com.flipkart.batching_gson.utils.utils; +package com.flipkart.batching_gson.utils; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.DataCollection; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.DataCollection; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; diff --git a/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java b/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java index 8b75afa..7877be9 100644 --- a/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java +++ b/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java @@ -24,19 +24,19 @@ package com.flipkart.batching_gson; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.batch.SizeBatch; -import com.flipkart.batchingcore.batch.SizeTimeBatch; -import com.flipkart.batchingcore.batch.TagBatch; -import com.flipkart.batchingcore.batch.TimeBatch; -import com.flipkart.batchingcore.data.EventData; -import com.flipkart.batchingcore.data.TagData; -import com.flipkart.batchingcore.exception.DeserializeException; -import com.flipkart.batchingcore.exception.SerializeException; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching_core.batch.SizeTimeBatch; +import com.flipkart.batching_core.batch.TagBatch; +import com.flipkart.batching_core.batch.TimeBatch; +import com.flipkart.batching_core.data.EventData; +import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching_core.exception.DeserializeException; +import com.flipkart.batching_core.exception.SerializeException; import com.google.gson.JsonSyntaxException; import junit.framework.Assert; diff --git a/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java b/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java index a350802..01b028d 100644 --- a/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java +++ b/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java @@ -24,10 +24,10 @@ package com.flipkart.batching_gson; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.data.EventData; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.data.EventData; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import java.util.ArrayList; From 75973f46189bff953f6f751cd271655f08135f8a Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Sat, 26 Nov 2016 17:22:58 +0530 Subject: [PATCH 39/41] #109 package name change --- .../ExampleInstrumentedTest.java | 4 ++-- batching-core/src/main/AndroidManifest.xml | 2 +- .../{batchingcore => batching_core}/Batch.java | 2 +- .../{batchingcore => batching_core}/BatchImpl.java | 2 +- .../flipkart/{batchingcore => batching_core}/Data.java | 4 ++-- .../DataCollection.java | 2 +- .../SerializationStrategy.java | 6 +++--- .../batch/SizeBatch.java | 6 +++--- .../batch/SizeTimeBatch.java | 6 +++--- .../batch/TagBatch.java | 10 +++++----- .../batch/TimeBatch.java | 6 +++--- .../data/EventData.java | 4 ++-- .../{batchingcore => batching_core}/data/Tag.java | 4 ++-- .../{batchingcore => batching_core}/data/TagData.java | 4 ++-- .../exception/DeserializeException.java | 2 +- .../exception/SerializeException.java | 2 +- .../{batchingcore => batching_core}/Utils.java | 8 ++++---- .../batch/SizeBatchTest.java | 2 +- .../batch/SizeTimeBatchTest.java | 2 +- .../batch/TagBatchTest.java | 4 ++-- .../batch/TimeBatchTest.java | 2 +- .../data/BatchTest.java | 10 +++++----- .../{batchingcore => batching_core}/data/DataTest.java | 4 ++-- .../{batchingcore => batching_core}/data/TagTest.java | 2 +- .../exception/DeserializeExceptionTest.java | 2 +- .../exception/SerializeExceptionTest.java | 2 +- 26 files changed, 52 insertions(+), 52 deletions(-) rename batching-core/src/androidTest/java/com/flipkart/{batchingcore => batching_core}/ExampleInstrumentedTest.java (83%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/Batch.java (97%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/BatchImpl.java (98%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/Data.java (96%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/DataCollection.java (98%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/SerializationStrategy.java (94%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/batch/SizeBatch.java (84%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/batch/SizeTimeBatch.java (89%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/batch/TagBatch.java (73%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/batch/TimeBatch.java (83%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/data/EventData.java (94%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/data/Tag.java (95%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/data/TagData.java (95%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/exception/DeserializeException.java (97%) rename batching-core/src/main/java/com/flipkart/{batchingcore => batching_core}/exception/SerializeException.java (97%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/Utils.java (95%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/batch/SizeBatchTest.java (96%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/batch/SizeTimeBatchTest.java (97%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/batch/TagBatchTest.java (94%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/batch/TimeBatchTest.java (96%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/data/BatchTest.java (90%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/data/DataTest.java (96%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/data/TagTest.java (98%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/exception/DeserializeExceptionTest.java (97%) rename batching-core/src/test/java/com/flipkart/{batchingcore => batching_core}/exception/SerializeExceptionTest.java (97%) diff --git a/batching-core/src/androidTest/java/com/flipkart/batchingcore/ExampleInstrumentedTest.java b/batching-core/src/androidTest/java/com/flipkart/batching_core/ExampleInstrumentedTest.java similarity index 83% rename from batching-core/src/androidTest/java/com/flipkart/batchingcore/ExampleInstrumentedTest.java rename to batching-core/src/androidTest/java/com/flipkart/batching_core/ExampleInstrumentedTest.java index c8b9e59..3d82e26 100644 --- a/batching-core/src/androidTest/java/com/flipkart/batchingcore/ExampleInstrumentedTest.java +++ b/batching-core/src/androidTest/java/com/flipkart/batching_core/ExampleInstrumentedTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batchingcore; +package com.flipkart.batching_core; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -21,6 +21,6 @@ public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); - assertEquals("com.flipkart.batchingcore.test", appContext.getPackageName()); + assertEquals("com.flipkart.batching_core.test", appContext.getPackageName()); } } diff --git a/batching-core/src/main/AndroidManifest.xml b/batching-core/src/main/AndroidManifest.xml index 0335046..e9b9871 100644 --- a/batching-core/src/main/AndroidManifest.xml +++ b/batching-core/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.flipkart.batching_core"> diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/Batch.java b/batching-core/src/main/java/com/flipkart/batching_core/Batch.java similarity index 97% rename from batching-core/src/main/java/com/flipkart/batchingcore/Batch.java rename to batching-core/src/main/java/com/flipkart/batching_core/Batch.java index f04da98..7503b21 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/Batch.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/Batch.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore; +package com.flipkart.batching_core; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/BatchImpl.java b/batching-core/src/main/java/com/flipkart/batching_core/BatchImpl.java similarity index 98% rename from batching-core/src/main/java/com/flipkart/batchingcore/BatchImpl.java rename to batching-core/src/main/java/com/flipkart/batching_core/BatchImpl.java index 979d833..3058e65 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/BatchImpl.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/BatchImpl.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore; +package com.flipkart.batching_core; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/Data.java b/batching-core/src/main/java/com/flipkart/batching_core/Data.java similarity index 96% rename from batching-core/src/main/java/com/flipkart/batchingcore/Data.java rename to batching-core/src/main/java/com/flipkart/batching_core/Data.java index 6b24b1d..1d056fc 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/Data.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/Data.java @@ -22,10 +22,10 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore; +package com.flipkart.batching_core; -import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batching_core.data.Tag; import java.io.Serializable; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/DataCollection.java b/batching-core/src/main/java/com/flipkart/batching_core/DataCollection.java similarity index 98% rename from batching-core/src/main/java/com/flipkart/batchingcore/DataCollection.java rename to batching-core/src/main/java/com/flipkart/batching_core/DataCollection.java index 7f483ed..1872f6a 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/DataCollection.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/DataCollection.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore; +package com.flipkart.batching_core; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/SerializationStrategy.java b/batching-core/src/main/java/com/flipkart/batching_core/SerializationStrategy.java similarity index 94% rename from batching-core/src/main/java/com/flipkart/batchingcore/SerializationStrategy.java rename to batching-core/src/main/java/com/flipkart/batching_core/SerializationStrategy.java index a2acb33..771ed4c 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/SerializationStrategy.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/SerializationStrategy.java @@ -22,10 +22,10 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore; +package com.flipkart.batching_core; -import com.flipkart.batchingcore.exception.DeserializeException; -import com.flipkart.batchingcore.exception.SerializeException; +import com.flipkart.batching_core.exception.DeserializeException; +import com.flipkart.batching_core.exception.SerializeException; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeBatch.java b/batching-core/src/main/java/com/flipkart/batching_core/batch/SizeBatch.java similarity index 84% rename from batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeBatch.java rename to batching-core/src/main/java/com/flipkart/batching_core/batch/SizeBatch.java index 588aff4..5a2090c 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeBatch.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/batch/SizeBatch.java @@ -1,8 +1,8 @@ -package com.flipkart.batchingcore.batch; +package com.flipkart.batching_core.batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching_core.Data; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeTimeBatch.java b/batching-core/src/main/java/com/flipkart/batching_core/batch/SizeTimeBatch.java similarity index 89% rename from batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeTimeBatch.java rename to batching-core/src/main/java/com/flipkart/batching_core/batch/SizeTimeBatch.java index b3272d6..5e1a065 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/batch/SizeTimeBatch.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/batch/SizeTimeBatch.java @@ -1,7 +1,7 @@ -package com.flipkart.batchingcore.batch; +package com.flipkart.batching_core.batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching_core.Data; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/batch/TagBatch.java b/batching-core/src/main/java/com/flipkart/batching_core/batch/TagBatch.java similarity index 73% rename from batching-core/src/main/java/com/flipkart/batchingcore/batch/TagBatch.java rename to batching-core/src/main/java/com/flipkart/batching_core/batch/TagBatch.java index 098f73c..73a4ef9 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/batch/TagBatch.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/batch/TagBatch.java @@ -1,9 +1,9 @@ -package com.flipkart.batchingcore.batch; +package com.flipkart.batching_core.batch; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching_core.BatchImpl; public class TagBatch extends BatchImpl { private Tag tag; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/batch/TimeBatch.java b/batching-core/src/main/java/com/flipkart/batching_core/batch/TimeBatch.java similarity index 83% rename from batching-core/src/main/java/com/flipkart/batchingcore/batch/TimeBatch.java rename to batching-core/src/main/java/com/flipkart/batching_core/batch/TimeBatch.java index 1999fe3..8077d59 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/batch/TimeBatch.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/batch/TimeBatch.java @@ -1,7 +1,7 @@ -package com.flipkart.batchingcore.batch; +package com.flipkart.batching_core.batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.BatchImpl; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/data/EventData.java b/batching-core/src/main/java/com/flipkart/batching_core/data/EventData.java similarity index 94% rename from batching-core/src/main/java/com/flipkart/batchingcore/data/EventData.java rename to batching-core/src/main/java/com/flipkart/batching_core/data/EventData.java index d12a2a1..2988424 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/data/EventData.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/data/EventData.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.data; +package com.flipkart.batching_core.data; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Data; /** * EventData class that extends {@link Data}. diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/data/Tag.java b/batching-core/src/main/java/com/flipkart/batching_core/data/Tag.java similarity index 95% rename from batching-core/src/main/java/com/flipkart/batchingcore/data/Tag.java rename to batching-core/src/main/java/com/flipkart/batching_core/data/Tag.java index 904d041..bcc96fa 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/data/Tag.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/data/Tag.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.data; +package com.flipkart.batching_core.data; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Data; import java.io.Serializable; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/data/TagData.java b/batching-core/src/main/java/com/flipkart/batching_core/data/TagData.java similarity index 95% rename from batching-core/src/main/java/com/flipkart/batchingcore/data/TagData.java rename to batching-core/src/main/java/com/flipkart/batching_core/data/TagData.java index 97d98c8..634ab3d 100644 --- a/batching-core/src/main/java/com/flipkart/batchingcore/data/TagData.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/data/TagData.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.data; +package com.flipkart.batching_core.data; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Data; /** * TagData Class that extends {@link Data}. diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/exception/DeserializeException.java b/batching-core/src/main/java/com/flipkart/batching_core/exception/DeserializeException.java similarity index 97% rename from batching-core/src/main/java/com/flipkart/batchingcore/exception/DeserializeException.java rename to batching-core/src/main/java/com/flipkart/batching_core/exception/DeserializeException.java index 4571e7a..1322456 100755 --- a/batching-core/src/main/java/com/flipkart/batchingcore/exception/DeserializeException.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/exception/DeserializeException.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.exception; +package com.flipkart.batching_core.exception; import java.io.IOException; diff --git a/batching-core/src/main/java/com/flipkart/batchingcore/exception/SerializeException.java b/batching-core/src/main/java/com/flipkart/batching_core/exception/SerializeException.java similarity index 97% rename from batching-core/src/main/java/com/flipkart/batchingcore/exception/SerializeException.java rename to batching-core/src/main/java/com/flipkart/batching_core/exception/SerializeException.java index 71a15eb..cf535c1 100755 --- a/batching-core/src/main/java/com/flipkart/batchingcore/exception/SerializeException.java +++ b/batching-core/src/main/java/com/flipkart/batching_core/exception/SerializeException.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.exception; +package com.flipkart.batching_core.exception; import java.io.IOException; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/Utils.java b/batching-core/src/test/java/com/flipkart/batching_core/Utils.java similarity index 95% rename from batching-core/src/test/java/com/flipkart/batchingcore/Utils.java rename to batching-core/src/test/java/com/flipkart/batching_core/Utils.java index f932d4f..0c75f4b 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/Utils.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/Utils.java @@ -22,11 +22,11 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore; +package com.flipkart.batching_core; -import com.flipkart.batchingcore.data.EventData; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.data.EventData; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import java.util.ArrayList; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeBatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeBatchTest.java similarity index 96% rename from batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeBatchTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/batch/SizeBatchTest.java index fd35b19..88e5504 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeBatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeBatchTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batchingcore.batch; +package com.flipkart.batching_core.batch; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeTimeBatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeTimeBatchTest.java similarity index 97% rename from batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeTimeBatchTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/batch/SizeTimeBatchTest.java index 94e3113..e0fa909 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/batch/SizeTimeBatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeTimeBatchTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batchingcore.batch; +package com.flipkart.batching_core.batch; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/batch/TagBatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/batch/TagBatchTest.java similarity index 94% rename from batching-core/src/test/java/com/flipkart/batchingcore/batch/TagBatchTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/batch/TagBatchTest.java index 00ad690..b48f91f 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/batch/TagBatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/batch/TagBatchTest.java @@ -1,6 +1,6 @@ -package com.flipkart.batchingcore.batch; +package com.flipkart.batching_core.batch; -import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batching_core.data.Tag; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/batch/TimeBatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/batch/TimeBatchTest.java similarity index 96% rename from batching-core/src/test/java/com/flipkart/batchingcore/batch/TimeBatchTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/batch/TimeBatchTest.java index 1d32835..b906a0f 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/batch/TimeBatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/batch/TimeBatchTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batchingcore.batch; +package com.flipkart.batching_core.batch; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/data/BatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/data/BatchTest.java similarity index 90% rename from batching-core/src/test/java/com/flipkart/batchingcore/data/BatchTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/data/BatchTest.java index 051a143..1c09040 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/data/BatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/data/BatchTest.java @@ -22,13 +22,13 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.data; +package com.flipkart.batching_core.data; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.Utils; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.Utils; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/data/DataTest.java b/batching-core/src/test/java/com/flipkart/batching_core/data/DataTest.java similarity index 96% rename from batching-core/src/test/java/com/flipkart/batchingcore/data/DataTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/data/DataTest.java index 1e20549..f400950 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/data/DataTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/data/DataTest.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.data; +package com.flipkart.batching_core.data; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Data; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/data/TagTest.java b/batching-core/src/test/java/com/flipkart/batching_core/data/TagTest.java similarity index 98% rename from batching-core/src/test/java/com/flipkart/batchingcore/data/TagTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/data/TagTest.java index 8c022ba..c78d94f 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/data/TagTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/data/TagTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.data; +package com.flipkart.batching_core.data; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/exception/DeserializeExceptionTest.java b/batching-core/src/test/java/com/flipkart/batching_core/exception/DeserializeExceptionTest.java similarity index 97% rename from batching-core/src/test/java/com/flipkart/batchingcore/exception/DeserializeExceptionTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/exception/DeserializeExceptionTest.java index cd1d4ad..20a2f97 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/exception/DeserializeExceptionTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/exception/DeserializeExceptionTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.exception; +package com.flipkart.batching_core.exception; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batchingcore/exception/SerializeExceptionTest.java b/batching-core/src/test/java/com/flipkart/batching_core/exception/SerializeExceptionTest.java similarity index 97% rename from batching-core/src/test/java/com/flipkart/batchingcore/exception/SerializeExceptionTest.java rename to batching-core/src/test/java/com/flipkart/batching_core/exception/SerializeExceptionTest.java index 0409d95..a46f249 100644 --- a/batching-core/src/test/java/com/flipkart/batchingcore/exception/SerializeExceptionTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/exception/SerializeExceptionTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batchingcore.exception; +package com.flipkart.batching_core.exception; import junit.framework.Assert; From e1fdd62e5102a4da8387f9d33ddc5a983c190837 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Sat, 26 Nov 2016 17:23:38 +0530 Subject: [PATCH 40/41] #109 corresponding changes in other modules --- app/build.gradle | 36 ++++++++----------- .../com/flipkart/batchdemo/CustomTagData.java | 4 +-- .../java/com/flipkart/batchdemo/EventTag.java | 2 +- .../com/flipkart/batchdemo/MainActivity.java | 12 +++---- batching/build.gradle | 9 ++--- .../flipkart/batching/BatchController.java | 6 ++-- .../com/flipkart/batching/BatchManager.java | 20 +++++------ .../flipkart/batching/BatchingStrategy.java | 4 +-- .../batching/OnBatchReadyListener.java | 4 +-- .../flipkart/batching/TagBatchManager.java | 22 ++++++------ .../NetworkPersistedBatchReadyListener.java | 6 ++-- .../listener/PersistedBatchCallback.java | 2 +- .../listener/PersistedBatchReadyListener.java | 6 ++-- .../listener/TagBatchReadyListener.java | 6 ++-- .../TrimPersistedBatchReadyListener.java | 6 ++-- .../persistence/BatchObjectConverter.java | 6 ++-- .../persistence/DataObjectConverter.java | 6 ++-- .../batching/persistence/DatabaseHelper.java | 10 +++--- .../InMemoryPersistenceStrategy.java | 2 +- .../persistence/PersistenceStrategy.java | 2 +- .../persistence/SQLPersistenceStrategy.java | 10 +++--- .../TagBasedPersistenceStrategy.java | 6 ++-- .../persistence/TapePersistenceStrategy.java | 6 ++-- .../strategy/BaseBatchingStrategy.java | 4 +-- .../strategy/SizeBatchingStrategy.java | 4 +-- .../strategy/SizeTimeBatchingStrategy.java | 4 +-- .../strategy/TagBatchingStrategy.java | 10 +++--- .../strategy/TimeBatchingStrategy.java | 4 +-- .../toolbox/SizeTimeStrategyFactory.java | 6 ++-- .../src/test/java/com/flipkart/Utils.java | 8 ++--- .../flipkart/batching/BatchManagerTest.java | 10 +++--- .../NetworkPersistedBatchReadyTest.java | 12 +++---- .../listener/PersistedBatchReadyTest.java | 12 +++---- .../batching/listener/TagBatchReadyTest.java | 8 ++--- .../listener/TrimPersistedBatchReadyTest.java | 10 +++--- .../persistence/DatabaseHelperTest.java | 12 +++---- .../persistence/InMemoryPersistenceTest.java | 2 +- .../persistence/SQLPersistenceTest.java | 6 ++-- .../persistence/TagBasedPersistenceTest.java | 10 +++--- .../persistence/TapePersistenceTest.java | 6 ++-- .../strategy/BaseBatchingStrategyTest.java | 4 +-- .../batching/strategy/SizeBatchingTest.java | 6 ++-- .../strategy/SizeTimeBatchingTest.java | 6 ++-- .../batching/strategy/TagBatchingTest.java | 12 +++---- .../batching/strategy/TimeBatchingTest.java | 6 ++-- 45 files changed, 171 insertions(+), 184 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4e05f52..c69d9f1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,19 +24,26 @@ apply plugin: 'com.android.application' +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:25.0.1' + compile 'com.android.support:design:25.0.1' + compile project(':batching') + compile project(':batching-core') + compile project(':batching-gson') +} + android { - compileSdkVersion 24 - buildToolsVersion '24' + compileSdkVersion 25 + buildToolsVersion '25.0.0' defaultConfig { applicationId "com.flipkart.batchdemo" minSdkVersion 14 - targetSdkVersion 24 + targetSdkVersion 25 versionCode 1 versionName "1.0" - jackOptions { - enabled true - } } lintOptions { @@ -49,19 +56,4 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:24.0.0' - compile 'com.android.support:design:24.0.0' - compile project(':batching') - compile project(':batching-core') - compile project(':batching-gson') -} +} \ No newline at end of file diff --git a/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java b/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java index 3fdbf55..7a357fe 100644 --- a/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java +++ b/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java @@ -24,8 +24,8 @@ package com.flipkart.batchdemo; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import com.google.gson.annotations.SerializedName; import org.json.JSONObject; diff --git a/app/src/main/java/com/flipkart/batchdemo/EventTag.java b/app/src/main/java/com/flipkart/batchdemo/EventTag.java index d86b99f..3760263 100644 --- a/app/src/main/java/com/flipkart/batchdemo/EventTag.java +++ b/app/src/main/java/com/flipkart/batchdemo/EventTag.java @@ -24,7 +24,7 @@ package com.flipkart.batchdemo; -import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batching_core.data.Tag; import com.google.gson.annotations.SerializedName; public class EventTag extends Tag { diff --git a/app/src/main/java/com/flipkart/batchdemo/MainActivity.java b/app/src/main/java/com/flipkart/batchdemo/MainActivity.java index 54a6ffd..fcb753a 100644 --- a/app/src/main/java/com/flipkart/batchdemo/MainActivity.java +++ b/app/src/main/java/com/flipkart/batchdemo/MainActivity.java @@ -47,12 +47,12 @@ import com.flipkart.batching.listener.TrimmedBatchCallback; import com.flipkart.batching.persistence.TapePersistenceStrategy; import com.flipkart.batching.strategy.SizeBatchingStrategy; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.batch.TagBatch; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.batch.TagBatch; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching_gson.GsonSerializationStrategy; import java.util.ArrayList; import java.util.Collections; diff --git a/batching/build.gradle b/batching/build.gradle index df0b4f6..6dc6a95 100644 --- a/batching/build.gradle +++ b/batching/build.gradle @@ -51,11 +51,6 @@ android { testOptions { unitTests.returnDefaultValues = true } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } } dependencies { @@ -63,11 +58,11 @@ dependencies { testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.robolectric:robolectric:3.1.1' - testCompile 'com.github.flipkart-incubator.batchman:batching-gson:1.1.8' + testCompile project(':batching-gson') //temp fix, will need to look into this dependency since batching-gson already has this dependency testCompile 'com.google.code.gson:gson:2.4' - compile 'com.github.flipkart-incubator.batchman:batching-core:1.1.8' + compile project(':batching-core') compile 'org.jetbrains:annotations-java5:15.0' compile 'org.slf4j:slf4j-api:1.7.6' errorprone 'com.google.errorprone:error_prone_core:2.0.9' diff --git a/batching/src/main/java/com/flipkart/batching/BatchController.java b/batching/src/main/java/com/flipkart/batching/BatchController.java index 84be9b6..8f937a0 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchController.java +++ b/batching/src/main/java/com/flipkart/batching/BatchController.java @@ -26,9 +26,9 @@ import android.os.Handler; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/BatchManager.java b/batching/src/main/java/com/flipkart/batching/BatchManager.java index 0342f95..9ad29ad 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchManager.java +++ b/batching/src/main/java/com/flipkart/batching/BatchManager.java @@ -32,16 +32,16 @@ import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; import com.flipkart.batching.strategy.TagBatchingStrategy; import com.flipkart.batching.strategy.TimeBatchingStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.batch.SizeBatch; -import com.flipkart.batchingcore.batch.SizeTimeBatch; -import com.flipkart.batchingcore.batch.TagBatch; -import com.flipkart.batchingcore.batch.TimeBatch; -import com.flipkart.batchingcore.data.EventData; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching_core.batch.SizeTimeBatch; +import com.flipkart.batching_core.batch.TagBatch; +import com.flipkart.batching_core.batch.TimeBatch; +import com.flipkart.batching_core.data.EventData; +import com.flipkart.batching_core.data.TagData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java index 0b4670c..bc45814 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java @@ -27,8 +27,8 @@ import android.content.Context; import android.os.Handler; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java index 5c30898..9be0154 100644 --- a/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java @@ -25,8 +25,8 @@ package com.flipkart.batching; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; public interface OnBatchReadyListener> { void onReady(BatchingStrategy causingStrategy, T batch); diff --git a/batching/src/main/java/com/flipkart/batching/TagBatchManager.java b/batching/src/main/java/com/flipkart/batching/TagBatchManager.java index 203dc22..d21a28d 100644 --- a/batching/src/main/java/com/flipkart/batching/TagBatchManager.java +++ b/batching/src/main/java/com/flipkart/batching/TagBatchManager.java @@ -31,17 +31,17 @@ import com.flipkart.batching.listener.NetworkPersistedBatchReadyListener; import com.flipkart.batching.listener.TagBatchReadyListener; import com.flipkart.batching.strategy.TagBatchingStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.batch.SizeBatch; -import com.flipkart.batchingcore.batch.SizeTimeBatch; -import com.flipkart.batchingcore.batch.TagBatch; -import com.flipkart.batchingcore.batch.TimeBatch; -import com.flipkart.batchingcore.data.EventData; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching_core.batch.SizeTimeBatch; +import com.flipkart.batching_core.batch.TagBatch; +import com.flipkart.batching_core.batch.TimeBatch; +import com.flipkart.batching_core.data.EventData; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import java.util.ArrayList; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java index bc62215..d70499e 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java @@ -34,9 +34,9 @@ import android.webkit.ValueCallback; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java index bf61dc4..87d2484 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java +++ b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java @@ -24,7 +24,7 @@ package com.flipkart.batching.listener; -import com.flipkart.batchingcore.Batch; +import com.flipkart.batching_core.Batch; /** * Persisted Batch Callback diff --git a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java index 4de2837..59b47ab 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java @@ -33,9 +33,9 @@ import com.flipkart.batching.tape.ObjectQueue; import com.flipkart.batching.toolbox.LenientFileObjectQueue; import com.flipkart.batching.toolbox.LenientQueueFile; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import org.jetbrains.annotations.Nullable; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java index 391ebe9..81be279 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java @@ -26,9 +26,9 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batchingcore.batch.TagBatch; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.batch.TagBatch; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import java.util.HashMap; import java.util.Map; diff --git a/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java index b73b4e6..d99f928 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java @@ -27,9 +27,9 @@ import android.os.Handler; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java b/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java index a3314a2..0e95191 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java @@ -25,9 +25,9 @@ package com.flipkart.batching.persistence; import com.flipkart.batching.tape.FileObjectQueue; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import java.io.IOException; import java.io.OutputStream; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java b/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java index 369f2a7..3f978f2 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java @@ -25,9 +25,9 @@ package com.flipkart.batching.persistence; import com.flipkart.batching.tape.FileObjectQueue; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import java.io.IOException; import java.io.OutputStream; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java b/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java index bf89dd1..d142d5d 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java @@ -31,11 +31,11 @@ import android.database.sqlite.SQLiteOpenHelper; import android.text.TextUtils; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.exception.DeserializeException; -import com.flipkart.batchingcore.exception.SerializeException; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.exception.DeserializeException; +import com.flipkart.batching_core.exception.SerializeException; import java.util.ArrayList; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java index 6154685..a506bf1 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java @@ -24,7 +24,7 @@ package com.flipkart.batching.persistence; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Data; import java.util.ArrayList; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java index c3a302a..c19507f 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java @@ -24,7 +24,7 @@ package com.flipkart.batching.persistence; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Data; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java index a586c64..300d2b3 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java @@ -26,11 +26,11 @@ import android.content.Context; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.exception.DeserializeException; -import com.flipkart.batchingcore.exception.SerializeException; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.exception.DeserializeException; +import com.flipkart.batching_core.exception.SerializeException; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java index d4017df..7bef04a 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java @@ -24,9 +24,9 @@ package com.flipkart.batching.persistence; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import java.util.Collection; import java.util.Iterator; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java index e9d312a..f5011d2 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java @@ -29,9 +29,9 @@ import com.flipkart.batching.tape.ObjectQueue; import com.flipkart.batching.toolbox.LenientFileObjectQueue; import com.flipkart.batching.toolbox.LenientQueueFile; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java index 654c908..03e4aea 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java @@ -31,8 +31,8 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java index 8abfa3d..143999a 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java @@ -30,8 +30,8 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.SizeBatch; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java index 0173710..a4733a7 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java @@ -29,8 +29,8 @@ import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.SizeTimeBatch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.SizeTimeBatch; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java index ff27458..54d0096 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java @@ -29,11 +29,11 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.TagBatch; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.TagBatch; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import java.util.Collection; import java.util.Collections; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java index d6329b9..7b20506 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java @@ -30,8 +30,8 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.TimeBatch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.TimeBatch; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java b/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java index e3c5c99..aa8c426 100644 --- a/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java +++ b/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java @@ -31,9 +31,9 @@ import com.flipkart.batching.persistence.TagBasedPersistenceStrategy; import com.flipkart.batching.persistence.TapePersistenceStrategy; import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.data.Tag; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.data.Tag; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/batching/src/test/java/com/flipkart/Utils.java b/batching/src/test/java/com/flipkart/Utils.java index 25f66ca..429e322 100644 --- a/batching/src/test/java/com/flipkart/Utils.java +++ b/batching/src/test/java/com/flipkart/Utils.java @@ -24,10 +24,10 @@ package com.flipkart; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.data.EventData; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.data.EventData; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import java.util.ArrayList; diff --git a/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java b/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java index d410998..f0e4c68 100644 --- a/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java +++ b/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java @@ -40,11 +40,11 @@ import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; import com.flipkart.batching.tape.ObjectQueue; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.BatchImpl; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java index 3c93793..43ff1f3 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java @@ -36,12 +36,12 @@ import com.flipkart.batching.BaseTestClass; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.batch.SizeBatch; -import com.flipkart.batchingcore.exception.SerializeException; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching_core.exception.SerializeException; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.tape.ObjectQueue; diff --git a/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java index a1a6599..dc66fe8 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java @@ -34,12 +34,12 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.tape.QueueFile; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.batch.SizeBatch; -import com.flipkart.batchingcore.exception.SerializeException; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching_core.exception.SerializeException; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java index 7b8c9e6..6927eab 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java @@ -28,10 +28,10 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batchingcore.batch.SizeBatch; -import com.flipkart.batchingcore.batch.TagBatch; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching_core.batch.TagBatch; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.strategy.TagBatchingStrategy; diff --git a/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java index a2e4b1f..e003e9d 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java @@ -33,11 +33,11 @@ import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; import com.flipkart.batching.strategy.SizeBatchingStrategy; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.SizeBatch; -import com.flipkart.batchingcore.exception.SerializeException; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching_core.exception.SerializeException; import org.junit.After; import org.junit.Test; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java b/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java index 3e0c8f0..b43f78d 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java @@ -30,12 +30,12 @@ import com.flipkart.Utils; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.data.EventData; -import com.flipkart.batchingcore.exception.DeserializeException; -import com.flipkart.batchingcore.exception.SerializeException; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.data.EventData; +import com.flipkart.batching_core.exception.DeserializeException; +import com.flipkart.batching_core.exception.SerializeException; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java index 38b2d24..e553f85 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java @@ -25,7 +25,7 @@ package com.flipkart.batching.persistence; import com.flipkart.Utils; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Data; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java index 97c2181..7bb8230 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java @@ -30,9 +30,9 @@ import com.flipkart.batching.BaseTestClass; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java index 3f4d63f..29fb1fc 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java @@ -29,11 +29,11 @@ import com.flipkart.Utils; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.SerializationStrategy; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import org.junit.Assert; import org.junit.Test; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java index 0668d04..7e541c8 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java @@ -28,9 +28,9 @@ import com.flipkart.batching.BaseTestClass; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.utils.GsonSerializationStrategy; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.SerializationStrategy; +import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.SerializationStrategy; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java b/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java index bdeaa11..157b0ca 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java @@ -33,8 +33,8 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java index 2311180..7d9d997 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java @@ -31,9 +31,9 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.listener.PersistedBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.SizeBatch; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.SizeBatch; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java index 01f116f..06a0736 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java @@ -35,9 +35,9 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.SizeTimeBatch; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.SizeTimeBatch; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java index 03f3207..6957aea 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java @@ -33,12 +33,12 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.SizeBatch; -import com.flipkart.batchingcore.batch.TagBatch; -import com.flipkart.batchingcore.data.Tag; -import com.flipkart.batchingcore.data.TagData; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching_core.batch.TagBatch; +import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching_core.data.TagData; import com.flipkart.batching.persistence.InMemoryPersistenceStrategy; import com.flipkart.batching.persistence.SQLPersistenceStrategy; import com.flipkart.batching.persistence.TagBasedPersistenceStrategy; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java index 20996b9..8bad431 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java @@ -34,9 +34,9 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.listener.PersistedBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batchingcore.Batch; -import com.flipkart.batchingcore.Data; -import com.flipkart.batchingcore.batch.TimeBatch; +import com.flipkart.batching_core.Batch; +import com.flipkart.batching_core.Data; +import com.flipkart.batching_core.batch.TimeBatch; import junit.framework.Assert; From 51623f2755e42b8aa38ce695ba9011efe31cbad4 Mon Sep 17 00:00:00 2001 From: "anirudh.r" Date: Sat, 26 Nov 2016 18:43:49 +0530 Subject: [PATCH 41/41] #109 replaced _ in package name with . char --- .../com/flipkart/batchdemo/CustomTagData.java | 4 +-- .../java/com/flipkart/batchdemo/EventTag.java | 2 +- .../com/flipkart/batchdemo/MainActivity.java | 12 ++++---- .../ExampleInstrumentedTest.java | 4 +-- batching-core/src/main/AndroidManifest.xml | 2 +- .../core}/Batch.java | 2 +- .../core}/BatchImpl.java | 2 +- .../core}/Data.java | 4 +-- .../core}/DataCollection.java | 2 +- .../core}/SerializationStrategy.java | 6 ++-- .../core}/batch/SizeBatch.java | 6 ++-- .../core}/batch/SizeTimeBatch.java | 6 ++-- .../core}/batch/TagBatch.java | 10 +++---- .../core}/batch/TimeBatch.java | 6 ++-- .../core}/data/EventData.java | 4 +-- .../core}/data/Tag.java | 4 +-- .../core}/data/TagData.java | 4 +-- .../core}/exception/DeserializeException.java | 2 +- .../core}/exception/SerializeException.java | 2 +- .../com/flipkart/batching_core/Utils.java | 9 +++--- .../batching_core/batch/SizeBatchTest.java | 2 +- .../batch/SizeTimeBatchTest.java | 2 +- .../batching_core/batch/TagBatchTest.java | 4 +-- .../batching_core/batch/TimeBatchTest.java | 2 +- .../batching_core/data/BatchTest.java | 10 +++---- .../flipkart/batching_core/data/DataTest.java | 4 +-- .../flipkart/batching_core/data/TagTest.java | 2 +- .../exception/DeserializeExceptionTest.java | 2 +- .../exception/SerializeExceptionTest.java | 2 +- .../ExampleInstrumentedTest.java | 4 +-- batching-gson/src/main/AndroidManifest.xml | 2 +- .../gson}/GsonSerializationStrategy.java | 20 ++++++------- .../gson}/RuntimeTypeAdapterFactory.java | 2 +- .../gson}/utils/Deserializer.java | 6 ++-- .../gson}/utils/Serializer.java | 6 ++-- .../batching_gson/GsonSerializationTest.java | 30 +++++++++---------- .../com/flipkart/batching_gson/Utils.java | 10 +++---- .../flipkart/batching/BatchController.java | 6 ++-- .../com/flipkart/batching/BatchManager.java | 24 +++++++-------- .../flipkart/batching/BatchingStrategy.java | 4 +-- .../batching/OnBatchReadyListener.java | 4 +-- .../flipkart/batching/TagBatchManager.java | 22 +++++++------- .../NetworkPersistedBatchReadyListener.java | 6 ++-- .../listener/PersistedBatchCallback.java | 2 +- .../listener/PersistedBatchReadyListener.java | 6 ++-- .../listener/TagBatchReadyListener.java | 6 ++-- .../TrimPersistedBatchReadyListener.java | 6 ++-- .../persistence/BatchObjectConverter.java | 6 ++-- .../persistence/DataObjectConverter.java | 6 ++-- .../batching/persistence/DatabaseHelper.java | 10 +++---- .../InMemoryPersistenceStrategy.java | 2 +- .../persistence/PersistenceStrategy.java | 2 +- .../persistence/SQLPersistenceStrategy.java | 10 +++---- .../TagBasedPersistenceStrategy.java | 6 ++-- .../persistence/TapePersistenceStrategy.java | 6 ++-- .../strategy/BaseBatchingStrategy.java | 4 +-- .../strategy/SizeBatchingStrategy.java | 4 +-- .../strategy/SizeTimeBatchingStrategy.java | 4 +-- .../strategy/TagBatchingStrategy.java | 10 +++---- .../strategy/TimeBatchingStrategy.java | 4 +-- .../toolbox/SizeTimeStrategyFactory.java | 6 ++-- .../src/test/java/com/flipkart/Utils.java | 8 ++--- .../flipkart/batching/BatchManagerTest.java | 10 +++---- .../NetworkPersistedBatchReadyTest.java | 12 ++++---- .../listener/PersistedBatchReadyTest.java | 12 ++++---- .../batching/listener/TagBatchReadyTest.java | 8 ++--- .../listener/TrimPersistedBatchReadyTest.java | 10 +++---- .../persistence/DatabaseHelperTest.java | 12 ++++---- .../persistence/InMemoryPersistenceTest.java | 2 +- .../persistence/SQLPersistenceTest.java | 6 ++-- .../persistence/TagBasedPersistenceTest.java | 10 +++---- .../persistence/TapePersistenceTest.java | 6 ++-- .../strategy/BaseBatchingStrategyTest.java | 4 +-- .../batching/strategy/SizeBatchingTest.java | 6 ++-- .../strategy/SizeTimeBatchingTest.java | 6 ++-- .../batching/strategy/TagBatchingTest.java | 12 ++++---- .../batching/strategy/TimeBatchingTest.java | 6 ++-- 77 files changed, 248 insertions(+), 251 deletions(-) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/Batch.java (97%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/BatchImpl.java (98%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/Data.java (96%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/DataCollection.java (98%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/SerializationStrategy.java (94%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/batch/SizeBatch.java (84%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/batch/SizeTimeBatch.java (89%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/batch/TagBatch.java (73%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/batch/TimeBatch.java (83%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/data/EventData.java (94%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/data/Tag.java (95%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/data/TagData.java (95%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/exception/DeserializeException.java (97%) rename batching-core/src/main/java/com/flipkart/{batching_core => batching/core}/exception/SerializeException.java (97%) rename batching-gson/src/main/java/com/flipkart/{batching_gson => batching/gson}/GsonSerializationStrategy.java (96%) rename batching-gson/src/main/java/com/flipkart/{batching_gson => batching/gson}/RuntimeTypeAdapterFactory.java (99%) rename batching-gson/src/main/java/com/flipkart/{batching_gson => batching/gson}/utils/Deserializer.java (88%) rename batching-gson/src/main/java/com/flipkart/{batching_gson => batching/gson}/utils/Serializer.java (86%) diff --git a/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java b/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java index 7a357fe..421b77e 100644 --- a/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java +++ b/app/src/main/java/com/flipkart/batchdemo/CustomTagData.java @@ -24,8 +24,8 @@ package com.flipkart.batchdemo; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import com.google.gson.annotations.SerializedName; import org.json.JSONObject; diff --git a/app/src/main/java/com/flipkart/batchdemo/EventTag.java b/app/src/main/java/com/flipkart/batchdemo/EventTag.java index 3760263..4ff5ae4 100644 --- a/app/src/main/java/com/flipkart/batchdemo/EventTag.java +++ b/app/src/main/java/com/flipkart/batchdemo/EventTag.java @@ -24,7 +24,7 @@ package com.flipkart.batchdemo; -import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching.core.data.Tag; import com.google.gson.annotations.SerializedName; public class EventTag extends Tag { diff --git a/app/src/main/java/com/flipkart/batchdemo/MainActivity.java b/app/src/main/java/com/flipkart/batchdemo/MainActivity.java index fcb753a..02be24d 100644 --- a/app/src/main/java/com/flipkart/batchdemo/MainActivity.java +++ b/app/src/main/java/com/flipkart/batchdemo/MainActivity.java @@ -47,12 +47,12 @@ import com.flipkart.batching.listener.TrimmedBatchCallback; import com.flipkart.batching.persistence.TapePersistenceStrategy; import com.flipkart.batching.strategy.SizeBatchingStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.batch.TagBatch; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; -import com.flipkart.batching_gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.batch.TagBatch; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; +import com.flipkart.batching.gson.GsonSerializationStrategy; import java.util.ArrayList; import java.util.Collections; diff --git a/batching-core/src/androidTest/java/com/flipkart/batching_core/ExampleInstrumentedTest.java b/batching-core/src/androidTest/java/com/flipkart/batching_core/ExampleInstrumentedTest.java index 3d82e26..7c5cc64 100644 --- a/batching-core/src/androidTest/java/com/flipkart/batching_core/ExampleInstrumentedTest.java +++ b/batching-core/src/androidTest/java/com/flipkart/batching_core/ExampleInstrumentedTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batching_core; +package com.flipkart.batching.core; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -21,6 +21,6 @@ public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); - assertEquals("com.flipkart.batching_core.test", appContext.getPackageName()); + assertEquals("com.flipkart.batching.core.test", appContext.getPackageName()); } } diff --git a/batching-core/src/main/AndroidManifest.xml b/batching-core/src/main/AndroidManifest.xml index e9b9871..d5ea95e 100644 --- a/batching-core/src/main/AndroidManifest.xml +++ b/batching-core/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.flipkart.batching.core"> diff --git a/batching-core/src/main/java/com/flipkart/batching_core/Batch.java b/batching-core/src/main/java/com/flipkart/batching/core/Batch.java similarity index 97% rename from batching-core/src/main/java/com/flipkart/batching_core/Batch.java rename to batching-core/src/main/java/com/flipkart/batching/core/Batch.java index 7503b21..00d46f0 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/Batch.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/Batch.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core; +package com.flipkart.batching.core; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/BatchImpl.java b/batching-core/src/main/java/com/flipkart/batching/core/BatchImpl.java similarity index 98% rename from batching-core/src/main/java/com/flipkart/batching_core/BatchImpl.java rename to batching-core/src/main/java/com/flipkart/batching/core/BatchImpl.java index 3058e65..5820a7f 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/BatchImpl.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/BatchImpl.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core; +package com.flipkart.batching.core; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/Data.java b/batching-core/src/main/java/com/flipkart/batching/core/Data.java similarity index 96% rename from batching-core/src/main/java/com/flipkart/batching_core/Data.java rename to batching-core/src/main/java/com/flipkart/batching/core/Data.java index 1d056fc..5a77280 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/Data.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/Data.java @@ -22,10 +22,10 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core; +package com.flipkart.batching.core; -import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching.core.data.Tag; import java.io.Serializable; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/DataCollection.java b/batching-core/src/main/java/com/flipkart/batching/core/DataCollection.java similarity index 98% rename from batching-core/src/main/java/com/flipkart/batching_core/DataCollection.java rename to batching-core/src/main/java/com/flipkart/batching/core/DataCollection.java index 1872f6a..b6f170f 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/DataCollection.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/DataCollection.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core; +package com.flipkart.batching.core; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/SerializationStrategy.java b/batching-core/src/main/java/com/flipkart/batching/core/SerializationStrategy.java similarity index 94% rename from batching-core/src/main/java/com/flipkart/batching_core/SerializationStrategy.java rename to batching-core/src/main/java/com/flipkart/batching/core/SerializationStrategy.java index 771ed4c..f99d706 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/SerializationStrategy.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/SerializationStrategy.java @@ -22,10 +22,10 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core; +package com.flipkart.batching.core; -import com.flipkart.batching_core.exception.DeserializeException; -import com.flipkart.batching_core.exception.SerializeException; +import com.flipkart.batching.core.exception.DeserializeException; +import com.flipkart.batching.core.exception.SerializeException; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/batch/SizeBatch.java b/batching-core/src/main/java/com/flipkart/batching/core/batch/SizeBatch.java similarity index 84% rename from batching-core/src/main/java/com/flipkart/batching_core/batch/SizeBatch.java rename to batching-core/src/main/java/com/flipkart/batching/core/batch/SizeBatch.java index 5a2090c..f7bcb3c 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/batch/SizeBatch.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/batch/SizeBatch.java @@ -1,8 +1,8 @@ -package com.flipkart.batching_core.batch; +package com.flipkart.batching.core.batch; -import com.flipkart.batching_core.BatchImpl; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.Data; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/batch/SizeTimeBatch.java b/batching-core/src/main/java/com/flipkart/batching/core/batch/SizeTimeBatch.java similarity index 89% rename from batching-core/src/main/java/com/flipkart/batching_core/batch/SizeTimeBatch.java rename to batching-core/src/main/java/com/flipkart/batching/core/batch/SizeTimeBatch.java index 5e1a065..0edc69c 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/batch/SizeTimeBatch.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/batch/SizeTimeBatch.java @@ -1,7 +1,7 @@ -package com.flipkart.batching_core.batch; +package com.flipkart.batching.core.batch; -import com.flipkart.batching_core.BatchImpl; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.Data; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/batch/TagBatch.java b/batching-core/src/main/java/com/flipkart/batching/core/batch/TagBatch.java similarity index 73% rename from batching-core/src/main/java/com/flipkart/batching_core/batch/TagBatch.java rename to batching-core/src/main/java/com/flipkart/batching/core/batch/TagBatch.java index 73a4ef9..94bc10d 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/batch/TagBatch.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/batch/TagBatch.java @@ -1,9 +1,9 @@ -package com.flipkart.batching_core.batch; +package com.flipkart.batching.core.batch; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; -import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; public class TagBatch extends BatchImpl { private Tag tag; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/batch/TimeBatch.java b/batching-core/src/main/java/com/flipkart/batching/core/batch/TimeBatch.java similarity index 83% rename from batching-core/src/main/java/com/flipkart/batching_core/batch/TimeBatch.java rename to batching-core/src/main/java/com/flipkart/batching/core/batch/TimeBatch.java index 8077d59..62facf5 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/batch/TimeBatch.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/batch/TimeBatch.java @@ -1,7 +1,7 @@ -package com.flipkart.batching_core.batch; +package com.flipkart.batching.core.batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.BatchImpl; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.Data; import java.util.Collection; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/data/EventData.java b/batching-core/src/main/java/com/flipkart/batching/core/data/EventData.java similarity index 94% rename from batching-core/src/main/java/com/flipkart/batching_core/data/EventData.java rename to batching-core/src/main/java/com/flipkart/batching/core/data/EventData.java index 2988424..ab4f8b2 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/data/EventData.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/data/EventData.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.data; +package com.flipkart.batching.core.data; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Data; /** * EventData class that extends {@link Data}. diff --git a/batching-core/src/main/java/com/flipkart/batching_core/data/Tag.java b/batching-core/src/main/java/com/flipkart/batching/core/data/Tag.java similarity index 95% rename from batching-core/src/main/java/com/flipkart/batching_core/data/Tag.java rename to batching-core/src/main/java/com/flipkart/batching/core/data/Tag.java index bcc96fa..723de17 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/data/Tag.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/data/Tag.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.data; +package com.flipkart.batching.core.data; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Data; import java.io.Serializable; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/data/TagData.java b/batching-core/src/main/java/com/flipkart/batching/core/data/TagData.java similarity index 95% rename from batching-core/src/main/java/com/flipkart/batching_core/data/TagData.java rename to batching-core/src/main/java/com/flipkart/batching/core/data/TagData.java index 634ab3d..fad687c 100644 --- a/batching-core/src/main/java/com/flipkart/batching_core/data/TagData.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/data/TagData.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.data; +package com.flipkart.batching.core.data; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Data; /** * TagData Class that extends {@link Data}. diff --git a/batching-core/src/main/java/com/flipkart/batching_core/exception/DeserializeException.java b/batching-core/src/main/java/com/flipkart/batching/core/exception/DeserializeException.java similarity index 97% rename from batching-core/src/main/java/com/flipkart/batching_core/exception/DeserializeException.java rename to batching-core/src/main/java/com/flipkart/batching/core/exception/DeserializeException.java index 1322456..97d4e1f 100755 --- a/batching-core/src/main/java/com/flipkart/batching_core/exception/DeserializeException.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/exception/DeserializeException.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.exception; +package com.flipkart.batching.core.exception; import java.io.IOException; diff --git a/batching-core/src/main/java/com/flipkart/batching_core/exception/SerializeException.java b/batching-core/src/main/java/com/flipkart/batching/core/exception/SerializeException.java similarity index 97% rename from batching-core/src/main/java/com/flipkart/batching_core/exception/SerializeException.java rename to batching-core/src/main/java/com/flipkart/batching/core/exception/SerializeException.java index cf535c1..1c73132 100755 --- a/batching-core/src/main/java/com/flipkart/batching_core/exception/SerializeException.java +++ b/batching-core/src/main/java/com/flipkart/batching/core/exception/SerializeException.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.exception; +package com.flipkart.batching.core.exception; import java.io.IOException; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/Utils.java b/batching-core/src/test/java/com/flipkart/batching_core/Utils.java index 0c75f4b..235a450 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/Utils.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/Utils.java @@ -22,11 +22,12 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core; +package com.flipkart.batching.core; -import com.flipkart.batching_core.data.EventData; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.data.EventData; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import java.util.ArrayList; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeBatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeBatchTest.java index 88e5504..eda3a74 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeBatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeBatchTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batching_core.batch; +package com.flipkart.batching.core.batch; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeTimeBatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeTimeBatchTest.java index e0fa909..5e2ce15 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeTimeBatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/batch/SizeTimeBatchTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batching_core.batch; +package com.flipkart.batching.core.batch; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/batch/TagBatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/batch/TagBatchTest.java index b48f91f..84305c8 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/batch/TagBatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/batch/TagBatchTest.java @@ -1,6 +1,6 @@ -package com.flipkart.batching_core.batch; +package com.flipkart.batching.core.batch; -import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching.core.data.Tag; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/batch/TimeBatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/batch/TimeBatchTest.java index b906a0f..d0b4edb 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/batch/TimeBatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/batch/TimeBatchTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batching_core.batch; +package com.flipkart.batching.core.batch; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/data/BatchTest.java b/batching-core/src/test/java/com/flipkart/batching_core/data/BatchTest.java index 1c09040..72a105d 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/data/BatchTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/data/BatchTest.java @@ -22,13 +22,13 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.data; +package com.flipkart.batching.core.data; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.BatchImpl; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.Utils; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.Utils; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/data/DataTest.java b/batching-core/src/test/java/com/flipkart/batching_core/data/DataTest.java index f400950..e205f5b 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/data/DataTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/data/DataTest.java @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.data; +package com.flipkart.batching.core.data; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Data; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/data/TagTest.java b/batching-core/src/test/java/com/flipkart/batching_core/data/TagTest.java index c78d94f..9778a4d 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/data/TagTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/data/TagTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.data; +package com.flipkart.batching.core.data; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/exception/DeserializeExceptionTest.java b/batching-core/src/test/java/com/flipkart/batching_core/exception/DeserializeExceptionTest.java index 20a2f97..27d4e42 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/exception/DeserializeExceptionTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/exception/DeserializeExceptionTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.exception; +package com.flipkart.batching.core.exception; import junit.framework.Assert; diff --git a/batching-core/src/test/java/com/flipkart/batching_core/exception/SerializeExceptionTest.java b/batching-core/src/test/java/com/flipkart/batching_core/exception/SerializeExceptionTest.java index a46f249..70eaa29 100644 --- a/batching-core/src/test/java/com/flipkart/batching_core/exception/SerializeExceptionTest.java +++ b/batching-core/src/test/java/com/flipkart/batching_core/exception/SerializeExceptionTest.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_core.exception; +package com.flipkart.batching.core.exception; import junit.framework.Assert; diff --git a/batching-gson/src/androidTest/java/com/flipkart/batching_gson/ExampleInstrumentedTest.java b/batching-gson/src/androidTest/java/com/flipkart/batching_gson/ExampleInstrumentedTest.java index b68ddd9..f8e558f 100644 --- a/batching-gson/src/androidTest/java/com/flipkart/batching_gson/ExampleInstrumentedTest.java +++ b/batching-gson/src/androidTest/java/com/flipkart/batching_gson/ExampleInstrumentedTest.java @@ -1,4 +1,4 @@ -package com.flipkart.batching_gson; +package com.flipkart.batching.gson; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -21,6 +21,6 @@ public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); - assertEquals("com.flipkart.batching_gson.test", appContext.getPackageName()); + assertEquals("com.flipkart.batching.gson.test", appContext.getPackageName()); } } diff --git a/batching-gson/src/main/AndroidManifest.xml b/batching-gson/src/main/AndroidManifest.xml index 37f7942..412b47d 100644 --- a/batching-gson/src/main/AndroidManifest.xml +++ b/batching-gson/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.flipkart.batching.gson"> diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/GsonSerializationStrategy.java b/batching-gson/src/main/java/com/flipkart/batching/gson/GsonSerializationStrategy.java similarity index 96% rename from batching-gson/src/main/java/com/flipkart/batching_gson/GsonSerializationStrategy.java rename to batching-gson/src/main/java/com/flipkart/batching/gson/GsonSerializationStrategy.java index df07e69..c5e280b 100644 --- a/batching-gson/src/main/java/com/flipkart/batching_gson/GsonSerializationStrategy.java +++ b/batching-gson/src/main/java/com/flipkart/batching/gson/GsonSerializationStrategy.java @@ -22,16 +22,16 @@ * THE SOFTWARE. */ -package com.flipkart.batching_gson; - -import com.flipkart.batching_gson.utils.Deserializer; -import com.flipkart.batching_gson.utils.Serializer; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.DataCollection; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.exception.DeserializeException; -import com.flipkart.batching_core.exception.SerializeException; +package com.flipkart.batching.gson; + +import com.flipkart.batching.gson.utils.Deserializer; +import com.flipkart.batching.gson.utils.Serializer; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.DataCollection; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.exception.DeserializeException; +import com.flipkart.batching.core.exception.SerializeException; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/RuntimeTypeAdapterFactory.java b/batching-gson/src/main/java/com/flipkart/batching/gson/RuntimeTypeAdapterFactory.java similarity index 99% rename from batching-gson/src/main/java/com/flipkart/batching_gson/RuntimeTypeAdapterFactory.java rename to batching-gson/src/main/java/com/flipkart/batching/gson/RuntimeTypeAdapterFactory.java index a7bee91..1815859 100644 --- a/batching-gson/src/main/java/com/flipkart/batching_gson/RuntimeTypeAdapterFactory.java +++ b/batching-gson/src/main/java/com/flipkart/batching/gson/RuntimeTypeAdapterFactory.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package com.flipkart.batching_gson; +package com.flipkart.batching.gson; import com.google.gson.Gson; import com.google.gson.JsonElement; diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/Deserializer.java b/batching-gson/src/main/java/com/flipkart/batching/gson/utils/Deserializer.java similarity index 88% rename from batching-gson/src/main/java/com/flipkart/batching_gson/utils/Deserializer.java rename to batching-gson/src/main/java/com/flipkart/batching/gson/utils/Deserializer.java index 75e83fb..fe036cf 100644 --- a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/Deserializer.java +++ b/batching-gson/src/main/java/com/flipkart/batching/gson/utils/Deserializer.java @@ -1,7 +1,7 @@ -package com.flipkart.batching_gson.utils; +package com.flipkart.batching.gson.utils; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.DataCollection; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.DataCollection; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; diff --git a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/Serializer.java b/batching-gson/src/main/java/com/flipkart/batching/gson/utils/Serializer.java similarity index 86% rename from batching-gson/src/main/java/com/flipkart/batching_gson/utils/Serializer.java rename to batching-gson/src/main/java/com/flipkart/batching/gson/utils/Serializer.java index ce2afab..04e9ce6 100644 --- a/batching-gson/src/main/java/com/flipkart/batching_gson/utils/Serializer.java +++ b/batching-gson/src/main/java/com/flipkart/batching/gson/utils/Serializer.java @@ -1,7 +1,7 @@ -package com.flipkart.batching_gson.utils; +package com.flipkart.batching.gson.utils; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.DataCollection; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.DataCollection; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; diff --git a/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java b/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java index 7877be9..357433f 100644 --- a/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java +++ b/batching-gson/src/test/java/com/flipkart/batching_gson/GsonSerializationTest.java @@ -22,21 +22,21 @@ * THE SOFTWARE. */ -package com.flipkart.batching_gson; - -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.BatchImpl; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.batch.SizeBatch; -import com.flipkart.batching_core.batch.SizeTimeBatch; -import com.flipkart.batching_core.batch.TagBatch; -import com.flipkart.batching_core.batch.TimeBatch; -import com.flipkart.batching_core.data.EventData; -import com.flipkart.batching_core.data.TagData; -import com.flipkart.batching_core.exception.DeserializeException; -import com.flipkart.batching_core.exception.SerializeException; +package com.flipkart.batching.gson; + +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.batch.SizeBatch; +import com.flipkart.batching.core.batch.SizeTimeBatch; +import com.flipkart.batching.core.batch.TagBatch; +import com.flipkart.batching.core.batch.TimeBatch; +import com.flipkart.batching.core.data.EventData; +import com.flipkart.batching.core.data.TagData; +import com.flipkart.batching.core.exception.DeserializeException; +import com.flipkart.batching.core.exception.SerializeException; import com.google.gson.JsonSyntaxException; import junit.framework.Assert; diff --git a/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java b/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java index 01b028d..aaa1a9a 100644 --- a/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java +++ b/batching-gson/src/test/java/com/flipkart/batching_gson/Utils.java @@ -22,12 +22,12 @@ * THE SOFTWARE. */ -package com.flipkart.batching_gson; +package com.flipkart.batching.gson; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.data.EventData; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.data.EventData; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import java.util.ArrayList; diff --git a/batching/src/main/java/com/flipkart/batching/BatchController.java b/batching/src/main/java/com/flipkart/batching/BatchController.java index 8f937a0..6da83a7 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchController.java +++ b/batching/src/main/java/com/flipkart/batching/BatchController.java @@ -26,9 +26,9 @@ import android.os.Handler; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/BatchManager.java b/batching/src/main/java/com/flipkart/batching/BatchManager.java index 9ad29ad..8b8ec7e 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchManager.java +++ b/batching/src/main/java/com/flipkart/batching/BatchManager.java @@ -28,20 +28,16 @@ import android.os.Handler; import android.os.HandlerThread; -import com.flipkart.batching.strategy.SizeBatchingStrategy; -import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; -import com.flipkart.batching.strategy.TagBatchingStrategy; -import com.flipkart.batching.strategy.TimeBatchingStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.BatchImpl; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.batch.SizeBatch; -import com.flipkart.batching_core.batch.SizeTimeBatch; -import com.flipkart.batching_core.batch.TagBatch; -import com.flipkart.batching_core.batch.TimeBatch; -import com.flipkart.batching_core.data.EventData; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.batch.SizeBatch; +import com.flipkart.batching.core.batch.SizeTimeBatch; +import com.flipkart.batching.core.batch.TagBatch; +import com.flipkart.batching.core.batch.TimeBatch; +import com.flipkart.batching.core.data.EventData; +import com.flipkart.batching.core.data.TagData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java index bc45814..7483d6d 100644 --- a/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/BatchingStrategy.java @@ -27,8 +27,8 @@ import android.content.Context; import android.os.Handler; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java index 9be0154..07c51bd 100644 --- a/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/OnBatchReadyListener.java @@ -25,8 +25,8 @@ package com.flipkart.batching; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; public interface OnBatchReadyListener> { void onReady(BatchingStrategy causingStrategy, T batch); diff --git a/batching/src/main/java/com/flipkart/batching/TagBatchManager.java b/batching/src/main/java/com/flipkart/batching/TagBatchManager.java index d21a28d..c0d7d34 100644 --- a/batching/src/main/java/com/flipkart/batching/TagBatchManager.java +++ b/batching/src/main/java/com/flipkart/batching/TagBatchManager.java @@ -31,17 +31,17 @@ import com.flipkart.batching.listener.NetworkPersistedBatchReadyListener; import com.flipkart.batching.listener.TagBatchReadyListener; import com.flipkart.batching.strategy.TagBatchingStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.BatchImpl; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.batch.SizeBatch; -import com.flipkart.batching_core.batch.SizeTimeBatch; -import com.flipkart.batching_core.batch.TagBatch; -import com.flipkart.batching_core.batch.TimeBatch; -import com.flipkart.batching_core.data.EventData; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.batch.SizeBatch; +import com.flipkart.batching.core.batch.SizeTimeBatch; +import com.flipkart.batching.core.batch.TagBatch; +import com.flipkart.batching.core.batch.TimeBatch; +import com.flipkart.batching.core.data.EventData; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import java.util.ArrayList; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java index d70499e..84919e1 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyListener.java @@ -34,9 +34,9 @@ import android.webkit.ValueCallback; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java index 87d2484..3b13bb8 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java +++ b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchCallback.java @@ -24,7 +24,7 @@ package com.flipkart.batching.listener; -import com.flipkart.batching_core.Batch; +import com.flipkart.batching.core.Batch; /** * Persisted Batch Callback diff --git a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java index 59b47ab..191db15 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/PersistedBatchReadyListener.java @@ -33,9 +33,9 @@ import com.flipkart.batching.tape.ObjectQueue; import com.flipkart.batching.toolbox.LenientFileObjectQueue; import com.flipkart.batching.toolbox.LenientQueueFile; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import org.jetbrains.annotations.Nullable; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java index 81be279..1f6c002 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/TagBatchReadyListener.java @@ -26,9 +26,9 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batching_core.batch.TagBatch; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.batch.TagBatch; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import java.util.HashMap; import java.util.Map; diff --git a/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java b/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java index d99f928..bae230a 100644 --- a/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java +++ b/batching/src/main/java/com/flipkart/batching/listener/TrimPersistedBatchReadyListener.java @@ -27,9 +27,9 @@ import android.os.Handler; import com.flipkart.batching.BatchingStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java b/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java index 0e95191..23126a8 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/BatchObjectConverter.java @@ -25,9 +25,9 @@ package com.flipkart.batching.persistence; import com.flipkart.batching.tape.FileObjectQueue; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import java.io.IOException; import java.io.OutputStream; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java b/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java index 3f978f2..20348f8 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/DataObjectConverter.java @@ -25,9 +25,9 @@ package com.flipkart.batching.persistence; import com.flipkart.batching.tape.FileObjectQueue; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import java.io.IOException; import java.io.OutputStream; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java b/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java index d142d5d..f3c0575 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/DatabaseHelper.java @@ -31,11 +31,11 @@ import android.database.sqlite.SQLiteOpenHelper; import android.text.TextUtils; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.exception.DeserializeException; -import com.flipkart.batching_core.exception.SerializeException; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.exception.DeserializeException; +import com.flipkart.batching.core.exception.SerializeException; import java.util.ArrayList; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java index a506bf1..2095616 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/InMemoryPersistenceStrategy.java @@ -24,7 +24,7 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Data; import java.util.ArrayList; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java index c19507f..695130d 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/PersistenceStrategy.java @@ -24,7 +24,7 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Data; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java index 300d2b3..2c3b6ff 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/SQLPersistenceStrategy.java @@ -26,11 +26,11 @@ import android.content.Context; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.exception.DeserializeException; -import com.flipkart.batching_core.exception.SerializeException; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.exception.DeserializeException; +import com.flipkart.batching.core.exception.SerializeException; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java index 7bef04a..6f49d6b 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/TagBasedPersistenceStrategy.java @@ -24,9 +24,9 @@ package com.flipkart.batching.persistence; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import java.util.Collection; import java.util.Iterator; diff --git a/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java b/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java index f5011d2..7989867 100644 --- a/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/persistence/TapePersistenceStrategy.java @@ -29,9 +29,9 @@ import com.flipkart.batching.tape.ObjectQueue; import com.flipkart.batching.toolbox.LenientFileObjectQueue; import com.flipkart.batching.toolbox.LenientQueueFile; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import org.slf4j.LoggerFactory; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java index 03e4aea..9a05c0e 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/BaseBatchingStrategy.java @@ -31,8 +31,8 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java index 143999a..713545a 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/SizeBatchingStrategy.java @@ -30,8 +30,8 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.SizeBatch; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java index a4733a7..2885300 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/SizeTimeBatchingStrategy.java @@ -29,8 +29,8 @@ import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.SizeTimeBatch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.SizeTimeBatch; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java index 54d0096..c90c6a1 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/TagBatchingStrategy.java @@ -29,11 +29,11 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.TagBatch; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.TagBatch; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import java.util.Collection; import java.util.Collections; diff --git a/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java b/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java index 7b20506..ea60cea 100644 --- a/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java +++ b/batching/src/main/java/com/flipkart/batching/strategy/TimeBatchingStrategy.java @@ -30,8 +30,8 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.TimeBatch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.TimeBatch; import java.util.Collection; diff --git a/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java b/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java index aa8c426..54a285a 100644 --- a/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java +++ b/batching/src/main/java/com/flipkart/batching/toolbox/SizeTimeStrategyFactory.java @@ -31,9 +31,9 @@ import com.flipkart.batching.persistence.TagBasedPersistenceStrategy; import com.flipkart.batching.persistence.TapePersistenceStrategy; import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.data.Tag; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.data.Tag; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/batching/src/test/java/com/flipkart/Utils.java b/batching/src/test/java/com/flipkart/Utils.java index 429e322..fe5c02a 100644 --- a/batching/src/test/java/com/flipkart/Utils.java +++ b/batching/src/test/java/com/flipkart/Utils.java @@ -24,10 +24,10 @@ package com.flipkart; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.data.EventData; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.data.EventData; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import java.util.ArrayList; diff --git a/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java b/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java index f0e4c68..142e796 100644 --- a/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java +++ b/batching/src/test/java/com/flipkart/batching/BatchManagerTest.java @@ -40,11 +40,11 @@ import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.strategy.SizeTimeBatchingStrategy; import com.flipkart.batching.tape.ObjectQueue; -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.BatchImpl; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.BatchImpl; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java index 43ff1f3..bdbad26 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/NetworkPersistedBatchReadyTest.java @@ -36,12 +36,12 @@ import com.flipkart.batching.BaseTestClass; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.batch.SizeBatch; -import com.flipkart.batching_core.exception.SerializeException; +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.batch.SizeBatch; +import com.flipkart.batching.core.exception.SerializeException; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.tape.ObjectQueue; diff --git a/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java index dc66fe8..03a6e28 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/PersistedBatchReadyTest.java @@ -34,12 +34,12 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.tape.QueueFile; -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.batch.SizeBatch; -import com.flipkart.batching_core.exception.SerializeException; +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.batch.SizeBatch; +import com.flipkart.batching.core.exception.SerializeException; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java index 6927eab..e4e2e3f 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/TagBatchReadyTest.java @@ -28,10 +28,10 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batching_core.batch.SizeBatch; -import com.flipkart.batching_core.batch.TagBatch; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.batch.SizeBatch; +import com.flipkart.batching.core.batch.TagBatch; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import com.flipkart.batching.strategy.SizeBatchingStrategy; import com.flipkart.batching.strategy.TagBatchingStrategy; diff --git a/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java b/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java index e003e9d..9664e6d 100644 --- a/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java +++ b/batching/src/test/java/com/flipkart/batching/listener/TrimPersistedBatchReadyTest.java @@ -33,11 +33,11 @@ import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; import com.flipkart.batching.strategy.SizeBatchingStrategy; -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.SizeBatch; -import com.flipkart.batching_core.exception.SerializeException; +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.SizeBatch; +import com.flipkart.batching.core.exception.SerializeException; import org.junit.After; import org.junit.Test; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java b/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java index b43f78d..46f1c11 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/DatabaseHelperTest.java @@ -30,12 +30,12 @@ import com.flipkart.Utils; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.data.EventData; -import com.flipkart.batching_core.exception.DeserializeException; -import com.flipkart.batching_core.exception.SerializeException; +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.data.EventData; +import com.flipkart.batching.core.exception.DeserializeException; +import com.flipkart.batching.core.exception.SerializeException; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java index e553f85..a25e6ce 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/InMemoryPersistenceTest.java @@ -25,7 +25,7 @@ package com.flipkart.batching.persistence; import com.flipkart.Utils; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Data; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java index 7bb8230..46fa865 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/SQLPersistenceTest.java @@ -30,9 +30,9 @@ import com.flipkart.batching.BaseTestClass; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java index 29fb1fc..6a5cdfc 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/TagBasedPersistenceTest.java @@ -29,11 +29,11 @@ import com.flipkart.Utils; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.SerializationStrategy; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.SerializationStrategy; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import org.junit.Assert; import org.junit.Test; diff --git a/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java b/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java index 7e541c8..62cd47d 100644 --- a/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java +++ b/batching/src/test/java/com/flipkart/batching/persistence/TapePersistenceTest.java @@ -28,9 +28,9 @@ import com.flipkart.batching.BaseTestClass; import com.flipkart.batching.BatchManager; import com.flipkart.batching.BuildConfig; -import com.flipkart.batching_gson.GsonSerializationStrategy; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.SerializationStrategy; +import com.flipkart.batching.gson.GsonSerializationStrategy; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.SerializationStrategy; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java b/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java index 157b0ca..d6a47b2 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/BaseBatchingStrategyTest.java @@ -33,8 +33,8 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java index 7d9d997..8bbf25b 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/SizeBatchingTest.java @@ -31,9 +31,9 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.listener.PersistedBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.SizeBatch; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.SizeBatch; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java index 06a0736..f4ca99c 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/SizeTimeBatchingTest.java @@ -35,9 +35,9 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.SizeTimeBatch; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.SizeTimeBatch; import junit.framework.Assert; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java index 6957aea..73c5dc9 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/TagBatchingTest.java @@ -33,12 +33,12 @@ import com.flipkart.batching.BatchingStrategy; import com.flipkart.batching.BuildConfig; import com.flipkart.batching.OnBatchReadyListener; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.SizeBatch; -import com.flipkart.batching_core.batch.TagBatch; -import com.flipkart.batching_core.data.Tag; -import com.flipkart.batching_core.data.TagData; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.SizeBatch; +import com.flipkart.batching.core.batch.TagBatch; +import com.flipkart.batching.core.data.Tag; +import com.flipkart.batching.core.data.TagData; import com.flipkart.batching.persistence.InMemoryPersistenceStrategy; import com.flipkart.batching.persistence.SQLPersistenceStrategy; import com.flipkart.batching.persistence.TagBasedPersistenceStrategy; diff --git a/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java b/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java index 8bad431..84621a8 100644 --- a/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java +++ b/batching/src/test/java/com/flipkart/batching/strategy/TimeBatchingTest.java @@ -34,9 +34,9 @@ import com.flipkart.batching.BuildConfig; import com.flipkart.batching.listener.PersistedBatchReadyListener; import com.flipkart.batching.persistence.PersistenceStrategy; -import com.flipkart.batching_core.Batch; -import com.flipkart.batching_core.Data; -import com.flipkart.batching_core.batch.TimeBatch; +import com.flipkart.batching.core.Batch; +import com.flipkart.batching.core.Data; +import com.flipkart.batching.core.batch.TimeBatch; import junit.framework.Assert;