@BeforeClass
  public static void beforeClass() {
    injector = Guice.createInjector(new TestPersistServiceModule());
    serviceFactory = (CollectionPersisterServiceFactory) injector.getInstance(CollectionPersisterServiceFactory.class);
  }
Guice module for testing service / factory behavior
ambari-server/src/test/java/org/apache/ambari/server/serveraction/users/CsvFilePersisterServiceFunctionalTest.java