@Test
public void testModifyNetwork() {

    // Create some networks
    testCreateNetwork();
    // Modify net2 to add a gateway
    vns.createNetwork(guid2, net2, IPv4Address.of(gw1));
    assertTrue(vns.nameToGuid.get(net2).equals(guid2));
    assertTrue(vns.guidToGateway.get(guid2).equals(IPv4Address.of(gw1)));
    assertTrue(vns.gatewayToGuid.get(IPv4Address.of(gw1)).contains(guid1));
    assertTrue(vns.gatewayToGuid.get(IPv4Address.of(gw1)).contains(guid2));
    assertTrue(vns.gatewayToGuid.get(IPv4Address.of(gw1)).contains(guid3));
    assertTrue(vns.gatewayToGuid.get(IPv4Address.of(gw1)).size() == 3);
    // Modify net2 to change it's name
    vns.createNetwork(guid2, "newnet2", null);
    // Make sure the gateway is still there
    assertTrue(vns.gatewayToGuid.get(IPv4Address.of(gw1)).contains(guid2));
    assertTrue(vns.vNetsByGuid.get(guid2).gateway.equals(gw1));
    // make sure the new name mapping was learned
    assertTrue(vns.nameToGuid.get("newnet2").equals(guid2));
    assertTrue(vns.vNetsByGuid.get(guid2).name.equals("newnet2"));
    // and the old one was deleted
    assertFalse(vns.nameToGuid.containsKey(net2));
}