@Override public boolean apply(Extension ext) { return namespace.toASCIIString().equals(ext.getNamespace().toASCIIString().replace("https", "http")) || namespaceAliases.contains(ext.getNamespace()); }
@Override public boolean apply(Extension ext) { return name.equals(ext.getName()); }
public Extension build() { return new Extension(name, links, namespace, alias, updated, description); }
public T fromExtension(Extension in) { return super.fromResource(in) .namespace(in.getNamespace()) .alias(in.getAlias()) .updated(in.getUpdated()) .description(in.getDescription()); } }
/** * Tests retrieval of Extensions using their alias. * * @throws Exception */ @Test(description = "GET /v${apiVersion}/{tenantId}/extensions/{alias}", dependsOnMethods = { "testListExtensions" }) public void testGetExtensionByAlias() throws Exception { for (String zoneId : zones) { ExtensionApi extensionApi = api.getExtensionApiForZone(zoneId); Set<? extends Extension> response = extensionApi.list(); for (Extension extension : response) { Extension details = extensionApi.get(extension.getId()); assertNotNull(details); assertEquals(details.getId(), extension.getId()); assertEquals(details.getName(), extension.getName()); assertEquals(details.getDescription(), extension.getDescription()); assertEquals(details.getNamespace(), extension.getNamespace()); assertEquals(details.getUpdated(), extension.getUpdated()); assertEquals(details.getLinks(), extension.getLinks()); } } }
/** * Tests the listing of Extensions. * * @throws Exception */ @Test(description = "GET /v${apiVersion}/{tenantId}/extensions") public void testListExtensions() throws Exception { for (String regionId : regions) { ExtensionApi extensionApi = api.getExtensionApi(regionId); Set<? extends Extension> response = extensionApi.list(); assertNotNull(response); assertFalse(response.isEmpty()); for (Extension extension : response) { assertNotNull(extension.getId()); assertNotNull(extension.getName()); assertNotNull(extension.getDescription()); assertNotNull(extension.getLinks()); // Namespace and updated fields are nullable } } }
/** * It is possible that the /extensions call returned the correct extension, but that the * namespaces were different, for whatever reason. One way to address this is to have a multimap * of the authoritative namespace to alternate onces, which could be wired up with guice * */ public void testPresentWhenAliasForExtensionMapsToNamespace() throws SecurityException, NoSuchMethodException { Extension keypairsWithDifferentNamespace = keypairs.toBuilder().namespace( URI.create("http://docs.openstack.org/ext/arbitrarilydifferent/keypairs/api/v1.1")).build(); Multimap<URI, URI> aliases = ImmutableMultimap.of(keypairs.getNamespace(), keypairsWithDifferentNamespace .getNamespace()); assertEquals(whenExtensionsAndAliasesInZoneInclude("zone", ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply( getKeyPairExtension(ImmutableList.<Object> of("zone"))), Optional.of("foo")); assertEquals(whenExtensionsAndAliasesInZoneInclude("zone", ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply( getFloatingIPExtension(ImmutableList.<Object> of("zone"))), Optional.absent()); }
@Override public boolean apply(Extension ext) { return alias.equals(ext.getAlias()); }
public void testChangesHttpsToHttp() { assertEquals(fn.apply(Extension.builder().alias("security_groups").name("SecurityGroups").namespace( URI.create("https://docs.openstack.org/ext/securitygroups/api/v1.1")).updated( new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-07-21T00:00:00+00:00")).description( "Security group support").build()), URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1")); } }
public T fromExtension(Extension in) { return super.fromResource(in) .namespace(in.getNamespace()) .alias(in.getAlias()) .updated(in.getUpdated()) .description(in.getDescription()); } }
/** * Tests retrieval of Extensions using their alias. * * @throws Exception */ @Test(description = "GET /v${apiVersion}/{tenantId}/extensions/{alias}", dependsOnMethods = { "testListExtensions" }) public void testGetExtensionByAlias() throws Exception { for (String regionId : regions) { ExtensionApi extensionApi = api.getExtensionApi(regionId); Set<? extends Extension> response = extensionApi.list(); for (Extension extension : response) { Extension details = extensionApi.get(extension.getId()); assertNotNull(details); assertEquals(details.getId(), extension.getId()); assertEquals(details.getName(), extension.getName()); assertEquals(details.getDescription(), extension.getDescription()); assertEquals(details.getNamespace(), extension.getNamespace()); assertEquals(details.getUpdated(), extension.getUpdated()); assertEquals(details.getLinks(), extension.getLinks()); } } }
/** * Tests the listing of Neutron Extensions. * * @throws Exception */ public void testListExtensions() throws Exception { for (String regionId : api.getConfiguredRegions()) { ExtensionApi extensionApi = api.getExtensionApi(regionId); Set<Extension> response = extensionApi.list(); assertNotNull(response); assertFalse(response.isEmpty()); for (Extension extension : response) { assertNotNull(extension.getId()); assertNotNull(extension.getName()); assertNotNull(extension.getDescription()); assertNotNull(extension.getLinks()); // Namespace and updated fields are nullable } } }
/** * It is possible that the /extensions call returned the correct extension, but that the * namespaces were different, for whatever reason. One way to address this is to have a multimap * of the authoritative namespace to alternate ones, which could be wired up with guice * */ public void testPresentWhenAliasForExtensionMapsToNamespace() throws SecurityException, NoSuchMethodException { Extension keypairsWithDifferentNamespace = keypairs.toBuilder().namespace( URI.create("http://docs.openstack.org/ext/arbitrarilydifferent/keypairs/api/v1.1")).build(); Multimap<URI, URI> aliases = ImmutableMultimap.of(keypairs.getNamespace(), keypairsWithDifferentNamespace .getNamespace()); assertEquals(whenExtensionsAndAliasesInRegionInclude("region", ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply( getKeyPairExtension(ImmutableList.<Object> of("region"))), Optional.of("foo")); assertEquals(whenExtensionsAndAliasesInRegionInclude("region", ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply( getFloatingIPExtension(ImmutableList.<Object> of("region"))), Optional.absent()); }
@Override public boolean apply(Extension ext) { return alias.equals(ext.getAlias()); }
public void testReturnsNamespace() { URI ns = URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"); assertEquals(fn.apply(Extension.builder().alias("os-keypairs").name("Keypairs").namespace(ns).updated( new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00")).description( "Keypair Support").build()), ns); }
public T fromExtension(Extension in) { return super.fromResource(in) .namespace(in.getNamespace()) .alias(in.getAlias()) .updated(in.getUpdated()) .description(in.getDescription()); } }
/** * Tests retrieval of Neutron Extensions by their alias. * * @throws Exception */ public void testGetExtensionByAlias() throws Exception { for (String regionId : api.getConfiguredRegions()) { ExtensionApi extensionApi = api.getExtensionApi(regionId); Set<Extension> response = extensionApi.list(); assertNotNull(response); for (Extension extension : response) { Extension details = extensionApi.get(extension.getId()); assertNotNull(details); assertEquals(details.getId(), extension.getId()); assertEquals(details.getName(), extension.getName()); assertEquals(details.getDescription(), extension.getDescription()); assertEquals(details.getNamespace(), extension.getNamespace()); assertEquals(details.getUpdated(), extension.getUpdated()); assertEquals(details.getLinks(), extension.getLinks()); } } }
@Override public boolean apply(Extension ext) { return ext.getNamespace() == null ? false : namespace.toASCIIString().equals( ext.getNamespace().toASCIIString().replace("https", "http")); }
@Override public boolean apply(Extension ext) { return name.equals(ext.getName()); }
@Override public boolean apply(Extension ext) { return alias.equals(ext.getAlias()); }