Search in sources :

Example 1 with OutputFieldsDeclarer

use of org.apache.storm.topology.OutputFieldsDeclarer in project storm by apache.

the class TotalRankingsBoltTest method shouldDeclareOutputFields.

@Test
public void shouldDeclareOutputFields() {
    // given
    OutputFieldsDeclarer declarer = mock(OutputFieldsDeclarer.class);
    TotalRankingsBolt bolt = new TotalRankingsBolt();
    // when
    bolt.declareOutputFields(declarer);
    // then
    verify(declarer, times(1)).declare(any(Fields.class));
}
Also used : Fields(org.apache.storm.tuple.Fields) OutputFieldsDeclarer(org.apache.storm.topology.OutputFieldsDeclarer) Test(org.testng.annotations.Test)

Example 2 with OutputFieldsDeclarer

use of org.apache.storm.topology.OutputFieldsDeclarer in project storm by apache.

the class RollingCountBoltTest method shouldDeclareOutputFields.

@Test
public void shouldDeclareOutputFields() {
    // given
    OutputFieldsDeclarer declarer = mock(OutputFieldsDeclarer.class);
    RollingCountBolt bolt = new RollingCountBolt();
    // when
    bolt.declareOutputFields(declarer);
    // then
    verify(declarer, times(1)).declare(any(Fields.class));
}
Also used : Fields(org.apache.storm.tuple.Fields) OutputFieldsDeclarer(org.apache.storm.topology.OutputFieldsDeclarer) Test(org.testng.annotations.Test)

Example 3 with OutputFieldsDeclarer

use of org.apache.storm.topology.OutputFieldsDeclarer in project storm by apache.

the class EsLookupBoltTest method fieldsAreDeclaredThroughProvidedOutput.

@Test
public void fieldsAreDeclaredThroughProvidedOutput() throws Exception {
    Fields fields = new Fields(UUID.randomUUID().toString());
    when(output.fields()).thenReturn(fields);
    OutputFieldsDeclarer declarer = mock(OutputFieldsDeclarer.class);
    bolt.declareOutputFields(declarer);
    ArgumentCaptor<Fields> declaredFields = ArgumentCaptor.forClass(Fields.class);
    verify(declarer).declare(declaredFields.capture());
    assertThat(declaredFields.getValue(), is(fields));
}
Also used : Fields(org.apache.storm.tuple.Fields) OutputFieldsDeclarer(org.apache.storm.topology.OutputFieldsDeclarer) Test(org.junit.jupiter.api.Test)

Example 4 with OutputFieldsDeclarer

use of org.apache.storm.topology.OutputFieldsDeclarer in project kafka-spout by HolmesNL.

the class KafkaSpoutBufferBehaviourTest method testDeclarations.

@Test
public void testDeclarations() {
    final OutputFieldsDeclarer declarer = mock(OutputFieldsDeclarer.class);
    _subject.declareOutputFields(declarer);
    // verify the spout declares to output single-field tuples
    verify(declarer).declare(argThat(new ArgumentMatcher<Fields>() {

        @Override
        public boolean matches(final Object argument) {
            final Fields fields = (Fields) argument;
            return fields.size() == 1 && fields.get(0).equals("bytes");
        }
    }));
    // verify the spout will not provide component configuration
    assertNull(_subject.getComponentConfiguration());
}
Also used : Fields(org.apache.storm.tuple.Fields) ArgumentMatcher(org.mockito.ArgumentMatcher) OutputFieldsDeclarer(org.apache.storm.topology.OutputFieldsDeclarer) Test(org.junit.Test)

Example 5 with OutputFieldsDeclarer

use of org.apache.storm.topology.OutputFieldsDeclarer in project kafka-spout by HolmesNL.

the class KafkaSpoutConstructorTest method testRawSchemeForDefaultConstructor.

@Test
public void testRawSchemeForDefaultConstructor() {
    final KafkaSpout spout = spy(new KafkaSpout());
    final OutputFieldsDeclarer declarer = mock(OutputFieldsDeclarer.class);
    spout.declareOutputFields(declarer);
    // Fields doesn't implement equals; match it manually
    verify(declarer).declare(argThat(new ArgumentMatcher<Fields>() {

        @Override
        public boolean matches(final Object argument) {
            final Fields fields = (Fields) argument;
            return fields.size() == 1 && fields.get(0).equals("bytes");
        }
    }));
}
Also used : Fields(org.apache.storm.tuple.Fields) ArgumentMatcher(org.mockito.ArgumentMatcher) OutputFieldsDeclarer(org.apache.storm.topology.OutputFieldsDeclarer) Test(org.junit.Test)

Aggregations

OutputFieldsDeclarer (org.apache.storm.topology.OutputFieldsDeclarer)8 Fields (org.apache.storm.tuple.Fields)7 Test (org.junit.Test)4 ArgumentMatcher (org.mockito.ArgumentMatcher)3 Test (org.testng.annotations.Test)3 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Scheme (org.apache.storm.spout.Scheme)1 SpoutOutputCollector (org.apache.storm.spout.SpoutOutputCollector)1 TopologyContext (org.apache.storm.task.TopologyContext)1 IRichSpout (org.apache.storm.topology.IRichSpout)1 Test (org.junit.jupiter.api.Test)1