ConfigurableIngestTopology { String getSubscribingToComponent( String prevComponent, Map<Integer, String> boltNumberToId, Configuration boltConf) { int subscribingToBoltNumber = boltConf.getInt(SUBSCRIBE_TO_BOLT, -1); boolean isSubscribeToBoltDeclared = subscribingToBoltNumber >= 0; if (isSubscribeToBoltDeclared && boltNumberToId.containsKey(subscribingToBoltNumber)) return boltNumberToId.get(subscribingToBoltNumber); else return prevComponent; }  static void main(String[] args);  }
@Test public void testGetSubscribingToComponent0( @Injectable String prevComponent, @Injectable Map<Integer, String> boltNumberToId, @Injectable Configuration boltConf) { new Expectations() {{ boltConf.getInt(SUBSCRIBE_TO_BOLT, -1); result = -1; }}; String result = topology.getSubscribingToComponent(prevComponent, boltNumberToId, boltConf); assertThat(result, is(prevComponent)); }
@Test public void testGetSubscribingToComponent1( @Injectable String prevComponent, @Injectable String subscribedBolt, @Injectable Map<Integer, String> boltNumberToId, @Injectable Configuration boltConf) { int subscribedBoltNumber = 0; new Expectations() {{ boltConf.getInt(SUBSCRIBE_TO_BOLT, -1); result = subscribedBoltNumber; boltNumberToId.containsKey(subscribedBoltNumber); result = true; boltNumberToId.get(subscribedBoltNumber); result = subscribedBolt; }}; String result = topology.getSubscribingToComponent(prevComponent, boltNumberToId, boltConf); assertThat(result, is(subscribedBolt)); }
@Test public void testGetSubscribingToComponent2( @Injectable String prevComponent, @Injectable Map<Integer, String> boltNumberToId, @Injectable Configuration boltConf) { int subscribedBoltNumber = 0; new Expectations() {{ boltConf.getInt(SUBSCRIBE_TO_BOLT, -1); result = subscribedBoltNumber; boltNumberToId.containsKey(subscribedBoltNumber); result = false; }}; String result = topology.getSubscribingToComponent(prevComponent, boltNumberToId, boltConf); assertThat(result, is(prevComponent)); }