@Test public void constructor() throws IOException { String str = "{\"testrigName\" : \"testrig\"," + " \"nodes\" : [{\"name\": \"node\"}], " + " \"links\" : [{\"srcId\" : \"src\", \"dstId\" : \"dst\"}]," + " \"interfaces\" : [{\"nodeId\": \"node\", \"name\" : \"node\"}]," + " \"aggregates\" : [{\"name\": \"cloud\", \"contents\" : [\"id1\"]}]}"; Topology topo = BatfishObjectMapper.mapper().readValue(str, Topology.class); assertThat(topo.getId(), equalTo(Topology.getId("testrig"))); assertThat(topo.getTestrigName(), equalTo("testrig")); assertThat(topo.getAggregates().size(), equalTo(1)); assertThat( topo.getOrCreateAggregate("cloud", AggregateType.CLOUD).getContents().size(), equalTo(1)); assertThat(topo.getInterfaces().size(), equalTo(1)); assertThat(topo.getLinks().size(), equalTo(1)); assertThat(topo.getNodes().size(), equalTo(1)); }
Aggregate subnetAggregate = pojoTopology.getOrCreateAggregate(subnetId, AggregateType.SUBNET); subnetAggregate.getContents().add(pojoNode.getId()); vpcAggregate.getContents().add(subnetAggregate.getId()); } else if (configuration.getVendorFamily().getAws().getVpcId() != null) { String vpcId = configuration.getVendorFamily().getAws().getVpcId(); Aggregate vpcAggregate = pojoTopology.getOrCreateAggregate(vpcId, AggregateType.VNET); vpcAggregate.getContents().add(pojoNode.getId()); regionAggregate.getContents().add(vpcAggregate.getId()); } else if (configuration.getVendorFamily().getAws().getRegion() != null) { String region = configuration.getVendorFamily().getAws().getRegion(); Aggregate regionAggregate = pojoTopology.getOrCreateAggregate(region, AggregateType.REGION); regionAggregate.getContents().add(pojoNode.getId()); awsAggregate.getContents().add(regionAggregate.getId()); } else { Aggregate awsAggregate = pojoTopology.getOrCreateAggregate("aws", AggregateType.CLOUD); awsAggregate.getContents().add(pojoNode.getId());