@Test
public void testAddOrUpdateLink() throws Exception {

    LinkDiscoveryManager topology = getTopology();
    Link lt = new Link(1L, 2, 2L, 1);
    LinkInfo info = new LinkInfo(System.currentTimeMillis(),
                                 System.currentTimeMillis(), null,
                                 0, 0);
    topology.addOrUpdateLink(lt, info);
    NodePortTuple srcNpt = new NodePortTuple(1L, 2);
    NodePortTuple dstNpt = new NodePortTuple(2L, 1);
    // check invariants hold
    assertNotNull(topology.switchLinks.get(lt.getSrc()));
    assertTrue(topology.switchLinks.get(lt.getSrc()).contains(lt));
    assertNotNull(topology.portLinks.get(srcNpt));
    assertTrue(topology.portLinks.get(srcNpt).contains(lt));
    assertNotNull(topology.portLinks.get(dstNpt));
    assertTrue(topology.portLinks.get(dstNpt).contains(lt));
    assertTrue(topology.links.containsKey(lt));
}