Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small improvements/fixes #1728

Merged
merged 13 commits into from Sep 27, 2018
Expand Up @@ -38,10 +38,10 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static bisq.core.locale.TradeCurrencyMakers.usd;
import static bisq.core.user.PreferenceMakers.empty;
import static bisq.desktop.main.offer.offerbook.OfferBookListItemMaker.btcBuyItem;
import static bisq.desktop.main.offer.offerbook.OfferBookListItemMaker.btcSellItem;
import static bisq.desktop.maker.PreferenceMakers.empty;
import static bisq.desktop.maker.TradeCurrencyMakers.usd;
import static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
import static org.junit.Assert.assertEquals;
Expand Down
Expand Up @@ -54,7 +54,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static bisq.core.user.PreferenceMakers.empty;
import static bisq.desktop.maker.PreferenceMakers.empty;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
Expand Down
Expand Up @@ -17,15 +17,16 @@

package bisq.desktop.main.offer.offerbook;

import bisq.core.offer.OfferMaker;
import bisq.desktop.maker.OfferMaker;

import bisq.core.offer.OfferPayload;

import com.natpryce.makeiteasy.Instantiator;
import com.natpryce.makeiteasy.MakeItEasy;
import com.natpryce.makeiteasy.Maker;
import com.natpryce.makeiteasy.Property;

import static bisq.core.offer.OfferMaker.btcUsdOffer;
import static bisq.desktop.maker.OfferMaker.btcUsdOffer;
import static com.natpryce.makeiteasy.MakeItEasy.a;
import static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
Expand Down
Expand Up @@ -69,9 +69,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static bisq.core.locale.TradeCurrencyMakers.usd;
import static bisq.core.user.PreferenceMakers.empty;
import static bisq.desktop.main.offer.offerbook.OfferBookListItemMaker.*;
import static bisq.desktop.maker.PreferenceMakers.empty;
import static bisq.desktop.maker.TradeCurrencyMakers.usd;
import static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
import static org.junit.Assert.assertEquals;
Expand Down
Expand Up @@ -17,9 +17,10 @@

package bisq.desktop.main.settings.preferences;

import bisq.desktop.maker.PreferenceMakers;

import bisq.core.arbitration.Arbitrator;
import bisq.core.arbitration.ArbitratorManager;
import bisq.core.user.PreferenceMakers;
import bisq.core.user.Preferences;

import bisq.network.p2p.NodeAddress;
Expand Down
Expand Up @@ -15,22 +15,24 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.util;
package bisq.desktop.maker;

import bisq.desktop.util.CurrencyListItem;

import bisq.core.locale.TradeCurrency;

import com.natpryce.makeiteasy.Instantiator;
import com.natpryce.makeiteasy.Maker;
import com.natpryce.makeiteasy.Property;

import static bisq.core.locale.TradeCurrencyMakers.bitcoin;
import static bisq.core.locale.TradeCurrencyMakers.euro;
import static bisq.desktop.maker.TradeCurrencyMakers.bitcoin;
import static bisq.desktop.maker.TradeCurrencyMakers.euro;
import static com.natpryce.makeiteasy.MakeItEasy.a;
import static com.natpryce.makeiteasy.MakeItEasy.with;

public class CurrencyListItemMakers {

public static final Property<CurrencyListItem, TradeCurrency> tradeCurrency = new Property<>();
public static final Property<bisq.desktop.util.CurrencyListItem, TradeCurrency> tradeCurrency = new Property<>();
public static final Property<CurrencyListItem, Integer> numberOfTrades = new Property<>();

public static final Instantiator<CurrencyListItem> CurrencyListItem = lookup ->
Expand Down
82 changes: 82 additions & 0 deletions desktop/src/test/java/bisq/desktop/maker/OfferMaker.java
@@ -0,0 +1,82 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.maker;

import bisq.core.offer.Offer;
import bisq.core.offer.OfferPayload;

import com.natpryce.makeiteasy.Instantiator;
import com.natpryce.makeiteasy.Maker;
import com.natpryce.makeiteasy.Property;

import static com.natpryce.makeiteasy.MakeItEasy.a;

public class OfferMaker {

public static final Property<Offer, Long> price = new Property<>();
public static final Property<Offer, Long> minAmount = new Property<>();
public static final Property<Offer, Long> amount = new Property<>();
public static final Property<Offer, String> baseCurrencyCode = new Property<>();
public static final Property<Offer, String> counterCurrencyCode = new Property<>();
public static final Property<Offer, OfferPayload.Direction> direction = new Property<>();
public static final Property<Offer, Boolean> useMarketBasedPrice = new Property<>();
public static final Property<Offer, Double> marketPriceMargin = new Property<>();
public static final Property<Offer, String> id = new Property<>();

public static final Instantiator<Offer> Offer = lookup -> new Offer(
new OfferPayload(lookup.valueOf(id, "1234"),
0L,
null,
null,
lookup.valueOf(direction, OfferPayload.Direction.BUY),
lookup.valueOf(price, 100000L),
lookup.valueOf(marketPriceMargin, 0.0),
lookup.valueOf(useMarketBasedPrice, false),
lookup.valueOf(amount, 100000L),
lookup.valueOf(minAmount, 100000L),
lookup.valueOf(baseCurrencyCode, "BTC"),
lookup.valueOf(counterCurrencyCode, "USD"),
null,
null,
"SEPA",
"",
null,
null,
null,
null,
null,
"",
0L,
0L,
0L,
false,
0L,
0L,
0L,
0L,
false,
false,
0L,
0L,
false,
null,
null,
0));

public static final Maker<Offer> btcUsdOffer = a(Offer);
}
Expand Up @@ -15,9 +15,10 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.user;
package bisq.desktop.maker;

import bisq.core.app.BisqEnvironment;
import bisq.core.user.Preferences;

import bisq.common.storage.Storage;

Expand All @@ -30,7 +31,7 @@

public class PreferenceMakers {

public static final Property<Preferences, Storage> storage = new Property<>();
public static final Property<bisq.core.user.Preferences, Storage> storage = new Property<>();
public static final Property<Preferences, BisqEnvironment> bisqEnvironment = new Property<>();
public static final Property<Preferences, String> btcNodesFromOptions = new Property<>();
public static final Property<Preferences, String> useTorFlagFromOptions = new Property<>();
Expand Down
Expand Up @@ -15,7 +15,10 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.monetary;
package bisq.desktop.maker;

import bisq.core.monetary.Altcoin;
import bisq.core.monetary.Price;

import org.bitcoinj.utils.Fiat;

Expand Down
Expand Up @@ -15,7 +15,11 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.locale;
package bisq.desktop.maker;

import bisq.core.locale.CryptoCurrency;
import bisq.core.locale.FiatCurrency;
import bisq.core.locale.TradeCurrency;

import com.natpryce.makeiteasy.Instantiator;
import com.natpryce.makeiteasy.Property;
Expand All @@ -29,10 +33,10 @@ public class TradeCurrencyMakers {
public static final Property<TradeCurrency, String> currencyCode = new Property<>();
public static final Property<TradeCurrency, String> currencyName = new Property<>();

public static final Instantiator<CryptoCurrency> CryptoCurrency = lookup ->
public static final Instantiator<bisq.core.locale.CryptoCurrency> CryptoCurrency = lookup ->
new CryptoCurrency(lookup.valueOf(currencyCode, "BTC"), lookup.valueOf(currencyName, "Bitcoin"));

public static final Instantiator<FiatCurrency> FiatCurrency = lookup ->
public static final Instantiator<bisq.core.locale.FiatCurrency> FiatCurrency = lookup ->
new FiatCurrency(lookup.valueOf(currencyCode, "EUR"));

public static final CryptoCurrency bitcoin = make(a(CryptoCurrency));
Expand Down
Expand Up @@ -15,7 +15,10 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.monetary;
package bisq.desktop.maker;

import bisq.core.monetary.Altcoin;
import bisq.core.monetary.Volume;

import org.bitcoinj.utils.Fiat;

Expand Down
10 changes: 5 additions & 5 deletions desktop/src/test/java/bisq/desktop/util/BSFormatterTest.java
Expand Up @@ -37,11 +37,11 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static bisq.core.monetary.PriceMaker.priceString;
import static bisq.core.monetary.PriceMaker.usdPrice;
import static bisq.core.monetary.VolumeMaker.usdVolume;
import static bisq.core.monetary.VolumeMaker.volumeString;
import static bisq.core.offer.OfferMaker.btcUsdOffer;
import static bisq.desktop.maker.OfferMaker.btcUsdOffer;
import static bisq.desktop.maker.PriceMaker.priceString;
import static bisq.desktop.maker.PriceMaker.usdPrice;
import static bisq.desktop.maker.VolumeMaker.usdVolume;
import static bisq.desktop.maker.VolumeMaker.volumeString;
import static com.natpryce.makeiteasy.MakeItEasy.a;
import static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
Expand Down
12 changes: 6 additions & 6 deletions desktop/src/test/java/bisq/desktop/util/GUIUtilTest.java
Expand Up @@ -30,12 +30,12 @@
import org.junit.Before;
import org.junit.Test;

import static bisq.core.locale.TradeCurrencyMakers.bitcoin;
import static bisq.core.locale.TradeCurrencyMakers.euro;
import static bisq.core.user.PreferenceMakers.empty;
import static bisq.desktop.util.CurrencyListItemMakers.bitcoinItem;
import static bisq.desktop.util.CurrencyListItemMakers.euroItem;
import static bisq.desktop.util.CurrencyListItemMakers.numberOfTrades;
import static bisq.desktop.maker.CurrencyListItemMakers.bitcoinItem;
import static bisq.desktop.maker.CurrencyListItemMakers.euroItem;
import static bisq.desktop.maker.CurrencyListItemMakers.numberOfTrades;
import static bisq.desktop.maker.PreferenceMakers.empty;
import static bisq.desktop.maker.TradeCurrencyMakers.bitcoin;
import static bisq.desktop.maker.TradeCurrencyMakers.euro;
import static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
import static org.junit.Assert.assertEquals;
Expand Down