* The event bus
* @param webOfTrustConnector
* The Web of Trust connector
- * @param context
- * The context to focus on (may be {@code null} to ignore
- * contexts)
*/
@Inject
- public IdentityManager(EventBus eventBus, WebOfTrustConnector webOfTrustConnector, Context context) {
+ public IdentityManager(EventBus eventBus, WebOfTrustConnector webOfTrustConnector, IdentityLoader identityLoader) {
super("Sone Identity Manager", false);
this.eventBus = eventBus;
this.webOfTrustConnector = webOfTrustConnector;
- this.identityLoader = new IdentityLoader(webOfTrustConnector, fromNullable(context.getContext()));
+ this.identityLoader = identityLoader;
}
//
package net.pterodactylus.sone.main;
+import static com.google.common.base.Optional.of;
+
import java.io.File;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import net.pterodactylus.util.logging.LoggingListener;
import net.pterodactylus.util.version.Version;
+import com.google.common.base.Optional;
import com.google.common.eventbus.EventBus;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
bind(Configuration.class).toInstance(startConfiguration);
bind(FreenetInterface.class).in(Singleton.class);
bind(PluginConnector.class).in(Singleton.class);
- bind(Context.class).toInstance(new Context("Sone"));
+ Context context = new Context("Sone");
+ bind(Context.class).toInstance(context);
+ bind(getOptionalContextTypeLiteral()).toInstance(of(context));
bind(WebOfTrustConnector.class).in(Singleton.class);
bind(WebOfTrustUpdater.class).in(Singleton.class);
bind(IdentityManager.class).in(Singleton.class);
});
}
+ private TypeLiteral<Optional<Context>> getOptionalContextTypeLiteral() {
+ return new TypeLiteral<Optional<Context>>() {
+ };
+ }
+
};
Injector injector = Guice.createInjector(freenetModule, soneModule);
core = injector.getInstance(Core.class);
package net.pterodactylus.sone.freenet.wot;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Optional.of;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.doThrow;
private final EventBus eventBus = mock(EventBus.class);
private final WebOfTrustConnector webOfTrustConnector = mock(WebOfTrustConnector.class);
- private final IdentityManager identityManager = new IdentityManager(eventBus, webOfTrustConnector, new Context("Test"));
+ private final IdentityManager identityManager = new IdentityManager(eventBus, webOfTrustConnector, new IdentityLoader(webOfTrustConnector, of(new Context("Test"))));
@Test
public void identityManagerPingsWotConnector() throws PluginException {