@Test public void testGetSessionUtility_fails() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("SessionUtility"); bootstrapper.getInstanceOf(session, MockSessionUtility.class); }
@Override public <T> T getInstanceOf(AdWordsSession session, Class<T> dependencyClass) { Preconditions.checkNotNull(session, "Null session"); Preconditions.checkNotNull(dependencyClass, "Null dependency class"); if (dependencyClass.getAnnotation(SessionUtility.class) != null) { String message = String.format( "%s is annotated with %s. Only types without that annotation can be obtained " + " from this bootstrapper. Use AdWordsServicesInterface.getUtility instead.", dependencyClass, SessionUtility.class); throw new IllegalArgumentException(message); } Injector childInjector = injector.createChildInjector(new AdWordsSessionModule(session)); return childInjector.getInstance(dependencyClass); }
DependencyBootstrapperImpl implements DependencyBootstrapper { @Override public <T> T getInstanceOf(AdWordsSession session, Class<T> dependencyClass) { Preconditions.checkNotNull(session, "Null session"); Preconditions.checkNotNull(dependencyClass, "Null dependency class"); if (dependencyClass.getAnnotation(SessionUtility.class) != null) { String message = String.format( "%s is annotated with %s. Only types without that annotation can be obtained " + " from this bootstrapper. Use AdWordsServicesInterface.getUtility instead.", dependencyClass, SessionUtility.class); throw new IllegalArgumentException(message); } Injector childInjector = injector.createChildInjector(new AdWordsSessionModule(session)); return childInjector.getInstance(dependencyClass); } }
DependencyBootstrapperImpl implements DependencyBootstrapper { @Override public <T> T getInstanceOf(AdWordsSession session, Class<T> dependencyClass) { Preconditions.checkNotNull(session, "Null session"); Preconditions.checkNotNull(dependencyClass, "Null dependency class"); if (dependencyClass.getAnnotation(SessionUtility.class) != null) { String message = String.format( "%s is annotated with %s. Only types without that annotation can be obtained " + " from this bootstrapper. Use AdWordsServicesInterface.getUtility instead.", dependencyClass, SessionUtility.class); throw new IllegalArgumentException(message); } Injector childInjector = injector.createChildInjector(new AdWordsSessionModule(session)); return childInjector.getInstance(dependencyClass); } @Inject  DependencyBootstrapperImpl(Injector injector); }
DependencyBootstrapperImpl implements DependencyBootstrapper { @Override public <T> T getInstanceOf(AdWordsSession session, Class<T> dependencyClass) { Preconditions.checkNotNull(session, "Null session"); Preconditions.checkNotNull(dependencyClass, "Null dependency class"); if (dependencyClass.getAnnotation(SessionUtility.class) != null) { String message = String.format( "%s is annotated with %s. Only types without that annotation can be obtained " + " from this bootstrapper. Use AdWordsServicesInterface.getUtility instead.", dependencyClass, SessionUtility.class); throw new IllegalArgumentException(message); } Injector childInjector = injector.createChildInjector(new AdWordsSessionModule(session)); return childInjector.getInstance(dependencyClass); } @Inject  DependencyBootstrapperImpl(Injector injector); @Override T getInstanceOf(AdWordsSession session, Class<T> dependencyClass); }
DependencyBootstrapperImpl implements DependencyBootstrapper { @Override public <T> T getInstanceOf(AdWordsSession session, Class<T> dependencyClass) { Preconditions.checkNotNull(session, "Null session"); Preconditions.checkNotNull(dependencyClass, "Null dependency class"); if (dependencyClass.getAnnotation(SessionUtility.class) != null) { String message = String.format( "%s is annotated with %s. Only types without that annotation can be obtained " + " from this bootstrapper. Use AdWordsServicesInterface.getUtility instead.", dependencyClass, SessionUtility.class); throw new IllegalArgumentException(message); } Injector childInjector = injector.createChildInjector(new AdWordsSessionModule(session)); return childInjector.getInstance(dependencyClass); } @Inject  DependencyBootstrapperImpl(Injector injector); @Override T getInstanceOf(AdWordsSession session, Class<T> dependencyClass);  }