Program: 38005
Project: 38005
Buggy source:
/** 
 * BasicLinkDiscoveryTest will exercise the basics of Link Discovery test. The key results should show up in a kafka topic, which are dumped to file.
 */
@Test @Ignore public void basicLinkDiscoveryTest() throws IOException, ConfigurationException, CmdLineException {
  System.out.println("String_Node_Str");
  OFEventWFMTopology manager=new OFEventWFMTopology(makeLaunchEnvironment());
  TopologyConfig config=manager.getConfig();
  Tuple tuple;
  KeyValueState<String,Object> state=new InMemoryKeyValueState<>();
  initMocks();
  List<PathNode> nodes=Arrays.asList(new PathNode("String_Node_Str",1,0,10L),new PathNode("String_Node_Str",2,1,10L));
  InfoData data=new IslInfoData(10L,nodes,10000L,IslChangeType.DISCOVERED,9000L);
  String isl_discovered=MAPPER.writeValueAsString(data);
  OFELinkBolt linkBolt=new OFELinkBolt(config);
  linkBolt.prepare(stormConfig(),topologyContext,outputCollector);
  linkBolt.initState(state);
  ArrayList<DiscoveryFilterEntity> skipNodes=new ArrayList<>(1);
  skipNodes.add(new DiscoveryFilterEntity("String_Node_Str","String_Node_Str"));
  CommandMessage islFilterSetup=new CommandMessage(new DiscoveryFilterPopulateData(skipNodes),1,"String_Node_Str",Destination.WFM_OF_DISCOVERY);
  String json=MAPPER.writeValueAsString(islFilterSetup);
  tuple=new TupleImpl(topologyContext,Collections.singletonList(json),4,"String_Node_Str");
  linkBolt.execute(tuple);
  tuple=new TupleImpl(topologyContext,Arrays.asList("String_Node_Str",OFEMessageUtils.SWITCH_UP),0,InfoEventSplitterBolt.I_SWITCH_UPDOWN);
  linkBolt.execute(tuple);
  tuple=new TupleImpl(topologyContext,Arrays.asList("String_Node_Str",OFEMessageUtils.SWITCH_UP),0,InfoEventSplitterBolt.I_SWITCH_UPDOWN);
  linkBolt.execute(tuple);
  tuple=new TupleImpl(topologyContext,Arrays.asList("String_Node_Str","String_Node_Str",OFEMessageUtils.PORT_UP),1,InfoEventSplitterBolt.I_PORT_UPDOWN);
  linkBolt.execute(tuple);
  tuple=new TupleImpl(topologyContext,Arrays.asList("String_Node_Str","String_Node_Str",OFEMessageUtils.PORT_UP),1,InfoEventSplitterBolt.I_PORT_UPDOWN);
  linkBolt.execute(tuple);
  Tuple tickTuple=new TupleImpl(topologyContext,Collections.emptyList(),2,Constants.SYSTEM_TICK_STREAM_ID);
  linkBolt.execute(tickTuple);
  tuple=new TupleImpl(topologyContext,Collections.singletonList(isl_discovered),3,InfoEventSplitterBolt.I_ISL_UPDOWN);
  linkBolt.execute(tuple);
  linkBolt.execute(tickTuple);
  linkBolt.execute(tickTuple);
  messagesExpected=7;
  messagesReceived=outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
  Assert.assertEquals(messagesExpected,messagesReceived);
  messagesExpected=7;
  messagesReceived=outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
  Assert.assertEquals(messagesExpected,messagesReceived);
  linkBolt.execute(tickTuple);
  messagesExpected=7;
  messagesReceived=outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
  Assert.assertEquals(messagesExpected,messagesReceived);
  messagesExpected=7;
  messagesReceived=outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
  Assert.assertEquals(messagesExpected,messagesReceived);
}

Fixed version (ground truth):
/** 
 * BasicLinkDiscoveryTest will exercise the basics of Link Discovery test. The key results should show up in a kafka topic, which are dumped to file.
 */
@Test @Ignore public void basicLinkDiscoveryTest() throws IOException, ConfigurationException, CmdLineException {
  System.out.println("String_Node_Str");
  OFEventWFMTopology manager=new OFEventWFMTopology(makeLaunchEnvironment());
  TopologyConfig config=manager.getConfig();
  String topo_input_topic=config.getKafkaTopoDiscoTopic();
  Tuple tuple;
  KeyValueState<String,Object> state=new InMemoryKeyValueState<>();
  initMocks(topo_input_topic);
  List<PathNode> nodes=Arrays.asList(new PathNode("String_Node_Str",1,0,10L),new PathNode("String_Node_Str",2,1,10L));
  InfoData data=new IslInfoData(10L,nodes,10000L,IslChangeType.DISCOVERED,9000L);
  String isl_discovered=MAPPER.writeValueAsString(data);
  OFELinkBolt linkBolt=new OFELinkBolt(config);
  linkBolt.prepare(stormConfig(),topologyContext,outputCollector);
  linkBolt.initState(state);
  ArrayList<DiscoveryFilterEntity> skipNodes=new ArrayList<>(1);
  skipNodes.add(new DiscoveryFilterEntity("String_Node_Str","String_Node_Str"));
  CommandMessage islFilterSetup=new CommandMessage(new DiscoveryFilterPopulateData(skipNodes),1,"String_Node_Str",Destination.WFM_OF_DISCOVERY);
  String json=MAPPER.writeValueAsString(islFilterSetup);
  tuple=new TupleImpl(topologyContext,Collections.singletonList(json),4,"String_Node_Str");
  linkBolt.execute(tuple);
  tuple=new TupleImpl(topologyContext,Arrays.asList("String_Node_Str",OFEMessageUtils.SWITCH_UP),0,topo_input_topic);
  linkBolt.execute(tuple);
  tuple=new TupleImpl(topologyContext,Arrays.asList("String_Node_Str",OFEMessageUtils.SWITCH_UP),0,topo_input_topic);
  linkBolt.execute(tuple);
  tuple=new TupleImpl(topologyContext,Arrays.asList("String_Node_Str","String_Node_Str",OFEMessageUtils.PORT_UP),1,topo_input_topic);
  linkBolt.execute(tuple);
  tuple=new TupleImpl(topologyContext,Arrays.asList("String_Node_Str","String_Node_Str",OFEMessageUtils.PORT_UP),1,topo_input_topic);
  linkBolt.execute(tuple);
  Tuple tickTuple=new TupleImpl(topologyContext,Collections.emptyList(),2,Constants.SYSTEM_TICK_STREAM_ID);
  linkBolt.execute(tickTuple);
  tuple=new TupleImpl(topologyContext,Collections.singletonList(isl_discovered),3,topo_input_topic);
  linkBolt.execute(tuple);
  linkBolt.execute(tickTuple);
  linkBolt.execute(tickTuple);
  messagesExpected=7;
  messagesReceived=outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
  Assert.assertEquals(messagesExpected,messagesReceived);
  messagesExpected=7;
  messagesReceived=outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
  Assert.assertEquals(messagesExpected,messagesReceived);
  linkBolt.execute(tickTuple);
  messagesExpected=7;
  messagesReceived=outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
  Assert.assertEquals(messagesExpected,messagesReceived);
  messagesExpected=7;
  messagesReceived=outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
  Assert.assertEquals(messagesExpected,messagesReceived);
}