List of usage examples for org.apache.hadoop.io LongWritable LongWritable
public LongWritable(long value)
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_invalidRecord_DoesNotIncrementValidJsonRowCounter() throws IOException { mapDriver.withInput(new LongWritable(1), new Text("{not valid json")); mapDriver.run();//from w ww .ja va2 s . c om Assert.assertEquals(0, getCounter(KissmetricsConstants.TRACKING_COUNTER.VALID_JSON_ROW)); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_InvalidDate_IncrementsInvalidDateRowCounter() throws IOException { jsonRowbuilder.setValue("_t", "I am not a UNIX timestamp"); mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); mapDriver.run();//from ww w .j av a 2 s.c o m Assert.assertEquals(1, getCounter(KissmetricsConstants.TRACKING_COUNTER.INVALID_DATE)); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_InvalidDate_IncrementsInvalidJsonRowCounter() throws IOException { jsonRowbuilder.setValue("_t", "I am not a UNIX timestamp"); mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); mapDriver.run();// ww w.j a v a2s .co m Assert.assertEquals(1, getCounter(KissmetricsConstants.TRACKING_COUNTER.INVALID_JSON_ROW)); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_ValidRow_EnrichWithDateAndFileUsed() throws IOException, JSONException { mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile") .setValue("event", jsonRowbuilder.getValue("_n")).setValue("user_email", "justgiving@gmail.com") .setValue("user_email_back", "justgiving@gmail.com") .setValue("user_km_id", "3lwlxqlulqe24q/jl4aqlibrtte=").setValue("km_timestamp", "1397577453") .setValue("bucket", "somefile"); String expectedJSON = jsonRowbuilder.toString(); List<Pair<Text, Text>> output = mapDriver.run(); String actualJSON = output.get(0).getSecond().toString(); JSONAssert.assertEquals(expectedJSON, actualJSON, true); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_EmailAndID_emailIdData() throws IOException, JSONException { jsonRowbuilder.setValue("_p", "just@gmail.com").setValue("_p2", "22wlxqlulqe24q/jl4aqlibdfdfe="); mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); jsonRowbuilder.setValue("event", "viewed signup").setValue("user_email", "just@gmail.com") .setValue("user_email_back", "just@gmail.com") .setValue("user_km_id", "22wlxqlulqe24q/jl4aqlibdfdfe=") .setValue("event_timedate", "2014-04-15 16:57:33").setValue("km_timestamp", "1397577453") .setValue("filename", "somefile").setValue("bucket", "somefile"); String expectedJSON = jsonRowbuilder.toString(); List<Pair<Text, Text>> output = mapDriver.run(); String actualJSON = output.get(0).getSecond().toString(); JSONAssert.assertEquals(expectedJSON, actualJSON, true); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_EmailAndIDInverted_emailIdData() throws IOException, JSONException { jsonRowbuilder.setValue("_p2", "just@gmail.com").setValue("_p", "22wlxqlulqe24q/jl4aqlibdfdfe="); mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); jsonRowbuilder.setValue("event", "viewed signup").setValue("user_email", "just@gmail.com") .setValue("user_email_back", "just@gmail.com") .setValue("user_km_id", "22wlxqlulqe24q/jl4aqlibdfdfe=") .setValue("event_timedate", "2014-04-15 16:57:33").setValue("km_timestamp", "1397577453") .setValue("filename", "somefile").setValue("bucket", "somefile"); String expectedJSON = jsonRowbuilder.toString(); List<Pair<Text, Text>> output = mapDriver.run(); String actualJSON = output.get(0).getSecond().toString(); JSONAssert.assertEquals(expectedJSON, actualJSON, true); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_NoEmailAndID_IdData() throws IOException, JSONException { jsonRowbuilder.removePair("_p2").setValue("_p", "22wlxqlulqe24q/jl4aqlibdfdfe="); mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); jsonRowbuilder.setValue("event", "viewed signup").setValue("user_km_id", "22wlxqlulqe24q/jl4aqlibdfdfe=") .setValue("event_timedate", "2014-04-15 16:57:33").setValue("km_timestamp", "1397577453") .setValue("filename", "somefile").setValue("bucket", "somefile").setValue("bucket", "somefile"); String expectedJSON = jsonRowbuilder.toString(); List<Pair<Text, Text>> output = mapDriver.run(); String actualJSON = output.get(0).getSecond().toString(); JSONAssert.assertEquals(expectedJSON, actualJSON, true); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_NoEmailAndIDP2_IdData() throws IOException, JSONException { jsonRowbuilder.removePair("_p").setValue("_p2", "22wlxqlulqe24q/jl4aqlibdfdfe="); mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); jsonRowbuilder.setValue("event", "viewed signup").setValue("user_km_id", "22wlxqlulqe24q/jl4aqlibdfdfe=") .setValue("event_timedate", "2014-04-15 16:57:33").setValue("km_timestamp", "1397577453") .setValue("filename", "somefile").setValue("bucket", "somefile"); String expectedJSON = jsonRowbuilder.toString(); List<Pair<Text, Text>> output = mapDriver.run(); String actualJSON = output.get(0).getSecond().toString(); JSONAssert.assertEquals(expectedJSON, actualJSON, true); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_ValidRowEmailNoID_EmailEnrichWithDateAndFileUsed() throws IOException, JSONException { jsonRowbuilder.removePair("_p").setValue("_p2", "just@gmail.com"); mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile") .setValue("event", jsonRowbuilder.getValue("_n")).setValue("km_timestamp", "1397577453") .setValue("user_email", "just@gmail.com").setValue("user_email_back", "just@gmail.com") .setValue("bucket", "somefile"); String expectedJSON = jsonRowbuilder.toString(); List<Pair<Text, Text>> output = mapDriver.run(); String actualJSON = output.get(0).getSecond().toString(); JSONAssert.assertEquals(expectedJSON, actualJSON, true); }
From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java
License:Open Source License
@Test public void mapper_ValidRowEmailUpperCase_EmailLowerCaseEnrichWithDateAndFileUsed() throws IOException, JSONException { jsonRowbuilder.removePair("_p").setValue("_p2", "JusT@gmail.com"); mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString())); jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile") .setValue("event", jsonRowbuilder.getValue("_n")).setValue("km_timestamp", "1397577453") .setValue("user_email", "just@gmail.com").setValue("user_email_back", "just@gmail.com") .setValue("bucket", "somefile"); String expectedJSON = jsonRowbuilder.toString(); List<Pair<Text, Text>> output = mapDriver.run(); String actualJSON = output.get(0).getSecond().toString(); JSONAssert.assertEquals(expectedJSON, actualJSON, true); }