Network network = networkApi.create(
Network.createOptions("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
assertNotNull(network);
Subnet subnet = subnetApi.create(Subnet.createOptions(network.getId(), "192.168.0.0/16").ipVersion(4).build());
assertNotNull(subnet);
Router router = routerApi.create(Router.createOptions().name("jclouds-router-test")
.externalGatewayInfo(ExternalGatewayInfo.builder().networkId(network.getId()).build()).build());
assertNotNull(router);
/* List and Get test */
Set<Router> routers = api.getRouterExtensionApi(region).get().list().concat().toSet();
Router routerList = routers.iterator().next();
Router routerGet = api.getRouterExtensionApi(region).get().get(routerList.getId());
assertNotNull(routerGet);
assertEquals(routerGet, routerList);
/***/
routerGet = routerApi.get(router.getId());
assertEquals(routerGet.getName(), router.getName());
assertEquals(routerGet.getId(), router.getId());
assertEquals(routerGet.getExternalGatewayInfo(), router.getExternalGatewayInfo());
Router routerUpdate = routerApi.update(router.getId(), Router.updateOptions().name("jclouds-router-test-rename").build());
assertNotNull(routerUpdate);
assertEquals(routerUpdate.getName(), "jclouds-router-test-rename");
routerGet = routerApi.get(router.getId());
assertEquals(routerGet.getId(), router.getId());
assertEquals(routerGet.getName(), "jclouds-router-test-rename");
assertTrue(routerApi.delete(router.getId()));
assertTrue(subnetApi.delete(subnet.getId()));
assertTrue(networkApi.delete(network.getId()));
}
}