ApplicationInjector extends AbstractModule { @Provides @Named("USER_NAME") public String getUserName(User user) { return user.getUserName(); }  @Provides @Named("USER_NAME") String getUserName(User user); @Provides RapidFtrApplication getRapidFTRApplication(); @Provides DatabaseSession getDatabaseSession(DatabaseHelper helper); @Provides User getUser(RapidFtrApplication application); @Provides SynchronisationAsyncTask<Child> getChildSynchronisationAsyncTask(User user, Provider<SyncAllDataAsyncTask<Child>> provider1, Provider<SyncUnverifiedDataAsyncTask<Child>> provider2); @Provides SynchronisationAsyncTask<Enquiry> getEnquirySynchronisationAsyncTask(User user, Provider<SyncAllDataAsyncTask<Enquiry>> provider1, Provider<SyncUnverifiedDataAsyncTask<Enquiry>> provider2); @Provides SynchronisationAsyncTask<PotentialMatch> getPotentialMatchSynchronisationAsyncTask(User user, Provider<SyncAllDataAsyncTask<PotentialMatch>> provider1, Provider<SyncUnverifiedDataAsyncTask<PotentialMatch>> provider2); @Provides SharedPreferences getSharedPreferences(); @Provides EntityHttpDao<Enquiry> getEnquiryHttpDao(RapidFtrApplication rapidFtrApplication); @Provides EntityHttpDao<Child> getChildHttpDao(RapidFtrApplication rapidFtrApplication); @Provides EntityHttpDao<PotentialMatch> getPotentialMatchesHttpDao(RapidFtrApplication rapidFtrApplication);  }
@Test public void testUserName() throws IOException { User user = createUser(); application.setCurrentUser(user); String result = injector.getInstance(Key.get(String.class, Names.named("USER_NAME"))); assertThat(result, equalTo(user.getUserName())); }