@Test(expectedExceptions = NullPointerException.class) public void testAddHostNullWithHost() throws Exception { assertNull(RestAnnotationProcessor.addHostIfMissing(null, null)); }
@Test(expectedExceptions = NullPointerException.class) public void testAddHostNullWithHost() throws Exception { assertNull(RestAnnotationProcessor.addHostIfMissing(null, null)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddHostWithHostHasNoHost() throws Exception { assertNull(RestAnnotationProcessor.addHostIfMissing(null, new URI("/no/host"))); }
@Test public void testAddHostNullOriginal() throws Exception { assertNull(RestAnnotationProcessor.addHostIfMissing(null, new URI("http://foo"))); }
@Test public void testAddHostOriginalHasHost() throws Exception { URI original = new URI("http://hashost/foo"); URI result = RestAnnotationProcessor.addHostIfMissing(original, new URI("http://foo")); assertEquals(original, result); }
@Test public void testAddHostIfMissing() throws Exception { URI result = RestAnnotationProcessor.addHostIfMissing(new URI("/bar"), new URI("http://foo")); assertEquals(new URI("http://foo/bar"), result); }
@Test public void testAddHostNullOriginal() throws Exception { assertNull(RestAnnotationProcessor.addHostIfMissing(null, new URI("http://foo"))); }
@Test public void testAddHostOriginalHasHost() throws Exception { URI original = new URI("http://hashost/foo"); URI result = RestAnnotationProcessor.addHostIfMissing(original, new URI("http://foo")); assertEquals(original, result); }
@Test public void testAddHostIfMissing() throws Exception { URI result = RestAnnotationProcessor.addHostIfMissing(new URI("/bar"), new URI("http://foo")); assertEquals(new URI("http://foo/bar"), result); }
@Test public void testComplexHost() throws Exception { URI result = RestAnnotationProcessor.addHostIfMissing(new URI("bar"), new URI("http://foo/foobar")); assertEquals(new URI("http://foo/foobar/bar"), result); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddHostWithHostHasNoHost() throws Exception { assertNull(RestAnnotationProcessor.addHostIfMissing(null, new URI("/no/host"))); }
protected Optional<URI> getEndpointFor(Invocation invocation) { URI endpoint = getEndpointInParametersOrNull(invocation, injector); if (endpoint == null) { Endpoint annotation; if (invocation.getInvokable().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getAnnotation(Endpoint.class); } else if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Endpoint.class); } else { logger.trace("no annotations on class or invocation.getInvoked(): %s", invocation.getInvokable()); return Optional.absent(); } endpoint = injector.getInstance(Key.get(uriSupplierLiteral, annotation.value())).get(); } URI provider = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get(); return Optional.fromNullable(addHostIfMissing(endpoint, provider)); }
protected Optional<URI> getEndpointFor(Invocation invocation) { URI endpoint = getEndpointInParametersOrNull(invocation, injector); if (endpoint == null) { Endpoint annotation; if (invocation.getInvokable().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getAnnotation(Endpoint.class); } else if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Endpoint.class); } else { logger.trace("no annotations on class or invocation.getInvoked(): %s", invocation.getInvokable()); return Optional.absent(); } endpoint = injector.getInstance(Key.get(uriSupplierLiteral, annotation.value())).get(); } URI provider = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get(); return Optional.fromNullable(addHostIfMissing(endpoint, provider)); }
protected Optional<URI> getEndpointFor(Invocation invocation) { URI endpoint = getEndpointInParametersOrNull(invocation, injector); if (endpoint == null) { Endpoint annotation; if (invocation.getInvokable().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getAnnotation(Endpoint.class); } else if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Endpoint.class); } else { logger.trace("no annotations on class or invocation.getInvoked(): %s", invocation.getInvokable()); return Optional.absent(); } endpoint = injector.getInstance(Key.get(uriSupplierLiteral, annotation.value())).get(); } URI provider = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get(); return Optional.fromNullable(addHostIfMissing(endpoint, provider)); }
protected Optional<URI> getEndpointFor(Invocation invocation) { URI endpoint = getEndpointInParametersOrNull(invocation, injector); if (endpoint == null) { Endpoint annotation; if (invocation.getInvokable().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getAnnotation(Endpoint.class); } else if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Endpoint.class); } else { logger.trace("no annotations on class or invocation.getInvoked(): %s", invocation.getInvokable()); return Optional.absent(); } endpoint = injector.getInstance(Key.get(uriSupplierLiteral, annotation.value())).get(); } URI provider = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get(); return Optional.fromNullable(addHostIfMissing(endpoint, provider)); }
protected Optional<URI> getEndpointFor(Invocation invocation) { URI endpoint = getEndpointInParametersOrNull(invocation, injector); if (endpoint == null) { Endpoint annotation; if (invocation.getInvokable().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getAnnotation(Endpoint.class); } else if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Endpoint.class); } else { logger.trace("no annotations on class or invocation.getInvoked(): %s", invocation.getInvokable()); return Optional.absent(); } endpoint = injector.getInstance(Key.get(uriSupplierLiteral, annotation.value())).get(); } URI provider = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get(); return Optional.fromNullable(addHostIfMissing(endpoint, provider)); }
protected Optional<URI> getEndpointFor(Invocation invocation) { URI endpoint = getEndpointInParametersOrNull(invocation, injector); if (endpoint == null) { Endpoint annotation; if (invocation.getInvokable().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getAnnotation(Endpoint.class); } else if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Endpoint.class)) { annotation = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Endpoint.class); } else { logger.trace("no annotations on class or invocation.getInvoked(): %s", invocation.getInvokable()); return Optional.absent(); } endpoint = injector.getInstance(Key.get(uriSupplierLiteral, annotation.value())).get(); } URI provider = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get(); return Optional.fromNullable(addHostIfMissing(endpoint, provider)); }