@Test
public void testCreateNetwork() {

    // Test creating a network with all parameters
    vns.createNetwork(guid1, net1, IPv4.toIPv4Address(gw1));
    assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).contains(guid1));
    assertTrue(vns.nameToGuid.get(net1).equals(guid1));
    assertTrue(vns.guidToGateway.get(guid1).equals(IPv4.toIPv4Address(gw1)));
    assertTrue(vns.vNetsByGuid.get(guid1).name.equals(net1));
    assertTrue(vns.vNetsByGuid.get(guid1).guid.equals(guid1));
    assertTrue(vns.vNetsByGuid.get(guid1).gateway.equals(gw1));
    assertTrue(vns.vNetsByGuid.get(guid1).hosts.size()==0);
    // Test creating network without a gateway
    vns.createNetwork(guid2, net2, null);
    assertTrue(vns.nameToGuid.get(net2).equals(guid2));
    assertTrue(vns.guidToGateway.get(guid2) == null);
    assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).size() == 1);
    assertTrue(vns.vNetsByGuid.get(guid2).name.equals(net2));
    assertTrue(vns.vNetsByGuid.get(guid2).guid.equals(guid2));
    assertTrue(vns.vNetsByGuid.get(guid2).gateway == null);
    assertTrue(vns.vNetsByGuid.get(guid2).hosts.size()==0);
    
    // Test creating a network that shares the gateway with net1
    vns.createNetwork(guid3, net3, IPv4.toIPv4Address(gw1));
    assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).contains(guid1));
    assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).contains(guid3));
    assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).size() == 2);
    assertTrue(vns.nameToGuid.get(net3).equals(guid3));
    assertTrue(vns.guidToGateway.get(guid3).equals(IPv4.toIPv4Address(gw1)));
    assertTrue(vns.vNetsByGuid.get(guid3).name.equals(net3));
    assertTrue(vns.vNetsByGuid.get(guid3).guid.equals(guid3));
    assertTrue(vns.vNetsByGuid.get(guid3).gateway.equals(gw1));
    assertTrue(vns.vNetsByGuid.get(guid3).hosts.size()==0);
}