Network { public NetworkDto toDto() { NetworkDto networkDto = new NetworkDto(this.name); for (SubNetwork subnet : this.getSubNets()) { SubNetworkDto subNetDto = subnet.toDto(); networkDto.addSubNetworkDto(subNetDto); } return networkDto; } Network();  Network(String name, String vdc, String region); void addSubNet(SubNetwork subNet); Set<SubNetwork> cloneSubNets(); void deleteSubNet(SubNetwork subNet); void updateSubNet(SubNetwork subNet); boolean contains(SubNetwork subNet); String getNetworkName(); String getRegion(); void setNetworkName(String name); String getVdc(); void setVdc(String vdc); void setFederatedNetwork(boolean federatedNetwork); boolean getfederatedNetwork(); void setFederatedRange(String range); String getFederatedRange(); Set<SubNetwork> getSubNets(); void setSubNets(Set<SubNetwork> subNets); NetworkDto toDto(); NetworkInstance toNetworkInstance(); @Override boolean equals(Object obj); @Override int hashCode(); String toString();  }
@Test public void testToDto() throws Exception { Network network = new Network(); network.setNetworkName(NETWORK_NAME); Set<SubNetwork> subNets = new HashSet<SubNetwork>(); SubNetwork subnet = new SubNetwork(SUBNETWORK_NAME, VDC, REGION); subNets.add(subnet); network.setSubNets(subNets); SubNetwork subnet2 = new SubNetwork(SUBNETWORK_NAME + 2, VDC, REGION); network.addSubNet(subnet2); NetworkDto netDto = network.toDto(); assertEquals(netDto.getNetworkName(), NETWORK_NAME); assertEquals(netDto.getSubNetworkDto().size(), 2); }