@Test(description = "PUT /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetNetworkConfigSection" })
public void testEditNetworkConfigSection() {
// Copy existing section and update fields
NetworkConfigSection oldSection = vAppApi.getNetworkConfigSection(vAppUrn);
Network network = lazyGetNetwork();
tryFindBridgedNetworkInOrg();
IpRange ipRange = ipRange();
NetworkConfiguration newConfiguration = NetworkConfiguration.builder()
.ipScope(ipScope(ipRange))
.parentNetwork(Reference.builder().fromEntity(network).build())
.fenceMode(FenceMode.NAT_ROUTED)
.retainNetInfoAcrossDeployments(false)
.syslogServerSettings(SyslogServerSettings.builder().syslogServerIp1("192.168.14.27").build())
.features(NetworkFeatures.builder()
.service(DhcpService.builder()
.ipRange(ipRange)
.build())
.service(FirewallService.builder()
.logDefaultAction(false)
.defaultAction("drop")
.build())
.service(NatService.builder()
.natType("portForwarding")
.enabled(false)
.build())
.build())
.build();
final String networkName = name("vAppNetwork-");
VAppNetworkConfiguration newVAppNetworkConfiguration = VAppNetworkConfiguration.builder()
.networkName(networkName)
.description(name("description-"))
.configuration(newConfiguration)
.build();
NetworkConfigSection newSection = oldSection.toBuilder().networkConfigs(ImmutableSet.of(newVAppNetworkConfiguration)).build();
// The method under test
Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vAppUrn, newSection);
assertTrue(retryTaskSuccess.apply(editNetworkConfigSection),
String.format(TASK_COMPLETE_TIMELY, "editNetworkConfigSection"));
// Retrieve the modified section
NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn);
// Check the retrieved object is well formed
checkNetworkConfigSection(modified);
Optional<VAppNetworkConfiguration> modifiedOptionalVAppNetwork = Iterables.tryFind(modified.getNetworkConfigs(), new IsVAppNetworkNamed(networkName));
if (!modifiedOptionalVAppNetwork.isPresent())
fail(String.format("Could not find vApp network named %s", networkName));
Optional<VAppNetworkConfiguration> newOptionalVAppNetwork = Iterables.tryFind(newSection.getNetworkConfigs(), new IsVAppNetworkNamed(networkName));
if (!newOptionalVAppNetwork.isPresent())