mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-13 11:09:10 +01:00
Merge pull request #3058 from christophsturm/bump-guice
use singleton annotation instead of binding as singleton
This commit is contained in:
commit
e52c255446
22 changed files with 114 additions and 41 deletions
|
@ -176,7 +176,7 @@ configure(project(':common')) {
|
||||||
compile "ch.qos.logback:logback-classic:$logbackVersion"
|
compile "ch.qos.logback:logback-classic:$logbackVersion"
|
||||||
compile 'com.google.code.findbugs:jsr305:3.0.2'
|
compile 'com.google.code.findbugs:jsr305:3.0.2'
|
||||||
compile 'com.google.guava:guava:20.0'
|
compile 'com.google.guava:guava:20.0'
|
||||||
compile('com.google.inject:guice:4.1.0') {
|
compile('com.google.inject:guice:4.2.2') {
|
||||||
exclude(module: 'guava')
|
exclude(module: 'guava')
|
||||||
}
|
}
|
||||||
compile("com.github.bisq-network.bitcoinj:bitcoinj-core:$bitcoinjVersion") {
|
compile("com.github.bisq-network.bitcoinj:bitcoinj-core:$bitcoinjVersion") {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.bitcoinj.utils.Fiat;
|
||||||
import org.bitcoinj.utils.MonetaryFormat;
|
import org.bitcoinj.utils.MonetaryFormat;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
@ -59,6 +60,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Singleton
|
||||||
public class BSFormatter {
|
public class BSFormatter {
|
||||||
public final static String RANGE_SEPARATOR = " - ";
|
public final static String RANGE_SEPARATOR = " - ";
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.bitcoinj.core.Coin;
|
||||||
import org.bitcoinj.utils.MonetaryFormat;
|
import org.bitcoinj.utils.MonetaryFormat;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
@ -44,6 +45,7 @@ import java.util.Locale;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Singleton
|
||||||
public class BsqFormatter extends BSFormatter {
|
public class BsqFormatter extends BSFormatter {
|
||||||
@SuppressWarnings("PointlessBooleanExpression")
|
@SuppressWarnings("PointlessBooleanExpression")
|
||||||
private static final boolean useBsqAddressFormat = true || !DevEnv.isDevMode();
|
private static final boolean useBsqAddressFormat = true || !DevEnv.isDevMode();
|
||||||
|
|
|
@ -18,26 +18,12 @@
|
||||||
package bisq.desktop;
|
package bisq.desktop;
|
||||||
|
|
||||||
import bisq.desktop.common.fxml.FxmlViewLoader;
|
import bisq.desktop.common.fxml.FxmlViewLoader;
|
||||||
import bisq.desktop.common.view.CachingViewLoader;
|
|
||||||
import bisq.desktop.common.view.ViewFactory;
|
import bisq.desktop.common.view.ViewFactory;
|
||||||
import bisq.desktop.common.view.ViewLoader;
|
import bisq.desktop.common.view.ViewLoader;
|
||||||
import bisq.desktop.common.view.guice.InjectorViewFactory;
|
import bisq.desktop.common.view.guice.InjectorViewFactory;
|
||||||
import bisq.desktop.main.dao.bonding.BondingViewUtils;
|
|
||||||
import bisq.desktop.main.funds.transactions.DisplayedTransactionsFactory;
|
|
||||||
import bisq.desktop.main.funds.transactions.TradableRepository;
|
|
||||||
import bisq.desktop.main.funds.transactions.TransactionAwareTradableFactory;
|
|
||||||
import bisq.desktop.main.funds.transactions.TransactionListItemFactory;
|
|
||||||
import bisq.desktop.main.offer.offerbook.OfferBook;
|
|
||||||
import bisq.desktop.main.overlays.notifications.NotificationCenter;
|
|
||||||
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
|
|
||||||
import bisq.desktop.main.presentation.DaoPresentation;
|
|
||||||
import bisq.desktop.main.presentation.MarketPricePresentation;
|
|
||||||
import bisq.desktop.util.Transitions;
|
|
||||||
|
|
||||||
import bisq.core.app.AppOptionKeys;
|
import bisq.core.app.AppOptionKeys;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.util.BSFormatter;
|
|
||||||
import bisq.core.util.BsqFormatter;
|
|
||||||
|
|
||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
|
|
||||||
|
@ -57,32 +43,10 @@ public class DesktopModule extends AppModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(InjectorViewFactory.class).in(Singleton.class);
|
|
||||||
bind(ViewFactory.class).to(InjectorViewFactory.class);
|
bind(ViewFactory.class).to(InjectorViewFactory.class);
|
||||||
bind(CachingViewLoader.class).in(Singleton.class);
|
|
||||||
|
|
||||||
bind(ResourceBundle.class).toInstance(Res.getResourceBundle());
|
bind(ResourceBundle.class).toInstance(Res.getResourceBundle());
|
||||||
bind(ViewLoader.class).to(FxmlViewLoader.class).in(Singleton.class);
|
bind(ViewLoader.class).to(FxmlViewLoader.class).in(Singleton.class);
|
||||||
bind(CachingViewLoader.class).in(Singleton.class);
|
|
||||||
|
|
||||||
bind(Navigation.class).in(Singleton.class);
|
|
||||||
bind(NotificationCenter.class).in(Singleton.class);
|
|
||||||
|
|
||||||
bind(OfferBook.class).in(Singleton.class);
|
|
||||||
bind(BSFormatter.class).in(Singleton.class);
|
|
||||||
bind(BsqFormatter.class).in(Singleton.class);
|
|
||||||
bind(TorNetworkSettingsWindow.class).in(Singleton.class);
|
|
||||||
bind(MarketPricePresentation.class).in(Singleton.class);
|
|
||||||
bind(DaoPresentation.class).in(Singleton.class);
|
|
||||||
|
|
||||||
bind(Transitions.class).in(Singleton.class);
|
|
||||||
|
|
||||||
bind(TradableRepository.class).in(Singleton.class);
|
|
||||||
bind(TransactionListItemFactory.class).in(Singleton.class);
|
|
||||||
bind(TransactionAwareTradableFactory.class).in(Singleton.class);
|
|
||||||
bind(DisplayedTransactionsFactory.class).in(Singleton.class);
|
|
||||||
|
|
||||||
bind(BondingViewUtils.class).in(Singleton.class);
|
|
||||||
|
|
||||||
bindConstant().annotatedWith(Names.named(AppOptionKeys.APP_NAME_KEY)).to(environment.getRequiredProperty(AppOptionKeys.APP_NAME_KEY));
|
bindConstant().annotatedWith(Names.named(AppOptionKeys.APP_NAME_KEY)).to(environment.getRequiredProperty(AppOptionKeys.APP_NAME_KEY));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ import bisq.common.storage.Storage;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -41,6 +43,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Singleton
|
||||||
public final class Navigation implements PersistedDataHost {
|
public final class Navigation implements PersistedDataHost {
|
||||||
private static final ViewPath DEFAULT_VIEW_PATH = ViewPath.to(MainView.class, MarketView.class);
|
private static final ViewPath DEFAULT_VIEW_PATH = ViewPath.to(MainView.class, MarketView.class);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import bisq.desktop.common.view.ViewLoader;
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ import java.util.ResourceBundle;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.springframework.core.annotation.AnnotationUtils.getDefaultValue;
|
import static org.springframework.core.annotation.AnnotationUtils.getDefaultValue;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class FxmlViewLoader implements ViewLoader {
|
public class FxmlViewLoader implements ViewLoader {
|
||||||
|
|
||||||
private final ViewFactory viewFactory;
|
private final ViewFactory viewFactory;
|
||||||
|
|
|
@ -18,9 +18,11 @@
|
||||||
package bisq.desktop.common.view;
|
package bisq.desktop.common.view;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class CachingViewLoader implements ViewLoader {
|
public class CachingViewLoader implements ViewLoader {
|
||||||
|
|
||||||
private final HashMap<Object, View> cache = new HashMap<>();
|
private final HashMap<Object, View> cache = new HashMap<>();
|
||||||
|
|
|
@ -21,8 +21,11 @@ import bisq.desktop.common.view.ViewFactory;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class InjectorViewFactory implements ViewFactory {
|
public class InjectorViewFactory implements ViewFactory {
|
||||||
|
|
||||||
private Injector injector;
|
private Injector injector;
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.bitcoinj.core.Coin;
|
||||||
import org.bitcoinj.core.InsufficientMoneyException;
|
import org.bitcoinj.core.InsufficientMoneyException;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -56,6 +57,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Singleton
|
||||||
public class BondingViewUtils {
|
public class BondingViewUtils {
|
||||||
private final P2PService p2PService;
|
private final P2PService p2PService;
|
||||||
private final MyReputationListService myReputationListService;
|
private final MyReputationListService myReputationListService;
|
||||||
|
|
|
@ -20,7 +20,9 @@ package bisq.desktop.main.funds.transactions;
|
||||||
import bisq.core.btc.wallet.BtcWalletService;
|
import bisq.core.btc.wallet.BtcWalletService;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class DisplayedTransactionsFactory {
|
public class DisplayedTransactionsFactory {
|
||||||
private final BtcWalletService btcWalletService;
|
private final BtcWalletService btcWalletService;
|
||||||
private final TradableRepository tradableRepository;
|
private final TradableRepository tradableRepository;
|
||||||
|
|
|
@ -24,11 +24,13 @@ import bisq.core.trade.closed.ClosedTradableManager;
|
||||||
import bisq.core.trade.failed.FailedTradesManager;
|
import bisq.core.trade.failed.FailedTradesManager;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class TradableRepository {
|
public class TradableRepository {
|
||||||
private final OpenOfferManager openOfferManager;
|
private final OpenOfferManager openOfferManager;
|
||||||
private final TradeManager tradeManager;
|
private final TradeManager tradeManager;
|
||||||
|
|
|
@ -23,7 +23,9 @@ import bisq.core.trade.Tradable;
|
||||||
import bisq.core.trade.Trade;
|
import bisq.core.trade.Trade;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class TransactionAwareTradableFactory {
|
public class TransactionAwareTradableFactory {
|
||||||
private final DisputeManager disputeManager;
|
private final DisputeManager disputeManager;
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,13 @@ import bisq.core.util.BSFormatter;
|
||||||
import org.bitcoinj.core.Transaction;
|
import org.bitcoinj.core.Transaction;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class TransactionListItemFactory {
|
public class TransactionListItemFactory {
|
||||||
private final BtcWalletService btcWalletService;
|
private final BtcWalletService btcWalletService;
|
||||||
private final BsqWalletService bsqWalletService;
|
private final BsqWalletService bsqWalletService;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import bisq.core.offer.OfferBookService;
|
||||||
import bisq.core.trade.TradeManager;
|
import bisq.core.trade.TradeManager;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
@ -42,6 +43,7 @@ import static bisq.core.offer.OfferPayload.Direction.BUY;
|
||||||
* It also use OfferRepository.Listener as the lists items class and we don't want to get any dependency out of the
|
* It also use OfferRepository.Listener as the lists items class and we don't want to get any dependency out of the
|
||||||
* package for that.
|
* package for that.
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class OfferBook {
|
public class OfferBook {
|
||||||
private final OfferBookService offerBookService;
|
private final OfferBookService offerBookService;
|
||||||
|
|
|
@ -173,7 +173,7 @@ public abstract class Overlay<T extends Overlay> {
|
||||||
private HPos buttonAlignment = HPos.RIGHT;
|
private HPos buttonAlignment = HPos.RIGHT;
|
||||||
|
|
||||||
protected Optional<Runnable> closeHandlerOptional = Optional.<Runnable>empty();
|
protected Optional<Runnable> closeHandlerOptional = Optional.<Runnable>empty();
|
||||||
protected Optional<Runnable> actionHandlerOptional = Optional.<Runnable>empty();
|
protected Optional<Runnable> actionHandlerOptional = Optional.empty();
|
||||||
protected Optional<Runnable> secondaryActionHandlerOptional = Optional.<Runnable>empty();
|
protected Optional<Runnable> secondaryActionHandlerOptional = Optional.<Runnable>empty();
|
||||||
protected ChangeListener<Number> positionListener;
|
protected ChangeListener<Number> positionListener;
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ public abstract class Overlay<T extends Overlay> {
|
||||||
|
|
||||||
public T useShutDownButton() {
|
public T useShutDownButton() {
|
||||||
this.actionButtonText = Res.get("shared.shutDown");
|
this.actionButtonText = Res.get("shared.shutDown");
|
||||||
this.actionHandlerOptional = Optional.of(BisqApp.getShutDownHandler());
|
this.actionHandlerOptional = Optional.ofNullable(BisqApp.getShutDownHandler());
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ import bisq.common.UserThread;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.fxmisc.easybind.EasyBind;
|
import org.fxmisc.easybind.EasyBind;
|
||||||
import org.fxmisc.easybind.Subscription;
|
import org.fxmisc.easybind.Subscription;
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Singleton
|
||||||
public class NotificationCenter {
|
public class NotificationCenter {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -38,6 +38,7 @@ import bisq.common.util.Tuple4;
|
||||||
import bisq.common.util.Utilities;
|
import bisq.common.util.Utilities;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
@ -72,6 +73,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import static bisq.desktop.util.FormBuilder.*;
|
import static bisq.desktop.util.FormBuilder.*;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Singleton
|
||||||
public class TorNetworkSettingsWindow extends Overlay<TorNetworkSettingsWindow> {
|
public class TorNetworkSettingsWindow extends Overlay<TorNetworkSettingsWindow> {
|
||||||
|
|
||||||
public enum BridgeOption {
|
public enum BridgeOption {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import bisq.core.user.Preferences;
|
||||||
import bisq.common.app.DevEnv;
|
import bisq.common.app.DevEnv;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.DoubleProperty;
|
import javafx.beans.property.DoubleProperty;
|
||||||
|
@ -25,6 +26,7 @@ import javafx.collections.MapChangeListener;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class DaoPresentation implements DaoStateListener {
|
public class DaoPresentation implements DaoStateListener {
|
||||||
|
|
||||||
public static final String DAO_NEWS = "daoNewsVersion1.0.0";
|
public static final String DAO_NEWS = "daoNewsVersion1.0.0";
|
||||||
|
|
|
@ -35,6 +35,7 @@ import bisq.core.util.BSFormatter;
|
||||||
import bisq.common.UserThread;
|
import bisq.common.UserThread;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.fxmisc.easybind.EasyBind;
|
import org.fxmisc.easybind.EasyBind;
|
||||||
import org.fxmisc.easybind.Subscription;
|
import org.fxmisc.easybind.Subscription;
|
||||||
|
@ -60,6 +61,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class MarketPricePresentation {
|
public class MarketPricePresentation {
|
||||||
private final Preferences preferences;
|
private final Preferences preferences;
|
||||||
private final BSFormatter formatter;
|
private final BSFormatter formatter;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import bisq.core.user.Preferences;
|
||||||
import bisq.common.UserThread;
|
import bisq.common.UserThread;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
import javafx.animation.Interpolator;
|
import javafx.animation.Interpolator;
|
||||||
|
@ -39,6 +40,7 @@ import javafx.event.EventHandler;
|
||||||
|
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class Transitions {
|
public class Transitions {
|
||||||
|
|
||||||
public final static int DEFAULT_DURATION = 600;
|
public final static int DEFAULT_DURATION = 600;
|
||||||
|
|
73
desktop/src/test/java/bisq/desktop/GuiceSetupTest.java
Normal file
73
desktop/src/test/java/bisq/desktop/GuiceSetupTest.java
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
package bisq.desktop;
|
||||||
|
|
||||||
|
import bisq.desktop.app.BisqAppModule;
|
||||||
|
import bisq.desktop.common.view.CachingViewLoader;
|
||||||
|
import bisq.desktop.common.view.ViewLoader;
|
||||||
|
import bisq.desktop.common.view.guice.InjectorViewFactory;
|
||||||
|
import bisq.desktop.main.dao.bonding.BondingViewUtils;
|
||||||
|
import bisq.desktop.main.funds.transactions.DisplayedTransactionsFactory;
|
||||||
|
import bisq.desktop.main.funds.transactions.TradableRepository;
|
||||||
|
import bisq.desktop.main.funds.transactions.TransactionAwareTradableFactory;
|
||||||
|
import bisq.desktop.main.funds.transactions.TransactionListItemFactory;
|
||||||
|
import bisq.desktop.main.offer.offerbook.OfferBook;
|
||||||
|
import bisq.desktop.main.overlays.notifications.NotificationCenter;
|
||||||
|
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
|
||||||
|
import bisq.desktop.main.presentation.DaoPresentation;
|
||||||
|
import bisq.desktop.main.presentation.MarketPricePresentation;
|
||||||
|
import bisq.desktop.util.Transitions;
|
||||||
|
|
||||||
|
import bisq.core.app.AvoidStandbyModeService;
|
||||||
|
import bisq.core.app.BisqEnvironment;
|
||||||
|
import bisq.core.locale.CurrencyUtil;
|
||||||
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.core.util.BSFormatter;
|
||||||
|
import bisq.core.util.BsqFormatter;
|
||||||
|
|
||||||
|
import org.springframework.mock.env.MockPropertySource;
|
||||||
|
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
|
|
||||||
|
public class GuiceSetupTest {
|
||||||
|
|
||||||
|
private Injector injector;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
Res.setup();
|
||||||
|
CurrencyUtil.setup();
|
||||||
|
|
||||||
|
injector = Guice.createInjector(new BisqAppModule(new BisqEnvironment(new MockPropertySource())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGuiceSetup() {
|
||||||
|
injector.getInstance(AvoidStandbyModeService.class);
|
||||||
|
assertSingleton(OfferBook.class);
|
||||||
|
assertSingleton(CachingViewLoader.class);
|
||||||
|
assertSingleton(Navigation.class);
|
||||||
|
assertSingleton(InjectorViewFactory.class);
|
||||||
|
assertSingleton(NotificationCenter.class);
|
||||||
|
assertSingleton(BSFormatter.class);
|
||||||
|
assertSingleton(BsqFormatter.class);
|
||||||
|
assertSingleton(TorNetworkSettingsWindow.class);
|
||||||
|
assertSingleton(MarketPricePresentation.class);
|
||||||
|
assertSingleton(ViewLoader.class);
|
||||||
|
assertSingleton(DaoPresentation.class);
|
||||||
|
assertSingleton(Transitions.class);
|
||||||
|
assertSingleton(TradableRepository.class);
|
||||||
|
assertSingleton(TransactionListItemFactory.class);
|
||||||
|
assertSingleton(TransactionAwareTradableFactory.class);
|
||||||
|
assertSingleton(DisplayedTransactionsFactory.class);
|
||||||
|
assertSingleton(BondingViewUtils.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertSingleton(Class type) {
|
||||||
|
assertSame(injector.getInstance(type), injector.getInstance(type));
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,7 +42,7 @@ dependencyVerification {
|
||||||
'ch.qos.logback:logback-core:4cd46fa17d77057b39160058df2f21ebbc2aded51d0edcc25d2c1cecc042a005',
|
'ch.qos.logback:logback-core:4cd46fa17d77057b39160058df2f21ebbc2aded51d0edcc25d2c1cecc042a005',
|
||||||
'com.google.code.findbugs:jsr305:766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7',
|
'com.google.code.findbugs:jsr305:766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7',
|
||||||
'com.google.guava:guava:36a666e3b71ae7f0f0dca23654b67e086e6c93d192f60ba5dfd5519db6c288c8',
|
'com.google.guava:guava:36a666e3b71ae7f0f0dca23654b67e086e6c93d192f60ba5dfd5519db6c288c8',
|
||||||
'com.google.inject:guice:9b9df27a5b8c7864112b4137fd92b36c3f1395bfe57be42fedf2f520ead1a93e',
|
'com.google.inject:guice:d258ff1bd9b8b527872f8402648226658ad3149f1f40e74b0566d69e7e042fbc',
|
||||||
'com.github.bisq-network.bitcoinj:bitcoinj-core:f979c2187e61ee3b08dd4cbfc49a149734cff64c045d29ed112f2e12f34068a3',
|
'com.github.bisq-network.bitcoinj:bitcoinj-core:f979c2187e61ee3b08dd4cbfc49a149734cff64c045d29ed112f2e12f34068a3',
|
||||||
'com.github.JesusMcCloud.netlayer:tor:7950f8b44609eba2524941cb6517f43ade34e53c820aea849006e22eee93a83d',
|
'com.github.JesusMcCloud.netlayer:tor:7950f8b44609eba2524941cb6517f43ade34e53c820aea849006e22eee93a83d',
|
||||||
'org.jetbrains.kotlin:kotlin-stdlib-jdk8:193ab7813e4d249f2ea4fc1b968fea8c2126bcbeeb5d6127050ce1b93dbaa7c2',
|
'org.jetbrains.kotlin:kotlin-stdlib-jdk8:193ab7813e4d249f2ea4fc1b968fea8c2126bcbeeb5d6127050ce1b93dbaa7c2',
|
||||||
|
@ -80,4 +80,3 @@ dependencyVerification {
|
||||||
'org.jetbrains.kotlin:kotlin-stdlib-common:4b161ef619eee0d1a49b1c4f0c4a8e46f4e342573efd8e0106a765f47475fe39',
|
'org.jetbrains.kotlin:kotlin-stdlib-common:4b161ef619eee0d1a49b1c4f0c4a8e46f4e342573efd8e0106a765f47475fe39',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue