You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by th...@apache.org on 2016/05/18 20:41:58 UTC
[08/22] incubator-apex-malhar git commit: APEXMALHAR-2095 removed
checkstyle violations of malhar library module
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotTest.java
index 0cf03bc..8e827e0 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotTest.java
@@ -18,10 +18,11 @@
*/
package com.datatorrent.lib.appdata.schemas;
-import com.google.common.collect.Sets;
import org.junit.Assert;
import org.junit.Test;
+import com.google.common.collect.Sets;
+
public class DataQuerySnapshotTest
{
@Test
@@ -29,8 +30,7 @@ public class DataQuerySnapshotTest
{
Fields fields = new Fields(Sets.newHashSet("a", "b"));
- DataQuerySnapshot query = new DataQuerySnapshot("1",
- fields);
+ DataQuerySnapshot query = new DataQuerySnapshot("1", fields);
Assert.assertEquals("This query should be oneTime.", true, query.isOneTime());
}
@@ -40,9 +40,7 @@ public class DataQuerySnapshotTest
{
Fields fields = new Fields(Sets.newHashSet("a", "b"));
- DataQuerySnapshot query = new DataQuerySnapshot("1",
- fields,
- 1L);
+ DataQuerySnapshot query = new DataQuerySnapshot("1", fields, 1L);
Assert.assertEquals("This query should be oneTime.", false, query.isOneTime());
}
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataResultSnapshotSerializerTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataResultSnapshotSerializerTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataResultSnapshotSerializerTest.java
index fd99013..488f2bf 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataResultSnapshotSerializerTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataResultSnapshotSerializerTest.java
@@ -21,10 +21,6 @@ package com.datatorrent.lib.appdata.schemas;
import java.util.List;
import java.util.Map;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
import org.junit.Assert;
@@ -32,6 +28,10 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
import com.datatorrent.lib.appdata.gpo.GPOMutable;
import com.datatorrent.lib.appdata.query.serde.DataResultSnapshotSerializer;
@@ -43,16 +43,14 @@ public class DataResultSnapshotSerializerTest
public void simpleResultSerializerTest() throws Exception
{
List<GPOMutable> dataValues = createValues();
- DataQuerySnapshot gQuery = new DataQuerySnapshot("1",
- new Fields(Sets.newHashSet("a", "b")));
+ DataQuerySnapshot gQuery = new DataQuerySnapshot("1", new Fields(Sets.newHashSet("a", "b")));
- DataResultSnapshot result = new DataResultSnapshot(gQuery,
- dataValues);
+ DataResultSnapshot result = new DataResultSnapshot(gQuery, dataValues);
DataResultSnapshotSerializer serializer = new DataResultSnapshotSerializer();
- final String expectedJSONResult =
- "{\"id\":\"1\",\"type\":\"dataResult\",\"data\":[{\"b\":\"hello\",\"a\":\"1\"},{\"b\":\"world\",\"a\":\"2\"}]}";
+ final String expectedJSONResult = "{\"id\":\"1\",\"type\":\"dataResult\",\"data\":[{\"b\":\"hello\",\"a\":\"1\"}," +
+ "{\"b\":\"world\",\"a\":\"2\"}]}";
String resultJSON = serializer.serialize(result, new ResultFormatter());
JSONObject jo = new JSONObject(expectedJSONResult);
@@ -78,12 +76,9 @@ public class DataResultSnapshotSerializerTest
public void simpleCountdownTest() throws Exception
{
List<GPOMutable> dataValues = createValues();
- DataQuerySnapshot gQuery = new DataQuerySnapshot("1",
- new Fields(Sets.newHashSet("a", "b")));
+ DataQuerySnapshot gQuery = new DataQuerySnapshot("1", new Fields(Sets.newHashSet("a", "b")));
- DataResultSnapshot result = new DataResultSnapshot(gQuery,
- dataValues,
- 2);
+ DataResultSnapshot result = new DataResultSnapshot(gQuery, dataValues, 2);
DataResultSnapshotSerializer serializer = new DataResultSnapshotSerializer();
String resultJSON = serializer.serialize(result, new ResultFormatter());
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalConfigurationSchemaTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalConfigurationSchemaTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalConfigurationSchemaTest.java
index b3669bc..2306ae0 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalConfigurationSchemaTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalConfigurationSchemaTest.java
@@ -24,12 +24,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.codehaus.jettison.json.JSONArray;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.codehaus.jettison.json.JSONArray;
import org.apache.apex.malhar.lib.dimensions.DimensionsDescriptor;
import org.apache.apex.malhar.lib.dimensions.aggregator.AggregatorIncrementalType;
@@ -80,21 +80,22 @@ public class DimensionalConfigurationSchemaTest
final String valueName1Type = "double";
final String valueName2Type = "integer";
- final String jsonSchema =
- "{\"keys\":\n" +
- "[{\"name\":\"" + keyName1 + "\",\"type\":\"" + keyName1Type + "\"},\n" +
- "{\"name\":\"" + keyName2 + "\",\"type\":\"" + keyName2Type + "\"}],\n" +
- "\"values\":\n" +
- "[{\"name\":\"" + valueName1 + "\",\"type\":\"" + valueName1Type + "\"},\n" +
- "{\"name\":\"" + valueName2 + "\",\"type\":\"" + valueName2Type + "\"}],\n" +
- "\"timeBuckets\":[all]," +
- "\"dimensions\":\n" +
- "[{\"combination\":[\"" + keyName1 + "\",\"" + keyName2 + "\"],\"additionalValues\":[\"" + valueName1 + ":MIN\"," + "\"" + valueName1 + ":MAX\"]},\n" +
- "{\"combination\":[\"" + keyName1 + "\"],\"additionalValues\":[\"" + valueName2 + ":SUM\"," + "\"" + valueName2 + ":COUNT\"]}]\n" +
- "}";
+ final String jsonSchema = "{\"keys\":\n" +
+ "[{\"name\":\"" + keyName1 + "\",\"type\":\"" + keyName1Type + "\"},\n" +
+ "{\"name\":\"" + keyName2 + "\",\"type\":\"" + keyName2Type + "\"}],\n" +
+ "\"values\":\n" +
+ "[{\"name\":\"" + valueName1 + "\",\"type\":\"" + valueName1Type + "\"},\n" +
+ "{\"name\":\"" + valueName2 + "\",\"type\":\"" + valueName2Type + "\"}],\n" +
+ "\"timeBuckets\":[all]," +
+ "\"dimensions\":\n" +
+ "[{\"combination\":[\"" + keyName1 + "\",\"" + keyName2 + "\"],\"additionalValues\":[\"" + valueName1 +
+ ":MIN\"," + "\"" + valueName1 + ":MAX\"]},\n" +
+ "{\"combination\":[\"" + keyName1 + "\"],\"additionalValues\":[\"" + valueName2 + ":SUM\"," + "\"" +
+ valueName2 + ":COUNT\"]}]\n" +
+ "}";
DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(jsonSchema,
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
FieldsDescriptor allKeysDescriptor = des.getKeyDescriptor();
@@ -128,13 +129,13 @@ public class DimensionalConfigurationSchemaTest
logger.debug("map: {}", des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(0));
Assert.assertTrue("Incorrect aggregate fields.",
- des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(0).get("MIN").getFields().getFields().equals(minAggFields));
+ des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(0).get("MIN").getFields().getFields().equals(minAggFields));
Assert.assertTrue("Incorrect aggregate fields.",
- des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(0).get("MAX").getFields().getFields().equals(maxAggFields));
+ des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(0).get("MAX").getFields().getFields().equals(maxAggFields));
Assert.assertTrue("Incorrect aggregate fields.",
- des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(1).get("SUM").getFields().getFields().equals(sumAggFields));
+ des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(1).get("SUM").getFields().getFields().equals(sumAggFields));
Assert.assertTrue("Incorrect aggregate fields.",
- des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(1).get("COUNT").getFields().getFields().equals(countAggFields));
+ des.getDimensionsDescriptorIDToAggregatorToAggregateDescriptor().get(1).get("COUNT").getFields().getFields().equals(countAggFields));
final Map<String, Integer> aggToId = Maps.newHashMap();
aggToId.put("min", 0);
@@ -158,24 +159,26 @@ public class DimensionalConfigurationSchemaTest
final String valueName1Type = "double";
final String valueName2Type = "integer";
- final String jsonSchema =
- "{\"keys\":\n" +
- "[{\"name\":\"" + keyName1 + "\",\"type\":\"" + keyName1Type + "\"},\n" +
- "{\"name\":\"" + keyName2 + "\",\"type\":\"" + keyName2Type + "\"}],\n" +
- "\"values\":\n" +
- "[{\"name\":\"" + valueName1 + "\",\"type\":\"" + valueName1Type + "\"},\n" +
- "{\"name\":\"" + valueName2 + "\",\"type\":\"" + valueName2Type + "\"}],\n" +
- "\"timeBuckets\":[\"1m\"]," +
- "\"dimensions\":\n" +
- "[{\"combination\":[\"" + keyName1 + "\",\"" + keyName2 + "\"],\"additionalValues\":[\"" + valueName1 + ":COUNT\"" + "]},\n" + "]\n" +
- "}";
+ final String jsonSchema = "{\"keys\":\n" +
+ "[{\"name\":\"" + keyName1 + "\",\"type\":\"" + keyName1Type + "\"},\n" +
+ "{\"name\":\"" + keyName2 + "\",\"type\":\"" + keyName2Type + "\"}],\n" +
+ "\"values\":\n" +
+ "[{\"name\":\"" + valueName1 + "\",\"type\":\"" + valueName1Type + "\"},\n" +
+ "{\"name\":\"" + valueName2 + "\",\"type\":\"" + valueName2Type + "\"}],\n" +
+ "\"timeBuckets\":[\"1m\"]," +
+ "\"dimensions\":\n" +
+ "[{\"combination\":[\"" + keyName1 + "\",\"" + keyName2 + "\"],\"additionalValues\":[\"" + valueName1 +
+ ":COUNT\"" + "]},\n" + "]\n" +
+ "}";
DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(jsonSchema,
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
- FieldsDescriptor fd = des.getDimensionsDescriptorIDToAggregatorIDToOutputAggregatorDescriptor().get(0).get(AggregatorIncrementalType.NAME_TO_ORDINAL.get("COUNT"));
+ FieldsDescriptor fd = des.getDimensionsDescriptorIDToAggregatorIDToOutputAggregatorDescriptor().get(0).get(
+ AggregatorIncrementalType.NAME_TO_ORDINAL.get("COUNT"));
- Assert.assertEquals("Indexes for type compress fields should be 0", 0, (int) fd.getTypeToFieldToIndex().get(Type.LONG).get("valueName1"));
+ Assert.assertEquals("Indexes for type compress fields should be 0", 0,
+ (int)fd.getTypeToFieldToIndex().get(Type.LONG).get("valueName1"));
}
@Test
@@ -188,17 +191,17 @@ public class DimensionalConfigurationSchemaTest
final String valueName1Type = "double";
final String jsonSchema = "{\"keys\":\n" +
- "[{\"name\":\"" + keyName1 + "\",\"type\":\"" + keyName1Type + "\"}],\n" +
- "\"values\":\n" +
- "[{\"name\":\"" + valueName1 + "\",\"type\":\"" + valueName1Type + "\",\"aggregators\":[\"AVG\"]}],\n" +
- "\"timeBuckets\":[\"1m\"]," +
- "\"dimensions\":\n" +
- "[{\"combination\":[\"" + keyName1 + "\"]}]}";
+ "[{\"name\":\"" + keyName1 + "\",\"type\":\"" + keyName1Type + "\"}],\n" +
+ "\"values\":\n" +
+ "[{\"name\":\"" + valueName1 + "\",\"type\":\"" + valueName1Type + "\",\"aggregators\":[\"AVG\"]}],\n" +
+ "\"timeBuckets\":[\"1m\"]," +
+ "\"dimensions\":\n" +
+ "[{\"combination\":[\"" + keyName1 + "\"]}]}";
logger.debug("test schema:\n{}", jsonSchema);
DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(jsonSchema,
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
Assert.assertEquals(1, des.getDimensionsDescriptorIDToDimensionsDescriptor().size());
@@ -222,8 +225,9 @@ public class DimensionalConfigurationSchemaTest
@Test
public void getAllKeysDescriptorTest()
{
- DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(SchemaUtils.jarResourceFileToString("adsGenericEventSchema.json"),
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(
+ SchemaUtils.jarResourceFileToString("adsGenericEventSchema.json"),
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
Set<String> keys = Sets.newHashSet("publisher", "advertiser", "location");
@@ -233,8 +237,9 @@ public class DimensionalConfigurationSchemaTest
@Test
public void aggregationSchemaTest()
{
- DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(SchemaUtils.jarResourceFileToString("adsGenericEventSchemaAggregations.json"),
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(
+ SchemaUtils.jarResourceFileToString("adsGenericEventSchemaAggregations.json"),
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
Set<String> keys = Sets.newHashSet();
@@ -256,8 +261,9 @@ public class DimensionalConfigurationSchemaTest
@Test
public void simpleOTFTest()
{
- DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(SchemaUtils.jarResourceFileToString("adsGenericEventSchemaOTF.json"),
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(
+ SchemaUtils.jarResourceFileToString("adsGenericEventSchemaOTF.json"),
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
Assert.assertEquals(4, des.getDimensionsDescriptorIDToAggregatorIDs().get(0).size());
}
@@ -265,31 +271,29 @@ public class DimensionalConfigurationSchemaTest
@Test
public void testConstructorAgreement()
{
- DimensionalConfigurationSchema expectedEventSchema = new DimensionalConfigurationSchema(SchemaUtils.jarResourceFileToString("adsGenericEventSchemaAdditional.json"),
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ DimensionalConfigurationSchema expectedEventSchema = new DimensionalConfigurationSchema(
+ SchemaUtils.jarResourceFileToString("adsGenericEventSchemaAdditional.json"),
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
@SuppressWarnings("unchecked")
- List<Object> publisherEnumVals = (List<Object>) ((List) Lists.newArrayList("twitter","facebook","yahoo","google","bing","amazon"));
+ List<Object> publisherEnumVals = (List<Object>)((List)Lists.newArrayList("twitter", "facebook", "yahoo", "google",
+ "bing", "amazon"));
@SuppressWarnings("unchecked")
- List<Object> advertiserEnumVals = (List<Object>) ((List) Lists.newArrayList("starbucks","safeway","mcdonalds","macys","taco bell","walmart","khol's","san diego zoo","pandas","jack in the box","tomatina","ron swanson"));
+ List<Object> advertiserEnumVals = (List<Object>)((List)Lists.newArrayList("starbucks", "safeway", "mcdonalds",
+ "macys", "taco bell", "walmart", "khol's", "san diego zoo", "pandas", "jack in the box", "tomatina",
+ "ron swanson"));
@SuppressWarnings("unchecked")
- List<Object> locationEnumVals = (List<Object>) ((List) Lists.newArrayList("N","LREC","SKY","AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID"));
+ List<Object> locationEnumVals = (List<Object>)((List)Lists.newArrayList("N", "LREC", "SKY", "AL", "AK", "AZ", "AR",
+ "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID"));
List<Key> keys = Lists.newArrayList(new Key("publisher", Type.STRING, publisherEnumVals),
- new Key("advertiser", Type.STRING, advertiserEnumVals),
- new Key("location", Type.STRING, locationEnumVals));
+ new Key("advertiser", Type.STRING, advertiserEnumVals), new Key("location", Type.STRING, locationEnumVals));
+
List<TimeBucket> timeBuckets = Lists.newArrayList(TimeBucket.MINUTE, TimeBucket.HOUR, TimeBucket.DAY);
- List<Value> values = Lists.newArrayList(new Value("impressions",
- Type.LONG,
- Sets.newHashSet("SUM", "COUNT")),
- new Value("clicks",
- Type.LONG,
- Sets.newHashSet("SUM", "COUNT")),
- new Value("cost",
- Type.DOUBLE,
- Sets.newHashSet("SUM", "COUNT")),
- new Value("revenue",
- Type.DOUBLE,
- Sets.newHashSet("SUM", "COUNT")));
+
+ List<Value> values = Lists.newArrayList(new Value("impressions", Type.LONG, Sets.newHashSet("SUM", "COUNT")),
+ new Value("clicks", Type.LONG, Sets.newHashSet("SUM", "COUNT")),
+ new Value("cost", Type.DOUBLE, Sets.newHashSet("SUM", "COUNT")),
+ new Value("revenue", Type.DOUBLE, Sets.newHashSet("SUM", "COUNT")));
Map<String, Set<String>> valueToAggregators = Maps.newHashMap();
valueToAggregators.put("impressions", Sets.newHashSet("MIN", "MAX"));
@@ -300,29 +304,18 @@ public class DimensionalConfigurationSchemaTest
Set<String> emptySet = Sets.newHashSet();
Map<String, Set<String>> emptyMap = Maps.newHashMap();
- List<DimensionsCombination> dimensionsCombinations =
- Lists.newArrayList(new DimensionsCombination(new Fields(emptySet),
- emptyMap),
- new DimensionsCombination(new Fields(Sets.newHashSet("location")),
- emptyMap),
- new DimensionsCombination(new Fields(Sets.newHashSet("advertiser")),
- valueToAggregators),
- new DimensionsCombination(new Fields(Sets.newHashSet("publisher")),
- valueToAggregators),
- new DimensionsCombination(new Fields(Sets.newHashSet("advertiser", "location")),
- emptyMap),
- new DimensionsCombination(new Fields(Sets.newHashSet("publisher", "location")),
- emptyMap),
- new DimensionsCombination(new Fields(Sets.newHashSet("publisher", "advertiser")),
- emptyMap),
- new DimensionsCombination(new Fields(Sets.newHashSet("publisher", "advertiser", "location")),
- emptyMap));
+ List<DimensionsCombination> dimensionsCombinations = Lists.newArrayList(
+ new DimensionsCombination(new Fields(emptySet), emptyMap),
+ new DimensionsCombination(new Fields(Sets.newHashSet("location")), emptyMap),
+ new DimensionsCombination(new Fields(Sets.newHashSet("advertiser")), valueToAggregators),
+ new DimensionsCombination(new Fields(Sets.newHashSet("publisher")), valueToAggregators),
+ new DimensionsCombination(new Fields(Sets.newHashSet("advertiser", "location")), emptyMap),
+ new DimensionsCombination(new Fields(Sets.newHashSet("publisher", "location")), emptyMap),
+ new DimensionsCombination(new Fields(Sets.newHashSet("publisher", "advertiser")), emptyMap),
+ new DimensionsCombination(new Fields(Sets.newHashSet("publisher", "advertiser", "location")), emptyMap));
DimensionalConfigurationSchema eventSchema = new DimensionalConfigurationSchema(keys,
- values,
- timeBuckets,
- dimensionsCombinations,
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ values, timeBuckets, dimensionsCombinations, AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
logger.debug("expected {}", expectedEventSchema.getDimensionsDescriptorIDToValueToOTFAggregator());
logger.debug("actual {}", eventSchema.getDimensionsDescriptorIDToValueToOTFAggregator());
@@ -333,8 +326,9 @@ public class DimensionalConfigurationSchemaTest
@Test
public void testOTFAggregatorMap()
{
- DimensionalConfigurationSchema schema = new DimensionalConfigurationSchema(SchemaUtils.jarResourceFileToString("adsGenericEventSchemaOTF.json"),
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ DimensionalConfigurationSchema schema = new DimensionalConfigurationSchema(
+ SchemaUtils.jarResourceFileToString("adsGenericEventSchemaOTF.json"),
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
Set<String> otfAggregator = Sets.newHashSet("AVG");
Set<String> valueSet = Sets.newHashSet("impressions", "clicks", "cost", "revenue");
@@ -342,16 +336,14 @@ public class DimensionalConfigurationSchemaTest
List<Map<String, FieldsDescriptor>> aggregatorToDescriptor = schema.getDimensionsDescriptorIDToOTFAggregatorToAggregateDescriptor();
List<Map<String, Set<String>>> valueToAggregator = schema.getDimensionsDescriptorIDToValueToOTFAggregator();
- for(int ddId = 0;
- ddId < aggregatorToDescriptor.size();
- ddId++) {
+ for (int ddId = 0; ddId < aggregatorToDescriptor.size(); ddId++) {
Assert.assertEquals(otfAggregator, aggregatorToDescriptor.get(ddId).keySet());
Assert.assertNotNull(aggregatorToDescriptor.get(ddId).get("AVG"));
Assert.assertEquals(valueSet, valueToAggregator.get(ddId).keySet());
Map<String, Set<String>> tempValueToAgg = valueToAggregator.get(ddId);
- for(Map.Entry<String, Set<String>> entry: tempValueToAgg.entrySet()) {
+ for (Map.Entry<String, Set<String>> entry : tempValueToAgg.entrySet()) {
Assert.assertEquals(otfAggregator, entry.getValue());
}
}
@@ -366,12 +358,11 @@ public class DimensionalConfigurationSchemaTest
Assert.assertEquals(5, schema.getCustomTimeBuckets().size());
List<CustomTimeBucket> customTimeBuckets = Lists.newArrayList(new CustomTimeBucket(TimeBucket.MINUTE),
- new CustomTimeBucket(TimeBucket.HOUR),
- new CustomTimeBucket(TimeBucket.DAY),
- new CustomTimeBucket(TimeBucket.MINUTE, 5),
- new CustomTimeBucket(TimeBucket.HOUR, 3));
- Assert.assertEquals(customTimeBuckets,
- schema.getCustomTimeBuckets());
+ new CustomTimeBucket(TimeBucket.HOUR),
+ new CustomTimeBucket(TimeBucket.DAY),
+ new CustomTimeBucket(TimeBucket.MINUTE, 5),
+ new CustomTimeBucket(TimeBucket.HOUR, 3));
+ Assert.assertEquals(customTimeBuckets, schema.getCustomTimeBuckets());
Assert.assertEquals(40, schema.getDimensionsDescriptorIDToKeyDescriptor().size());
@@ -436,8 +427,9 @@ public class DimensionalConfigurationSchemaTest
public void testLoadingSchemaWithNoTimeBucket()
{
- DimensionalConfigurationSchema schema = new DimensionalConfigurationSchema(SchemaUtils.jarResourceFileToString("adsGenericEventSchemaNoTime.json"),
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ DimensionalConfigurationSchema schema = new DimensionalConfigurationSchema(
+ SchemaUtils.jarResourceFileToString("adsGenericEventSchemaNoTime.json"),
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
Assert.assertEquals(1, schema.getTimeBuckets().size());
Assert.assertEquals(TimeBucket.ALL, schema.getTimeBuckets().get(0));
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalSchemaTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalSchemaTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalSchemaTest.java
index 50b539e..8fe740b 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalSchemaTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DimensionalSchemaTest.java
@@ -24,6 +24,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONObject;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -31,8 +33,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.apex.malhar.lib.dimensions.aggregator.AggregatorRegistry;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -58,9 +58,9 @@ public class DimensionalSchemaTest
public void noEnumsTest()
{
//Test if creating schema with no enums works
- DimensionalConfigurationSchema des =
- new DimensionalConfigurationSchema(SchemaUtils.jarResourceFileToString("adsGenericEventSchemaNoEnums.json"),
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
+ DimensionalConfigurationSchema des = new DimensionalConfigurationSchema(
+ SchemaUtils.jarResourceFileToString("adsGenericEventSchemaNoEnums.json"),
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY);
}
@Test
@@ -76,20 +76,20 @@ public class DimensionalSchemaTest
@SuppressWarnings("unchecked")
List<Set<String>> dimensionCombinationsList = Lists.newArrayList((Set<String>)new HashSet<String>(),
- Sets.newHashSet("location"),
- Sets.newHashSet("advertiser"),
- Sets.newHashSet("publisher"),
- Sets.newHashSet("location", "advertiser"),
- Sets.newHashSet("location", "publisher"),
- Sets.newHashSet("advertiser", "publisher"),
- Sets.newHashSet("location", "advertiser", "publisher"));
+ Sets.newHashSet("location"),
+ Sets.newHashSet("advertiser"),
+ Sets.newHashSet("publisher"),
+ Sets.newHashSet("location", "advertiser"),
+ Sets.newHashSet("location", "publisher"),
+ Sets.newHashSet("advertiser", "publisher"),
+ Sets.newHashSet("location", "advertiser", "publisher"));
basicSchemaChecker(resultSchema,
- Lists.newArrayList(TimeBucket.ALL.getText()),
- Lists.newArrayList("publisher", "advertiser", "location"),
- Lists.newArrayList("string", "string", "string"),
- valueToType,
- dimensionCombinationsList);
+ Lists.newArrayList(TimeBucket.ALL.getText()),
+ Lists.newArrayList("publisher", "advertiser", "location"),
+ Lists.newArrayList("string", "string", "string"),
+ valueToType,
+ dimensionCombinationsList);
}
@Test
@@ -108,21 +108,16 @@ public class DimensionalSchemaTest
valueToType.put("revenue:SUM", "double");
@SuppressWarnings("unchecked")
- List<Set<String>> dimensionCombinationsList = Lists.newArrayList((Set<String>) new HashSet<String>(),
- Sets.newHashSet("location"),
- Sets.newHashSet("advertiser"),
- Sets.newHashSet("publisher"),
- Sets.newHashSet("location", "advertiser"),
- Sets.newHashSet("location", "publisher"),
- Sets.newHashSet("advertiser", "publisher"),
- Sets.newHashSet("location", "advertiser", "publisher"));
-
- basicSchemaChecker(resultSchema,
- timeBuckets,
- keyNames,
- keyTypes,
- valueToType,
- dimensionCombinationsList);
+ List<Set<String>> dimensionCombinationsList = Lists.newArrayList((Set<String>)new HashSet<String>(),
+ Sets.newHashSet("location"),
+ Sets.newHashSet("advertiser"),
+ Sets.newHashSet("publisher"),
+ Sets.newHashSet("location", "advertiser"),
+ Sets.newHashSet("location", "publisher"),
+ Sets.newHashSet("advertiser", "publisher"),
+ Sets.newHashSet("location", "advertiser", "publisher"));
+
+ basicSchemaChecker(resultSchema, timeBuckets, keyNames, keyTypes, valueToType, dimensionCombinationsList);
}
@Test
@@ -145,21 +140,16 @@ public class DimensionalSchemaTest
valueToType.put("revenue:COUNT", "long");
@SuppressWarnings("unchecked")
- List<Set<String>> dimensionCombinationsList = Lists.newArrayList((Set<String>) new HashSet<String>(),
- Sets.newHashSet("location"),
- Sets.newHashSet("advertiser"),
- Sets.newHashSet("publisher"),
- Sets.newHashSet("location", "advertiser"),
- Sets.newHashSet("location", "publisher"),
- Sets.newHashSet("advertiser", "publisher"),
- Sets.newHashSet("location", "advertiser", "publisher"));
+ List<Set<String>> dimensionCombinationsList = Lists.newArrayList((Set<String>)new HashSet<String>(),
+ Sets.newHashSet("location"),
+ Sets.newHashSet("advertiser"),
+ Sets.newHashSet("publisher"),
+ Sets.newHashSet("location", "advertiser"),
+ Sets.newHashSet("location", "publisher"),
+ Sets.newHashSet("advertiser", "publisher"),
+ Sets.newHashSet("location", "advertiser", "publisher"));
- basicSchemaChecker(resultSchema,
- timeBuckets,
- keyNames,
- keyTypes,
- valueToType,
- dimensionCombinationsList);
+ basicSchemaChecker(resultSchema, timeBuckets, keyNames, keyTypes, valueToType, dimensionCombinationsList);
Map<String, String> additionalValueMap = Maps.newHashMap();
additionalValueMap.put("impressions:MAX", "long");
@@ -172,21 +162,14 @@ public class DimensionalSchemaTest
additionalValueMap.put("revenue:MIN", "double");
@SuppressWarnings("unchecked")
- List<Map<String, String>> additionalValuesList = Lists.newArrayList((Map<String, String>) new HashMap<String, String>(),
- (Map<String, String>) new HashMap<String, String>(),
- additionalValueMap,
- additionalValueMap,
- (Map<String, String>) new HashMap<String, String>(),
- (Map<String, String>) new HashMap<String, String>(),
- (Map<String, String>) new HashMap<String, String>(),
- (Map<String, String>) new HashMap<String, String>());
+ List<Map<String, String>> additionalValuesList = Lists.newArrayList(new HashMap<String, String>(),
+ new HashMap<String, String>(), additionalValueMap, additionalValueMap, new HashMap<String, String>(),
+ new HashMap<String, String>(), new HashMap<String, String>(), new HashMap<String, String>());
JSONObject data = new JSONObject(resultSchema).getJSONArray("data").getJSONObject(0);
JSONArray dimensions = data.getJSONArray("dimensions");
- for(int index = 0;
- index < dimensions.length();
- index++) {
+ for (int index = 0; index < dimensions.length(); index++) {
JSONObject combination = dimensions.getJSONObject(index);
Map<String, String> tempAdditionalValueMap = additionalValuesList.get(index);
@@ -194,7 +177,7 @@ public class DimensionalSchemaTest
Set<String> additionalValueSet = Sets.newHashSet();
- if(tempAdditionalValueMap.isEmpty()) {
+ if (tempAdditionalValueMap.isEmpty()) {
continue;
}
@@ -202,9 +185,7 @@ public class DimensionalSchemaTest
LOG.debug("additionalValues {}", additionalValues);
- for(int aIndex = 0;
- aIndex < additionalValues.length();
- aIndex++) {
+ for (int aIndex = 0; aIndex < additionalValues.length(); aIndex++) {
JSONObject additionalValue = additionalValues.getJSONObject(aIndex);
String valueName = additionalValue.getString("name");
@@ -223,17 +204,16 @@ public class DimensionalSchemaTest
public void enumValUpdateTest() throws Exception
{
String eventSchemaJSON = SchemaUtils.jarResourceFileToString("adsGenericEventSchema.json");
- DimensionalSchema dimensional = new DimensionalSchema(
- new DimensionalConfigurationSchema(eventSchemaJSON,
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
+ DimensionalSchema dimensional = new DimensionalSchema(new DimensionalConfigurationSchema(eventSchemaJSON,
+ AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
Map<String, List<Object>> replacementEnums = Maps.newHashMap();
@SuppressWarnings("unchecked")
- List<Object> publisherEnumList = ((List<Object>) ((List) Lists.newArrayList("google", "twitter")));
+ List<Object> publisherEnumList = ((List<Object>)((List)Lists.newArrayList("google", "twitter")));
@SuppressWarnings("unchecked")
- List<Object> advertiserEnumList = ((List<Object>) ((List) Lists.newArrayList("google", "twitter")));
+ List<Object> advertiserEnumList = ((List<Object>)((List)Lists.newArrayList("google", "twitter")));
@SuppressWarnings("unchecked")
- List<Object> locationEnumList = ((List<Object>) ((List) Lists.newArrayList("google", "twitter")));
+ List<Object> locationEnumList = ((List<Object>)((List)Lists.newArrayList("google", "twitter")));
replacementEnums.put("publisher", publisherEnumList);
replacementEnums.put("advertiser", advertiserEnumList);
@@ -248,17 +228,13 @@ public class DimensionalSchemaTest
Map<String, List<Object>> newEnums = Maps.newHashMap();
- for(int keyIndex = 0;
- keyIndex < keys.length();
- keyIndex++) {
+ for (int keyIndex = 0; keyIndex < keys.length(); keyIndex++) {
JSONObject keyData = keys.getJSONObject(keyIndex);
String name = keyData.getString(DimensionalConfigurationSchema.FIELD_KEYS_NAME);
JSONArray enumValues = keyData.getJSONArray(DimensionalConfigurationSchema.FIELD_KEYS_ENUMVALUES);
List<Object> enumList = Lists.newArrayList();
- for(int enumIndex = 0;
- enumIndex < enumValues.length();
- enumIndex++) {
+ for (int enumIndex = 0; enumIndex < enumValues.length(); enumIndex++) {
enumList.add(enumValues.get(enumIndex));
}
@@ -274,16 +250,15 @@ public class DimensionalSchemaTest
{
String eventSchemaJSON = SchemaUtils.jarResourceFileToString("adsGenericEventSchema.json");
DimensionalSchema dimensional = new DimensionalSchema(
- new DimensionalConfigurationSchema(eventSchemaJSON,
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
+ new DimensionalConfigurationSchema(eventSchemaJSON, AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
Map<String, Set<Comparable>> replacementEnums = Maps.newHashMap();
@SuppressWarnings("unchecked")
- Set<Comparable> publisherEnumList = ((Set<Comparable>) ((Set) Sets.newHashSet("b", "c", "a")));
+ Set<Comparable> publisherEnumList = ((Set<Comparable>)((Set)Sets.newHashSet("b", "c", "a")));
@SuppressWarnings("unchecked")
- Set<Comparable> advertiserEnumList = ((Set<Comparable>) ((Set) Sets.newHashSet("b", "c", "a")));
+ Set<Comparable> advertiserEnumList = ((Set<Comparable>)((Set)Sets.newHashSet("b", "c", "a")));
@SuppressWarnings("unchecked")
- Set<Comparable> locationEnumList = ((Set<Comparable>) ((Set) Sets.newHashSet("b", "c", "a")));
+ Set<Comparable> locationEnumList = ((Set<Comparable>)((Set)Sets.newHashSet("b", "c", "a")));
replacementEnums.put("publisher", publisherEnumList);
replacementEnums.put("advertiser", advertiserEnumList);
@@ -291,11 +266,11 @@ public class DimensionalSchemaTest
Map<String, List<Comparable>> expectedOutput = Maps.newHashMap();
@SuppressWarnings("unchecked")
- List<Comparable> publisherEnumSortedList = (List<Comparable>) ((List) Lists.newArrayList("a", "b", "c"));
+ List<Comparable> publisherEnumSortedList = (List<Comparable>)((List)Lists.newArrayList("a", "b", "c"));
@SuppressWarnings("unchecked")
- List<Comparable> advertiserEnumSortedList = (List<Comparable>) ((List) Lists.newArrayList("a", "b", "c"));
+ List<Comparable> advertiserEnumSortedList = (List<Comparable>)((List)Lists.newArrayList("a", "b", "c"));
@SuppressWarnings("unchecked")
- List<Comparable> locationEnumSortedList = (List<Comparable>) ((List) Lists.newArrayList("a", "b", "c"));
+ List<Comparable> locationEnumSortedList = (List<Comparable>)((List)Lists.newArrayList("a", "b", "c"));
expectedOutput.put("publisher", publisherEnumSortedList);
expectedOutput.put("advertiser", advertiserEnumSortedList);
@@ -310,20 +285,15 @@ public class DimensionalSchemaTest
Map<String, List<Comparable>> newEnums = Maps.newHashMap();
- for(int keyIndex = 0;
- keyIndex < keys.length();
- keyIndex++) {
+ for (int keyIndex = 0; keyIndex < keys.length(); keyIndex++) {
JSONObject keyData = keys.getJSONObject(keyIndex);
String name = keyData.getString(DimensionalConfigurationSchema.FIELD_KEYS_NAME);
JSONArray enumValues = keyData.getJSONArray(DimensionalConfigurationSchema.FIELD_KEYS_ENUMVALUES);
List<Comparable> enumList = Lists.newArrayList();
- for(int enumIndex = 0;
- enumIndex < enumValues.length();
- enumIndex++) {
- enumList.add((Comparable) enumValues.get(enumIndex));
+ for (int enumIndex = 0; enumIndex < enumValues.length(); enumIndex++) {
+ enumList.add((Comparable)enumValues.get(enumIndex));
}
-
newEnums.put(name, enumList);
}
@@ -340,8 +310,7 @@ public class DimensionalSchemaTest
String eventSchemaJSON = SchemaUtils.jarResourceFileToString("adsGenericEventSchemaTags.json");
DimensionalSchema dimensional = new DimensionalSchema(
- new DimensionalConfigurationSchema(eventSchemaJSON,
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
+ new DimensionalConfigurationSchema(eventSchemaJSON, AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
String schemaJSON = dimensional.getSchemaJSON();
@@ -404,8 +373,8 @@ public class DimensionalSchemaTest
String eventSchemaJSON = SchemaUtils.jarResourceFileToString(resourceName);
MessageSerializerFactory dsf = new MessageSerializerFactory(new ResultFormatter());
- DimensionalSchema schemaDimensional = new DimensionalSchema(new DimensionalConfigurationSchema(eventSchemaJSON,
- AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
+ DimensionalSchema schemaDimensional = new DimensionalSchema(
+ new DimensionalConfigurationSchema(eventSchemaJSON, AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
SchemaQuery schemaQuery = new SchemaQuery("1");
@@ -424,12 +393,9 @@ public class DimensionalSchemaTest
return stringsArray;
}
- private void basicSchemaChecker(String resultSchema,
- List<String> timeBuckets,
- List<String> keyNames,
- List<String> keyTypes,
- Map<String, String> valueToType,
- List<Set<String>> dimensionCombinationsList) throws Exception
+ private void basicSchemaChecker(String resultSchema, List<String> timeBuckets, List<String> keyNames,
+ List<String> keyTypes, Map<String, String> valueToType, List<Set<String>> dimensionCombinationsList)
+ throws Exception
{
LOG.debug("Schema to check {}", resultSchema);
JSONObject schemaJO = new JSONObject(resultSchema);
@@ -439,17 +405,13 @@ public class DimensionalSchemaTest
Assert.assertEquals(timeBuckets.size(), jaBuckets.length());
- for(int index = 0;
- index < jaBuckets.length();
- index++) {
+ for (int index = 0; index < jaBuckets.length(); index++) {
Assert.assertEquals(timeBuckets.get(index), jaBuckets.get(index));
}
JSONArray keys = data.getJSONArray("keys");
- for(int index = 0;
- index < keys.length();
- index++) {
+ for (int index = 0; index < keys.length(); index++) {
JSONObject keyJO = keys.getJSONObject(index);
Assert.assertEquals(keyNames.get(index), keyJO.get("name"));
@@ -463,9 +425,7 @@ public class DimensionalSchemaTest
Set<String> valueNames = Sets.newHashSet();
- for(int index = 0;
- index < valuesArray.length();
- index++) {
+ for (int index = 0; index < valuesArray.length(); index++) {
JSONObject valueJO = valuesArray.getJSONObject(index);
String valueName = valueJO.getString("name");
@@ -481,17 +441,13 @@ public class DimensionalSchemaTest
JSONArray dimensions = data.getJSONArray("dimensions");
- for(int index = 0;
- index < dimensions.length();
- index++) {
+ for (int index = 0; index < dimensions.length(); index++) {
JSONObject combination = dimensions.getJSONObject(index);
JSONArray dimensionsCombinationArray = combination.getJSONArray("combination");
Set<String> dimensionCombination = Sets.newHashSet();
- for(int dimensionIndex = 0;
- dimensionIndex < dimensionsCombinationArray.length();
- dimensionIndex++) {
+ for (int dimensionIndex = 0; dimensionIndex < dimensionsCombinationArray.length(); dimensionIndex++) {
dimensionCombination.add(dimensionsCombinationArray.getString(dimensionIndex));
}
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/FieldsDescriptorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/FieldsDescriptorTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/FieldsDescriptorTest.java
index 53a3f96..843fb8d 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/FieldsDescriptorTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/FieldsDescriptorTest.java
@@ -23,13 +23,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.junit.Assert;
+import org.junit.Test;
+
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import org.junit.Assert;
-import org.junit.Test;
-
public class FieldsDescriptorTest
{
@Test
@@ -59,15 +59,15 @@ public class FieldsDescriptorTest
fieldToType.put(doubleField, Type.DOUBLE);
final List<String> expectedFieldList = Lists.newArrayList(boolField,
- charField,
- stringField,
- objectField,
- byteField,
- shortField,
- integerField,
- longField,
- floatField,
- doubleField);
+ charField,
+ stringField,
+ objectField,
+ byteField,
+ shortField,
+ integerField,
+ longField,
+ floatField,
+ doubleField);
final Fields expectedFields = new Fields(Sets.newHashSet(expectedFieldList));
final Set<Type> expectedTypes = Sets.newHashSet(fieldToType.values());
@@ -80,10 +80,8 @@ public class FieldsDescriptorTest
Assert.assertEquals(Sets.newHashSet(), fd.getCompressedTypes());
Assert.assertEquals(expectedFields, fd.getFields());
Assert.assertEquals(fieldToType, fd.getFieldToType());
- Assert.assertTrue(expectedTypes.containsAll(fd.getTypes()) &&
- fd.getTypes().containsAll(expectedTypes));
- Assert.assertTrue(fd.getTypesList().containsAll(expectedTypes) &&
- expectedTypes.containsAll(fd.getTypesList()));
+ Assert.assertTrue(expectedTypes.containsAll(fd.getTypes()) && fd.getTypes().containsAll(expectedTypes));
+ Assert.assertTrue(fd.getTypesList().containsAll(expectedTypes) && expectedTypes.containsAll(fd.getTypesList()));
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/ResultFormatterTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/ResultFormatterTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/ResultFormatterTest.java
index 5f2d924..10a5e56 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/ResultFormatterTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/ResultFormatterTest.java
@@ -53,10 +53,10 @@ public class ResultFormatterTest
final String expectedString = "1.00";
- Assert.assertEquals(expectedString, adf.format((byte) 1));
- Assert.assertEquals(expectedString, adf.format((short) 1));
+ Assert.assertEquals(expectedString, adf.format((byte)1));
+ Assert.assertEquals(expectedString, adf.format((short)1));
Assert.assertEquals(expectedString, adf.format(1));
- Assert.assertEquals(expectedString, adf.format((long) 1));
+ Assert.assertEquals(expectedString, adf.format((long)1));
}
@Test
@@ -76,14 +76,14 @@ public class ResultFormatterTest
final String discreteString = "1";
- Assert.assertEquals(discreteString, adf.format((byte) 1));
- Assert.assertEquals(discreteString, adf.format((short) 1));
+ Assert.assertEquals(discreteString, adf.format((byte)1));
+ Assert.assertEquals(discreteString, adf.format((short)1));
Assert.assertEquals(discreteString, adf.format(1));
- Assert.assertEquals(discreteString, adf.format((long) 1));
+ Assert.assertEquals(discreteString, adf.format((long)1));
final String continuousString = "1.0";
- Assert.assertEquals(continuousString, adf.format((float) 1));
- Assert.assertEquals(continuousString, adf.format((double) 1));
+ Assert.assertEquals(continuousString, adf.format((float)1));
+ Assert.assertEquals(continuousString, adf.format((double)1));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaQueryTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaQueryTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaQueryTest.java
index f0263d8..307cab0 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaQueryTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaQueryTest.java
@@ -20,11 +20,11 @@ package com.datatorrent.lib.appdata.schemas;
import java.util.Map;
-import com.google.common.collect.Maps;
-
import org.junit.Assert;
import org.junit.Test;
+import com.google.common.collect.Maps;
+
import com.datatorrent.lib.appdata.query.serde.MessageDeserializerFactory;
public class SchemaQueryTest
@@ -34,14 +34,14 @@ public class SchemaQueryTest
{
final String id = "12345";
final String schemaQueryJSON = "{" +
- "\"id\":\"" + id + "\"," +
- "\"type\":\"" + SchemaQuery.TYPE + "\"" +
- "}";
+ "\"id\":\"" + id + "\"," +
+ "\"type\":\"" + SchemaQuery.TYPE + "\"" +
+ "}";
@SuppressWarnings("unchecked")
MessageDeserializerFactory qb = new MessageDeserializerFactory(SchemaQuery.class);
- SchemaQuery schemaQuery = (SchemaQuery) qb.deserialize(schemaQueryJSON);
+ SchemaQuery schemaQuery = (SchemaQuery)qb.deserialize(schemaQueryJSON);
Assert.assertEquals("Id's must match", id, schemaQuery.getId());
Assert.assertEquals("Types must match", SchemaQuery.TYPE, schemaQuery.getType());
@@ -57,17 +57,17 @@ public class SchemaQueryTest
final String id = "12345";
final String schemaQueryJSON = "{" +
- "\"id\":\"" + id + "\"," +
- "\"type\":\"" + SchemaQuery.TYPE + "\"," +
- "\"context\":{" +
- "\"schemaKeys\":" +
- "{\"publisher\":\"google\",\"advertiser\":\"microsoft\",\"location\":\"CA\"}" +
- "}}";
+ "\"id\":\"" + id + "\"," +
+ "\"type\":\"" + SchemaQuery.TYPE + "\"," +
+ "\"context\":{" +
+ "\"schemaKeys\":" +
+ "{\"publisher\":\"google\",\"advertiser\":\"microsoft\",\"location\":\"CA\"}" +
+ "}}";
@SuppressWarnings("unchecked")
MessageDeserializerFactory qb = new MessageDeserializerFactory(SchemaQuery.class);
- SchemaQuery schemaQuery = (SchemaQuery) qb.deserialize(schemaQueryJSON);
+ SchemaQuery schemaQuery = (SchemaQuery)qb.deserialize(schemaQueryJSON);
Assert.assertEquals("Id's must match", id, schemaQuery.getId());
Assert.assertEquals("Types must match", SchemaQuery.TYPE, schemaQuery.getType());
@@ -88,18 +88,18 @@ public class SchemaQueryTest
final String id = "12345";
final String schemaQueryJSON = "{" +
- "\"id\":\"" + id + "\"," +
- "\"type\":\"" + SchemaQuery.TYPE + "\"," +
- "\"context\":{" +
- "\"schemaKeys\":" +
- "{\"publisher\":\"google\",\"advertiser\":\"microsoft\",\"location\":\"CA\"}," +
- "\"keys\":{\"publisher\":\"google\",\"advertiser\":\"microsoft\"}" +
- "}}";
+ "\"id\":\"" + id + "\"," +
+ "\"type\":\"" + SchemaQuery.TYPE + "\"," +
+ "\"context\":{" +
+ "\"schemaKeys\":" +
+ "{\"publisher\":\"google\",\"advertiser\":\"microsoft\",\"location\":\"CA\"}," +
+ "\"keys\":{\"publisher\":\"google\",\"advertiser\":\"microsoft\"}" +
+ "}}";
@SuppressWarnings("unchecked")
MessageDeserializerFactory qb = new MessageDeserializerFactory(SchemaQuery.class);
- SchemaQuery schemaQuery = (SchemaQuery) qb.deserialize(schemaQueryJSON);
+ SchemaQuery schemaQuery = (SchemaQuery)qb.deserialize(schemaQueryJSON);
Assert.assertEquals("Id's must match", id, schemaQuery.getId());
Assert.assertEquals("Types must match", SchemaQuery.TYPE, schemaQuery.getType());
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaRegistryMultipleTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaRegistryMultipleTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaRegistryMultipleTest.java
index 0513079..5504dda 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaRegistryMultipleTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaRegistryMultipleTest.java
@@ -21,12 +21,12 @@ package com.datatorrent.lib.appdata.schemas;
import java.util.Collections;
import java.util.Map;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
import org.junit.Assert;
import org.junit.Test;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
import com.datatorrent.lib.util.KryoCloneUtils;
public class SchemaRegistryMultipleTest
@@ -70,15 +70,13 @@ public class SchemaRegistryMultipleTest
Assert.assertEquals(SCHEMA_SALES_KEYS, tempSalesSchema.getSchemaKeys());
//Query schema for ads
- SchemaQuery schemaQueryAds = new SchemaQuery(id,
- SCHEMA_ADS_KEYS);
+ SchemaQuery schemaQueryAds = new SchemaQuery(id, SCHEMA_ADS_KEYS);
SchemaResult result = registry.getSchemaResult(schemaQueryAds);
Assert.assertEquals(1, result.getGenericSchemas().length);
Assert.assertEquals(SCHEMA_ADS_KEYS, result.getGenericSchemas()[0].getSchemaKeys());
//Query schema for sales
- SchemaQuery schemaQuerySales = new SchemaQuery(id,
- SCHEMA_SALES_KEYS);
+ SchemaQuery schemaQuerySales = new SchemaQuery(id, SCHEMA_SALES_KEYS);
result = registry.getSchemaResult(schemaQuerySales);
Assert.assertEquals(1, result.getGenericSchemas().length);
Assert.assertEquals(SCHEMA_SALES_KEYS, result.getGenericSchemas()[0].getSchemaKeys());
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaTestUtils.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaTestUtils.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaTestUtils.java
index 2c42879..26320ca 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaTestUtils.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaTestUtils.java
@@ -28,9 +28,7 @@ public class SchemaTestUtils
{
String[] result = new String[strings.length];
- for(int sc = 0;
- sc < strings.length;
- sc++) {
+ for (int sc = 0; sc < strings.length; sc++) {
result[sc] = left + strings[sc] + right;
}
@@ -41,9 +39,7 @@ public class SchemaTestUtils
{
String[] result = new String[strings.length];
- for(int sc = 0;
- sc < strings.length;
- sc++) {
+ for (int sc = 0; sc < strings.length; sc++) {
result[sc] = ws + strings[sc] + ws;
}
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaUtilsTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaUtilsTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaUtilsTest.java
index 3abee0b..5ae712f 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaUtilsTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SchemaUtilsTest.java
@@ -18,17 +18,17 @@
*/
package com.datatorrent.lib.appdata.schemas;
-import com.google.common.collect.Lists;
-import java.util.Map;
-
-import com.google.common.collect.Maps;
import java.util.List;
+import java.util.Map;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
public class SchemaUtilsTest
{
@Test
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/schemas/SnapshotSchemaTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SnapshotSchemaTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SnapshotSchemaTest.java
index b07c7e0..5fc5f4b 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/SnapshotSchemaTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/SnapshotSchemaTest.java
@@ -20,19 +20,19 @@ package com.datatorrent.lib.appdata.schemas;
import java.util.Map;
-import com.google.common.collect.Maps;
-
import org.junit.Assert;
import org.junit.Test;
+import com.google.common.collect.Maps;
+
public class SnapshotSchemaTest
{
public static final String TEST_JSON = "{\n"
- + " \"values\": [\n"
- + " {\"name\": \"url\", \"type\":\"string\"},\n"
- + " {\"name\": \"count\", \"type\":\"integer\"}\n"
- + " ]\n"
- + "}";
+ + " \"values\": [\n"
+ + " {\"name\": \"url\", \"type\":\"string\"},\n"
+ + " {\"name\": \"count\", \"type\":\"integer\"}\n"
+ + " ]\n"
+ + "}";
@Test
public void schemaSnapshotFieldTypeTest()
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerMapTest.java b/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerMapTest.java
index 96b348c..86ccb92 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerMapTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerMapTest.java
@@ -21,32 +21,36 @@ package com.datatorrent.lib.appdata.snapshot;
import java.util.List;
import java.util.Map;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
import org.codehaus.jettison.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
import com.datatorrent.lib.testbench.CollectorTestSink;
import com.datatorrent.lib.util.KryoCloneUtils;
public class AppDataSnapshotServerMapTest
{
- public static final String SIMPLE_RESULT = "{\"id\":\"1\",\"type\":\"dataQuery\",\"data\":[{\"count\":\"2\",\"word\":\"a\"},{\"count\":\"3\",\"word\":\"b\"}],\"countdown\":10}";
+ public static final String SIMPLE_RESULT = "{\"id\":\"1\"," +
+ "\"type\":\"dataQuery\",\"data\":[{\"count\":\"2\",\"word\":\"a\"},{\"count\":\"3\"," +
+ "\"word\":\"b\"}],\"countdown\":10}";
+
public static final String SIMPLE_QUERY = "{\"id\": \"1\",\n"
- + "\"type\": \"dataQuery\",\n"
- + "\"data\": {\n"
- + "\"fields\": [ \"word\", \"count\" ]\n"
- + "},\n"
- + "\"countdown\":10\n"
- + "}";
+ + "\"type\": \"dataQuery\",\n"
+ + "\"data\": {\n"
+ + "\"fields\": [ \"word\", \"count\" ]\n"
+ + "},\n"
+ + "\"countdown\":10\n"
+ + "}";
+
public static final String SIMPLE_SCHEMA = "{\n"
- + " \"values\": [{\"name\": \"word\", \"type\": \"string\"},\n"
- + " {\"name\": \"count\", \"type\": \"integer\"}]\n"
- + "}";
+ + " \"values\": [{\"name\": \"word\", \"type\": \"string\"},\n"
+ + " {\"name\": \"count\", \"type\": \"integer\"}]\n"
+ + "}";
@Test
public void simpleTest() throws Exception
@@ -73,7 +77,7 @@ public class AppDataSnapshotServerMapTest
CollectorTestSink<String> resultSink = new CollectorTestSink<String>();
@SuppressWarnings({"unchecked", "rawtypes"})
- CollectorTestSink<Object> tempResultSink = (CollectorTestSink) resultSink;
+ CollectorTestSink<Object> tempResultSink = (CollectorTestSink)resultSink;
snapshotServer.queryResult.setSink(tempResultSink);
snapshotServer.setup(null);
@@ -86,7 +90,7 @@ public class AppDataSnapshotServerMapTest
snapshotServer.query.put(SIMPLE_QUERY);
snapshotServer.endWindow();
- String result = (String) tempResultSink.collectedTuples.get(0);
+ String result = (String)tempResultSink.collectedTuples.get(0);
Assert.assertEquals("Should get only 1 result back", 1, tempResultSink.collectedTuples.size());
Assert.assertEquals("Countdown incorrect", 10, new JSONObject(result).getInt("countdown"));
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerPojoTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerPojoTest.java b/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerPojoTest.java
index a6cbf2b..6e8b0da 100644
--- a/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerPojoTest.java
+++ b/library/src/test/java/com/datatorrent/lib/appdata/snapshot/AppDataSnapshotServerPojoTest.java
@@ -21,15 +21,15 @@ package com.datatorrent.lib.appdata.snapshot;
import java.util.List;
import java.util.Map;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
import org.codehaus.jettison.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
import com.datatorrent.lib.appdata.schemas.DataQuerySnapshot;
import com.datatorrent.lib.appdata.schemas.SchemaUtils;
import com.datatorrent.lib.testbench.CollectorTestSink;
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/codec/JavaSerializationStreamCodecTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/codec/JavaSerializationStreamCodecTest.java b/library/src/test/java/com/datatorrent/lib/codec/JavaSerializationStreamCodecTest.java
index be432c8..a67e116 100644
--- a/library/src/test/java/com/datatorrent/lib/codec/JavaSerializationStreamCodecTest.java
+++ b/library/src/test/java/com/datatorrent/lib/codec/JavaSerializationStreamCodecTest.java
@@ -31,102 +31,102 @@ import com.datatorrent.netlet.util.Slice;
*/
public class JavaSerializationStreamCodecTest
{
- static class TestClass implements Serializable
- {
- private static final long serialVersionUID = 201301081743L;
- final String s;
- final int i;
-
- TestClass(String s, int i)
- {
- this.s = s;
- this.i = i;
- }
-
- TestClass()
- {
- s = "default!";
- i = Integer.MAX_VALUE;
- }
-
- @Override
- public int hashCode()
- {
- int hash = 7;
- hash = 97 * hash + (this.s != null ? this.s.hashCode() : 0);
- hash = 97 * hash + this.i;
- return hash;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final TestClass other = (TestClass) obj;
- if ((this.s == null) ? (other.s != null) : !this.s.equals(other.s)) {
- return false;
- }
- if (this.i != other.i) {
- return false;
- }
- return true;
- }
-
- }
-
- @Test
- public void testSomeMethod() throws IOException
- {
- JavaSerializationStreamCodec<Serializable> coder = new JavaSerializationStreamCodec<Serializable>();
- JavaSerializationStreamCodec<Serializable> decoder = new JavaSerializationStreamCodec<Serializable>();
-
- TestClass tc = new TestClass("hello!", 42);
-
- Slice dsp1 = coder.toByteArray(tc);
- Slice dsp2 = coder.toByteArray(tc);
- Assert.assertEquals(dsp1, dsp2);
-
- Object tcObject1 = decoder.fromByteArray(dsp1);
- assert (tc.equals(tcObject1));
-
- Object tcObject2 = decoder.fromByteArray(dsp2);
- assert (tc.equals(tcObject2));
-
- dsp1 = coder.toByteArray(tc);
- dsp2 = coder.toByteArray(tc);
- Assert.assertEquals(dsp1, dsp2);
- }
-
- public static class TestTuple implements Serializable
- {
- private static final long serialVersionUID = 201301081744L;
- final Integer finalField;
-
- @SuppressWarnings("unused")
- private TestTuple()
- {
- finalField = null;
- }
-
- public TestTuple(Integer i)
- {
- this.finalField = i;
- }
-
- }
-
- @Test
- public void testFinalFieldSerialization() throws Exception
- {
- TestTuple t1 = new TestTuple(5);
- JavaSerializationStreamCodec<Serializable> c = new JavaSerializationStreamCodec<Serializable>();
- Slice dsp = c.toByteArray(t1);
- TestTuple t2 = (TestTuple) c.fromByteArray(dsp);
- Assert.assertEquals("", t1.finalField, t2.finalField);
- }
+ static class TestClass implements Serializable
+ {
+ private static final long serialVersionUID = 201301081743L;
+ final String s;
+ final int i;
+
+ TestClass(String s, int i)
+ {
+ this.s = s;
+ this.i = i;
+ }
+
+ TestClass()
+ {
+ s = "default!";
+ i = Integer.MAX_VALUE;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hash = 7;
+ hash = 97 * hash + (this.s != null ? this.s.hashCode() : 0);
+ hash = 97 * hash + this.i;
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TestClass other = (TestClass)obj;
+ if ((this.s == null) ? (other.s != null) : !this.s.equals(other.s)) {
+ return false;
+ }
+ if (this.i != other.i) {
+ return false;
+ }
+ return true;
+ }
+
+ }
+
+ @Test
+ public void testSomeMethod() throws IOException
+ {
+ JavaSerializationStreamCodec<Serializable> coder = new JavaSerializationStreamCodec<Serializable>();
+ JavaSerializationStreamCodec<Serializable> decoder = new JavaSerializationStreamCodec<Serializable>();
+
+ TestClass tc = new TestClass("hello!", 42);
+
+ Slice dsp1 = coder.toByteArray(tc);
+ Slice dsp2 = coder.toByteArray(tc);
+ Assert.assertEquals(dsp1, dsp2);
+
+ Object tcObject1 = decoder.fromByteArray(dsp1);
+ assert (tc.equals(tcObject1));
+
+ Object tcObject2 = decoder.fromByteArray(dsp2);
+ assert (tc.equals(tcObject2));
+
+ dsp1 = coder.toByteArray(tc);
+ dsp2 = coder.toByteArray(tc);
+ Assert.assertEquals(dsp1, dsp2);
+ }
+
+ public static class TestTuple implements Serializable
+ {
+ private static final long serialVersionUID = 201301081744L;
+ final Integer finalField;
+
+ @SuppressWarnings("unused")
+ private TestTuple()
+ {
+ finalField = null;
+ }
+
+ public TestTuple(Integer i)
+ {
+ this.finalField = i;
+ }
+
+ }
+
+ @Test
+ public void testFinalFieldSerialization() throws Exception
+ {
+ TestTuple t1 = new TestTuple(5);
+ JavaSerializationStreamCodec<Serializable> c = new JavaSerializationStreamCodec<Serializable>();
+ Slice dsp = c.toByteArray(t1);
+ TestTuple t2 = (TestTuple)c.fromByteArray(dsp);
+ Assert.assertEquals("", t1.finalField, t2.finalField);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/converter/ByteArrayToStringConverterTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/converter/ByteArrayToStringConverterTest.java b/library/src/test/java/com/datatorrent/lib/converter/ByteArrayToStringConverterTest.java
index 99ae5b7..12f5d83 100644
--- a/library/src/test/java/com/datatorrent/lib/converter/ByteArrayToStringConverterTest.java
+++ b/library/src/test/java/com/datatorrent/lib/converter/ByteArrayToStringConverterTest.java
@@ -18,14 +18,16 @@
*/
package com.datatorrent.lib.converter;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-import com.datatorrent.lib.util.TestUtils;
import java.io.UnsupportedEncodingException;
+
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+import com.datatorrent.lib.util.TestUtils;
+
public class ByteArrayToStringConverterTest
{
@Test
@@ -69,5 +71,6 @@ public class ByteArrayToStringConverterTest
Assert.assertEquals(test1, testsink.collectedTuples.get(0));
}
+
private static final Logger logger = LoggerFactory.getLogger(ByteArrayToStringConverterTest.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/converter/MapToKeyValuePairConverterTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/converter/MapToKeyValuePairConverterTest.java b/library/src/test/java/com/datatorrent/lib/converter/MapToKeyValuePairConverterTest.java
index bbd5386..dd19d2b 100644
--- a/library/src/test/java/com/datatorrent/lib/converter/MapToKeyValuePairConverterTest.java
+++ b/library/src/test/java/com/datatorrent/lib/converter/MapToKeyValuePairConverterTest.java
@@ -27,8 +27,8 @@ import com.datatorrent.lib.testbench.CollectorTestSink;
import com.datatorrent.lib.util.KeyValPair;
import com.datatorrent.lib.util.TestUtils;
-public class MapToKeyValuePairConverterTest {
-
+public class MapToKeyValuePairConverterTest
+{
@Test
public void MapToKeyValuePairConversion()
{
@@ -37,10 +37,9 @@ public class MapToKeyValuePairConverterTest {
String[] keys = {"a", "b", "c"};
HashMap<String, Integer> inputMap = new HashMap<String, Integer>();
-
- for(int i =0 ; i < 3; i++)
- {
- inputMap.put(keys[i], values[i]);
+
+ for (int i = 0; i < 3; i++) {
+ inputMap.put(keys[i], values[i]);
}
CollectorTestSink<KeyValPair<String, Integer>> testsink = new CollectorTestSink<KeyValPair<String, Integer>>();
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/converter/StringValueToNumberConverterForMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/converter/StringValueToNumberConverterForMapTest.java b/library/src/test/java/com/datatorrent/lib/converter/StringValueToNumberConverterForMapTest.java
index fb1f605..8a5eed2 100644
--- a/library/src/test/java/com/datatorrent/lib/converter/StringValueToNumberConverterForMapTest.java
+++ b/library/src/test/java/com/datatorrent/lib/converter/StringValueToNumberConverterForMapTest.java
@@ -18,19 +18,17 @@
*/
package com.datatorrent.lib.converter;
-import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import org.junit.Assert;
import org.junit.Test;
import com.datatorrent.lib.testbench.CollectorTestSink;
-import com.datatorrent.lib.util.KeyValPair;
import com.datatorrent.lib.util.TestUtils;
-public class StringValueToNumberConverterForMapTest {
+public class StringValueToNumberConverterForMapTest
+{
@Test
public void testStringValueToNumericConversion()
@@ -40,10 +38,9 @@ public class StringValueToNumberConverterForMapTest {
String[] keys = {"a", "b", "c"};
HashMap<String, String> inputMap = new HashMap<String, String>();
-
- for(int i =0 ; i < 3; i++)
- {
- inputMap.put(keys[i], values[i]);
+
+ for (int i = 0; i < 3; i++) {
+ inputMap.put(keys[i], values[i]);
}
CollectorTestSink<Map<String, Number>> testsink = new CollectorTestSink<Map<String, Number>>();
@@ -56,15 +53,12 @@ public class StringValueToNumberConverterForMapTest {
testop.endWindow();
Assert.assertEquals(1,testsink.collectedTuples.size());
-
- int cnt = 0;
-
- Map<String, Number> output= testsink.collectedTuples.get(0);
-
- Assert.assertEquals(output.get("a"), 1.0);
- Assert.assertEquals(output.get("b"), 2.0);
- Assert.assertEquals(output.get("c"), 3.0);
-
-
+
+ Map<String, Number> output = testsink.collectedTuples.get(0);
+
+ Assert.assertEquals(output.get("a"), 1.0);
+ Assert.assertEquals(output.get("b"), 2.0);
+ Assert.assertEquals(output.get("c"), 3.0);
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/counters/BasicCountersTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/counters/BasicCountersTest.java b/library/src/test/java/com/datatorrent/lib/counters/BasicCountersTest.java
index 36416d6..b3c76d1 100644
--- a/library/src/test/java/com/datatorrent/lib/counters/BasicCountersTest.java
+++ b/library/src/test/java/com/datatorrent/lib/counters/BasicCountersTest.java
@@ -21,13 +21,13 @@ package com.datatorrent.lib.counters;
import java.util.List;
import java.util.Map;
-import com.google.common.collect.Lists;
-
import org.junit.Assert;
import org.junit.Test;
import org.apache.commons.lang.mutable.MutableDouble;
+import com.google.common.collect.Lists;
+
import com.datatorrent.common.util.NumberAggregate;
/**
@@ -69,7 +69,8 @@ public class BasicCountersTest
BasicCounters.DoubleAggregator<MutableDouble> aggregator = new BasicCounters.DoubleAggregator<MutableDouble>();
@SuppressWarnings("unchecked")
- Map<String, NumberAggregate.DoubleAggregate> aggregateMap = (Map<String, NumberAggregate.DoubleAggregate>) aggregator.aggregate(physicalCounters);
+ Map<String, NumberAggregate.DoubleAggregate> aggregateMap =
+ (Map<String, NumberAggregate.DoubleAggregate>)aggregator.aggregate(physicalCounters);
Assert.assertNotNull("null", aggregateMap.get(CounterKeys.A.name()));
NumberAggregate.DoubleAggregate aggregate = aggregateMap.get(CounterKeys.A.name());
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/db/KeyValueStoreOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/db/KeyValueStoreOperatorTest.java b/library/src/test/java/com/datatorrent/lib/db/KeyValueStoreOperatorTest.java
index 13ca6d6..90e67d6 100644
--- a/library/src/test/java/com/datatorrent/lib/db/KeyValueStoreOperatorTest.java
+++ b/library/src/test/java/com/datatorrent/lib/db/KeyValueStoreOperatorTest.java
@@ -24,11 +24,11 @@ import java.util.Map;
import org.junit.Assert;
-import com.datatorrent.lib.helper.OperatorContextTestHelper;
-
-import com.datatorrent.api.*;
-
+import com.datatorrent.api.DAG;
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.LocalMode;
import com.datatorrent.common.util.BaseOperator;
+import com.datatorrent.lib.helper.OperatorContextTestHelper;
/**
* @param <S>
@@ -55,7 +55,7 @@ public class KeyValueStoreOperatorTest<S extends KeyValueStore>
public void process(T t)
{
@SuppressWarnings("unchecked")
- Map<String, String> map = (Map<String, String>) t;
+ Map<String, String> map = (Map<String, String>)t;
resultMap.putAll(map);
resultCount++;
}
@@ -69,7 +69,7 @@ public class KeyValueStoreOperatorTest<S extends KeyValueStore>
@SuppressWarnings("unchecked")
public Map<String, String> convertToTuple(Map<Object, Object> o)
{
- return (Map<String, String>) (Map<?, ?>) o;
+ return (Map<String, String>)(Map<?, ?>)o;
}
}
@@ -80,7 +80,7 @@ public class KeyValueStoreOperatorTest<S extends KeyValueStore>
@SuppressWarnings("unchecked")
public void processTuple(Map<String, String> tuple)
{
- store.putAll((Map<Object, Object>) (Map<?, ?>) tuple);
+ store.putAll((Map<Object, Object>)(Map<?, ?>)tuple);
}
}
@@ -109,8 +109,7 @@ public class KeyValueStoreOperatorTest<S extends KeyValueStore>
Assert.assertEquals("456", CollectorModule.resultMap.get("test_def"));
Assert.assertEquals("123", CollectorModule.resultMap.get("test_ghi"));
- }
- finally {
+ } finally {
testStore.remove("test_abc");
testStore.remove("test_def");
testStore.remove("test_ghi");
@@ -140,8 +139,8 @@ public class KeyValueStoreOperatorTest<S extends KeyValueStore>
Assert.assertEquals("123", testStore.get("test_abc"));
Assert.assertEquals("456", testStore.get("test_def"));
Assert.assertEquals("789", testStore.get("test_ghi"));
- }
- finally {
+
+ } finally {
testStore.remove("test_abc");
testStore.remove("test_def");
testStore.remove("test_ghi");
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/3735316e/library/src/test/java/com/datatorrent/lib/db/TransactionableKeyValueStoreOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/db/TransactionableKeyValueStoreOperatorTest.java b/library/src/test/java/com/datatorrent/lib/db/TransactionableKeyValueStoreOperatorTest.java
index 416c3e5..d37863d 100644
--- a/library/src/test/java/com/datatorrent/lib/db/TransactionableKeyValueStoreOperatorTest.java
+++ b/library/src/test/java/com/datatorrent/lib/db/TransactionableKeyValueStoreOperatorTest.java
@@ -45,7 +45,7 @@ public class TransactionableKeyValueStoreOperatorTest<S extends TransactionableK
@SuppressWarnings("unchecked")
public void processTuple(Map<String, String> tuple)
{
- store.putAll((Map<Object, Object>) (Map<?, ?>) tuple);
+ store.putAll((Map<Object, Object>)(Map<?, ?>)tuple);
}
}
@@ -80,8 +80,7 @@ public class TransactionableKeyValueStoreOperatorTest<S extends TransactionableK
Assert.assertEquals("123", testStore.get("test_abc"));
Assert.assertEquals("456", testStore.get("test_def"));
Assert.assertEquals("789", testStore.get("test_ghi"));
- }
- finally {
+ } finally {
testStore.remove("test_abc");
testStore.remove("test_def");
testStore.remove("test_ghi");