use of com.google.inject.Provider in project gerrit by GerritCodeReview.
the class BatchUpdateTest method setUp.
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(new InMemoryModule());
injector.injectMembers(this);
lifecycle = new LifecycleManager();
lifecycle.add(injector);
lifecycle.start();
try (ReviewDb underlyingDb = inMemoryDatabase.getDatabase().open()) {
schemaCreator.create(underlyingDb);
}
db = schemaFactory.open();
Account.Id userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
user = userFactory.create(userId);
project = new Project.NameKey("test");
InMemoryRepository inMemoryRepo = repoManager.createRepository(project);
repo = new TestRepository<>(inMemoryRepo);
requestContext.setContext(new RequestContext() {
@Override
public CurrentUser getUser() {
return user;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
});
}
use of com.google.inject.Provider in project gerrit by GerritCodeReview.
the class GerritPublicKeyCheckerTest method setUpInjector.
@Before
public void setUpInjector() throws Exception {
Config cfg = InMemoryModule.newDefaultConfig();
cfg.setInt("receive", null, "maxTrustDepth", 2);
cfg.setStringList("receive", null, "trustedKey", ImmutableList.of(Fingerprint.toString(keyB().getPublicKey().getFingerprint()), Fingerprint.toString(keyD().getPublicKey().getFingerprint())));
Injector injector = Guice.createInjector(new InMemoryModule(cfg, new TestNotesMigration()));
lifecycle = new LifecycleManager();
lifecycle.add(injector);
injector.injectMembers(this);
lifecycle.start();
db = schemaFactory.open();
schemaCreator.create(db);
userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
Account userAccount = db.accounts().get(userId);
// Note: does not match any key in TestKeys.
userAccount.setPreferredEmail("user@example.com");
db.accounts().update(ImmutableList.of(userAccount));
user = reloadUser();
requestContext.setContext(new RequestContext() {
@Override
public CurrentUser getUser() {
return user;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
});
storeRepo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
store = new PublicKeyStore(storeRepo);
}
use of com.google.inject.Provider in project gerrit by GerritCodeReview.
the class LabelNormalizerTest method setUpInjector.
@Before
public void setUpInjector() throws Exception {
Injector injector = Guice.createInjector(new InMemoryModule());
injector.injectMembers(this);
lifecycle = new LifecycleManager();
lifecycle.add(injector);
lifecycle.start();
db = schemaFactory.open();
schemaCreator.create(db);
userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
user = userFactory.create(userId);
requestContext.setContext(new RequestContext() {
@Override
public CurrentUser getUser() {
return user;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
});
configureProject();
setUpChange();
}
use of com.google.inject.Provider in project xtext-xtend by eclipse.
the class ConstantExpressionsInterpreter method findVisibleFeatures.
/**
* looks up the static final fields which are accessible in unqualified form for the given expression.
* That essentially includes static imports and the fields declared in the containing types
*/
protected Map<String, JvmIdentifiableElement> findVisibleFeatures(final XExpression expression) {
HashMap<String, JvmIdentifiableElement> _xblockexpression = null;
{
Resource _eResource = expression.eResource();
final Resource res = _eResource;
boolean _matched = false;
if (res instanceof StorageAwareResource) {
boolean _isLoadedFromStorage = ((StorageAwareResource) res).isLoadedFromStorage();
if (_isLoadedFromStorage) {
_matched = true;
return CollectionLiterals.<String, JvmIdentifiableElement>newHashMap();
}
}
JvmDeclaredType _switchResult_1 = null;
JvmIdentifiableElement _nearestLogicalContainer = this.containerProvider.getNearestLogicalContainer(expression);
final JvmIdentifiableElement cont = _nearestLogicalContainer;
boolean _matched_1 = false;
if (cont instanceof JvmGenericType) {
_matched_1 = true;
_switchResult_1 = ((JvmGenericType) cont);
}
if (!_matched_1) {
if (cont instanceof JvmMember) {
_matched_1 = true;
_switchResult_1 = ((JvmMember) cont).getDeclaringType();
}
}
final JvmDeclaredType container = _switchResult_1;
Pair<String, JvmDeclaredType> _mappedTo = Pair.<String, JvmDeclaredType>of("visibleFeaturesForAnnotationValues", container);
final Provider<HashMap<String, JvmIdentifiableElement>> _function = () -> {
final HashMap<String, JvmIdentifiableElement> result = CollectionLiterals.<String, JvmIdentifiableElement>newHashMap();
Resource _eResource_1 = expression.eResource();
final XImportSection section = this.importSectionLocator.getImportSection(((XtextResource) _eResource_1));
if ((section != null)) {
EList<XImportDeclaration> _importDeclarations = section.getImportDeclarations();
for (final XImportDeclaration imp : _importDeclarations) {
boolean _isStatic = imp.isStatic();
if (_isStatic) {
final String importedTypeName = imp.getImportedTypeName();
if ((importedTypeName != null)) {
final JvmType type = this.findTypeByName(imp, importedTypeName);
boolean _matched_2 = false;
if (type instanceof JvmGenericType) {
_matched_2 = true;
this.collectAllVisibleFields(((JvmDeclaredType) type), result);
}
if (!_matched_2) {
if (type instanceof JvmEnumerationType) {
_matched_2 = true;
EList<JvmEnumerationLiteral> _literals = ((JvmEnumerationType) type).getLiterals();
for (final JvmEnumerationLiteral feature : _literals) {
result.put(feature.getSimpleName(), feature);
}
}
}
}
}
}
}
this.collectAllVisibleFields(container, result);
return result;
};
_xblockexpression = this.cache.<HashMap<String, JvmIdentifiableElement>>get(_mappedTo, expression.eResource(), _function);
}
return _xblockexpression;
}
use of com.google.inject.Provider in project cdap by caskdata.
the class LogPipelineLoader method validate.
/**
* Validates the log pipeline configurations.
*
* @throws InvalidPipelineException if any of the pipeline configuration is invalid.
*/
public void validate() throws InvalidPipelineException {
Provider<LoggerContext> contextProvider = new Provider<LoggerContext>() {
@Override
public LoggerContext get() {
LoggerContext context = new LoggerContext();
context.putObject(Constants.Logging.PIPELINE_VALIDATION, Boolean.TRUE);
return context;
}
};
doLoad(contextProvider, false);
}
Aggregations