use of com.google.inject.Provider in project che by eclipse.
the class ClasspathManagerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
when(projectRegistryProvider.get()).thenReturn(projectRegistry);
MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
MavenTerminal terminal = (level, message, throwable) -> {
System.out.println(message);
if (throwable != null) {
throwable.printStackTrace();
}
};
localRepository = new File(new File("target/localRepo").getAbsolutePath());
localRepository.mkdirs();
mavenServerManager.setLocalRepository(localRepository);
MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier);
mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {
@Override
public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
}
@Override
public void sendNotification(NotificationMessage message) {
System.out.println(message.toString());
}
@Override
public void send(JsonObject object, MessageType type) {
}
}, classpathManager, eventService, new EclipseWorkspaceProvider());
}
use of com.google.inject.Provider in project che by eclipse.
the class ProjectWizardPresenter method getWizardForProjectType.
/** Creates or returns project wizard for the specified projectType with the given dataObject. */
private ProjectWizard getWizardForProjectType(@NotNull ProjectTypeDto projectType, @NotNull MutableProjectConfig configDto) {
if (wizardsCache.containsKey(projectType)) {
return wizardsCache.get(projectType);
}
final ProjectWizardRegistrar wizardRegistrar = wizardRegistry.getWizardRegistrar(projectType.getId());
if (wizardRegistrar == null) {
// should never occur
throw new IllegalStateException("WizardRegistrar for the project type " + projectType.getId() + " isn't registered.");
}
List<Provider<? extends WizardPage<MutableProjectConfig>>> pageProviders = wizardRegistrar.getWizardPages();
final ProjectWizard projectWizard = createDefaultWizard(configDto, wizardMode);
for (Provider<? extends WizardPage<MutableProjectConfig>> provider : pageProviders) {
projectWizard.addPage(provider.get(), 1, false);
}
wizardsCache.put(projectType, projectWizard);
return projectWizard;
}
use of com.google.inject.Provider in project ninja by ninjaframework.
the class RouteBuilderImplTest method testWithFiltersClass.
@Test
public void testWithFiltersClass() throws Exception {
// given
DummyFilter dummyFilter = new DummyFilter();
Result expectedResult = Mockito.mock(Result.class);
Context context = Mockito.mock(Context.class);
Provider filterProvider = Mockito.mock(Provider.class);
Mockito.when(injector.getProvider(DummyFilter.class)).thenReturn(filterProvider);
Mockito.when(filterProvider.get()).thenReturn(dummyFilter);
routeBuilder.GET().route("/").filters(DummyFilter.class).with(() -> expectedResult);
Route route = routeBuilder.buildRoute(injector);
FilterChain filterChain = route.getFilterChain();
// when
Result result = filterChain.next(context);
// then
assertThat(dummyFilter.executed, Matchers.equalTo(1));
assertThat(result, org.hamcrest.Matchers.equalTo(expectedResult));
}
use of com.google.inject.Provider in project ninja by ninjaframework.
the class RouteBuilderImplTest method testWithFiltersList.
@Test
public void testWithFiltersList() throws Exception {
// given
DummyFilter dummyFilter = new DummyFilter();
Result expectedResult = Mockito.mock(Result.class);
Context context = Mockito.mock(Context.class);
Provider filterProvider = Mockito.mock(Provider.class);
Mockito.when(injector.getProvider(DummyFilter.class)).thenReturn(filterProvider);
Mockito.when(filterProvider.get()).thenReturn(dummyFilter);
routeBuilder.GET().route("/").filters(Lists.newArrayList(DummyFilter.class)).with(() -> expectedResult);
Route route = routeBuilder.buildRoute(injector);
FilterChain filterChain = route.getFilterChain();
// when
Result result = filterChain.next(context);
// then
assertThat(dummyFilter.executed, Matchers.equalTo(1));
assertThat(result, org.hamcrest.Matchers.equalTo(expectedResult));
}
use of com.google.inject.Provider in project platformlayer by platformlayer.
the class GuiceDataSourceProvider method bindJndi.
public static Provider<? extends DataSource> bindJndi(final String key) {
Provider<DataSource> provider = new Provider<DataSource>() {
@Override
public DataSource get() {
try {
InitialContext context = new InitialContext();
DataSource dataSource = (DataSource) context.lookup(key);
return dataSource;
} catch (NamingException e) {
throw new IllegalStateException("Error getting JDNI connection: " + key, e);
}
}
};
return provider;
}
Aggregations