### Question:
RestAnnotationProcessor implements Function<Invocation, HttpRequest> { @VisibleForTesting static URI getEndpointInParametersOrNull(Invocation invocation, Injector injector) { Collection<Parameter> endpointParams = parametersWithAnnotation(invocation.getInvokable(), EndpointParam.class); if (endpointParams.isEmpty()) return null; checkState(endpointParams.size() == 1, "invocation.getInvoked() %s has too many EndpointParam annotations", invocation.getInvokable()); Parameter endpointParam = get(endpointParams, 0); Function<Object, URI> parser = injector.getInstance(endpointParam.getAnnotation(EndpointParam.class).parser()); int position = endpointParam.hashCode(); try { URI returnVal = parser.apply(invocation.getArgs().get(position)); checkArgument(returnVal != null, "endpoint for [%s] not configured for %s", position, invocation.getInvokable()); return returnVal; } catch (NullPointerException e) { throw new IllegalArgumentException(format("argument at index %d on invocation.getInvoked() %s was null", position, invocation.getInvokable()), e); } } @Inject private  RestAnnotationProcessor(Injector injector,
         @Provider Supplier<Credentials> credentials, @ApiVersion String apiVersion, @BuildVersion String buildVersion,
         HttpUtils utils, ContentMetadataCodec contentMetadataCodec, InputParamValidator inputParamValidator,
         GetAcceptHeaders getAcceptHeaders, @Nullable @Named("caller") Invocation caller,
         @Named(Constants.PROPERTY_STRIP_EXPECT_HEADER) boolean stripExpectHeader,
         @Named(Constants.PROPERTY_CONNECTION_CLOSE_HEADER) boolean connectionCloseHeader); @Deprecated GeneratedHttpRequest createRequest(Invokable<?, ?> invokable, List<Object> args); @Override GeneratedHttpRequest apply(Invocation invocation); @Override String toString();  }### Answer:
@Test public void testOneEndpointParam() throws SecurityException, NoSuchMethodException, ExecutionException { Invokable<?, ?> method = method(TestEndpointParams.class, "oneEndpointParam", String.class); URI uri = RestAnnotationProcessor.getEndpointInParametersOrNull( Invocation.create(method, ImmutableList.<Object> of("robot")), injector); assertEquals(uri, URI.create("robot")); }
@Test(expectedExceptions = IllegalStateException.class) public void testTwoDifferentEndpointParams() throws SecurityException, NoSuchMethodException, ExecutionException { Invokable<?, ?> method = method(TestEndpointParams.class, "twoEndpointParams", String.class, String.class); RestAnnotationProcessor.getEndpointInParametersOrNull( Invocation.create(method, ImmutableList.<Object> of("robot", "egg")), injector); }