Java Code Examples for org.apache.storm.tuple.Values#get()
The following examples show how to use
org.apache.storm.tuple.Values#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomProcessorBoltTest.java From streamline with Apache License 2.0 | 5 votes |
@Test public void testExecuteNull() throws ProcessingException { customProcessorBolt.outputSchema(map(outputStream, schema("A", "B"))); customProcessorBolt.inputSchemaMap(map("stream", map("A", "longfieldname"))); customProcessorBolt.customProcessorImpl(TestCP.class.getName()); customProcessorBolt.prepare(Collections.emptyMap(), mockTopologyContext, mockOutputCollector); StreamlineEvent event = StreamlineEventImpl.builder() .fieldsAndValues(map("longfieldname", "val")) .dataSourceId("dsrcid") .build(); new Expectations() {{ tuple.getSourceComponent(); returns("datasource"); tuple.getSourceStreamId(); returns("stream"); tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT); returns(event); mockTopologyContext.getThisComponentId(); returns("foo-bar"); }}; customProcessorBolt.execute(tuple); new Verifications() {{ Values actualValues; mockOutputCollector.emit(outputStream, tuple, actualValues = withCapture()); times = 1; assertEquals(1, actualValues.size()); assertTrue(actualValues.get(0) instanceof StreamlineEvent); StreamlineEvent output = (StreamlineEvent) actualValues.get(0); assertEquals(1, output.size()); assertEquals("val", output.get("A")); }}; }
Example 2
Source File: MetronErrorJSONMatcher.java From metron with Apache License 2.0 | 5 votes |
@Override public boolean matches(Values values) { JSONObject actual = (JSONObject) values.get(0); actual.remove("timestamp"); expected.remove("timestamp"); actual.remove("stack"); expected.remove("stack"); actual.remove("guid"); expected.remove("guid"); return actual.equals(expected); }
Example 3
Source File: GenericEnrichmentBoltTest.java From metron with Apache License 2.0 | 5 votes |
@Override public boolean matches(Values values) { String actualKey = (String) values.get(0); JSONObject actualMessage = (JSONObject) values.get(1); removeTimingFields(actualMessage); return expectedKey.equals(actualKey) && expectedMessage.equals(actualMessage); }
Example 4
Source File: HBaseEmitterTest.java From metron with Apache License 2.0 | 5 votes |
/** * Verifies that the emitter does emit a {@code ProfileMeasurement}. * * @return The {@code ProfileMeasurement} that was emitted */ private ProfileMeasurement expectMeasurement(HBaseEmitter hbaseEmitter, OutputCollector collector) { ArgumentCaptor<Values> arg = ArgumentCaptor.forClass(Values.class); verify(collector, times(1)).emit(eq(hbaseEmitter.getStreamId()), arg.capture()); Values values = arg.getValue(); assertTrue(values.get(0) instanceof ProfileMeasurement); return (ProfileMeasurement) values.get(0); }
Example 5
Source File: KafkaEmitterTest.java From metron with Apache License 2.0 | 5 votes |
/** * Verifies that the KafkaEmitter does emit a JSONObject. * @return The JSONObject that was emitted */ private JSONObject expectJsonObject(KafkaEmitter kafkaEmitter, OutputCollector collector) { ArgumentCaptor<Values> arg = ArgumentCaptor.forClass(Values.class); verify(collector, times(1)).emit(eq(kafkaEmitter.getStreamId()), arg.capture()); Values values = arg.getValue(); assertTrue(values.get(0) instanceof JSONObject); return (JSONObject) values.get(0); }