Some refactoring / removed current test classes

This commit is contained in:
7u83 2018-12-03 00:03:44 +01:00
parent 59998baa08
commit c30524b388
30 changed files with 245 additions and 526 deletions

View File

@ -24,7 +24,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.chart;
import opensesim.*;
/**
*

View File

@ -30,8 +30,8 @@ import java.awt.Window;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import opensesim.AbstractAsset;
import opensesim.World;
import opensesim.world.AbstractAsset;
import opensesim.world.World;
import opensesim.gui.util.EscDialog;
import opensesim.gui.Globals;

View File

@ -33,7 +33,7 @@ import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JDialog;
import javax.swing.JPanel;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
import opensesim.gui.Globals;
import opensesim.gui.util.Json.Export;
import opensesim.gui.util.Json.Import;

View File

@ -30,8 +30,8 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import opensesim.AbstractAsset;
import opensesim.World;
import opensesim.world.AbstractAsset;
import opensesim.world.World;
import opensesim.gui.Globals;
import org.json.JSONObject;

View File

@ -31,7 +31,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
import opensesim.gui.Globals;
import opensesim.gui.util.EscDialog;

View File

@ -1,8 +1,8 @@
package opensesim.gui.AssetPairEditor;
import java.util.Collection;
import opensesim.AbstractAsset;
import opensesim.World;
import opensesim.world.AbstractAsset;
import opensesim.world.World;
import opensesim.gui.Globals;
/*

View File

@ -25,7 +25,7 @@
*/
package opensesim.gui.AssetPairEditor;
import opensesim.World;
import opensesim.world.World;
import opensesim.gui.util.EscDialog;
import opensesim.gui.Globals;

View File

@ -47,8 +47,8 @@ import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import opensesim.AbstractAsset;
import opensesim.World;
import opensesim.world.AbstractAsset;
import opensesim.world.World;
import opensesim.gui.AssetEditor.AssetEditorPanel;
import org.json.JSONArray;
import org.json.JSONObject;
@ -299,7 +299,7 @@ public class Globals {
prefs = Preferences.userNodeForPackage(c);
world = new World();
// world = new World();
// initialize urllist used by class loader
updateUrlList();
@ -444,6 +444,13 @@ public class Globals {
putTraders(traders);
}
public static JSONObject getWorld(){
JSONObject world = new JSONObject();
world.put(PrefKeys.ASSETS, getAssets());
world.put(PrefKeys.EXCHANGES, getExchanges());
return world;
}
public static void clearAll() {
putStrategies(new JSONObject());

View File

@ -597,6 +597,12 @@ public class SeSimApplication extends javax.swing.JFrame {
}
void startSim() {
// World = new World();
resetSim();
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", "{}"));
@ -990,10 +996,11 @@ public class SeSimApplication extends javax.swing.JFrame {
Class<?> c = opensesim.gui.SeSimApplication.class;
Globals.initGlobals(c);
String world_source = Globals.prefs.get("world", "{}");
/* String world_source = Globals.prefs.get("world", "{}");
JSONObject world = new org.json.JSONObject(world_source);
Globals.world.putConfig(world);
*/
//Globals.installLookAndFeels();

View File

@ -25,8 +25,8 @@
*/
package opensesim.gui.exchangeeditor;
import opensesim.Exchange;
import opensesim.World;
import opensesim.world.Exchange;
import opensesim.world.World;
import opensesim.gui.Globals;
import opensesim.gui.util.Json.Export;
import opensesim.gui.util.Json.Import;

View File

@ -27,9 +27,9 @@ package opensesim.gui.exchangeeditor;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import opensesim.World;
import opensesim.world.World;
import opensesim.gui.Globals;
import opensesim.Exchange;
import opensesim.world.Exchange;
import org.json.JSONObject;
/**

View File

@ -25,10 +25,11 @@
*/
package opensesim.sesim;
import opensesim.world.Order;
import java.util.HashMap;
import java.util.SortedSet;
import java.util.TreeSet;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
import opensesim.sesim.interfaces.Asset;

View File

@ -25,7 +25,7 @@
*/
package opensesim.sesim.Assets;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
/**
*

View File

@ -25,7 +25,7 @@
*/
package opensesim.sesim.Assets;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
/**
*

View File

@ -26,7 +26,7 @@
package opensesim.sesim.Assets;
import javax.swing.JPanel;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
/**
*

View File

@ -25,7 +25,7 @@
*/
package opensesim.sesim.Assets;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
/**
*

View File

@ -25,7 +25,7 @@
*/
package opensesim.sesim.Assets;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
/**
*

View File

@ -1,67 +0,0 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class Order implements Comparable{
@Override
public int compareTo(Object o) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
/**
* Order status
*/
public enum Status {
OPEN, PARTIALLY_EXECUTED, CLOSED, CANCELED
}
/**
* Definition of order types
*/
public enum Type {
BUYLIMIT, SELLLIMIT, STOPLOSS, STOPBUY, BUY, SELL
}
protected double limit;
protected double volume;
public double getLimit() {
return limit;
}
public double getVolume() {
return volume;
}
AssetPair assetPair;
}

View File

@ -27,7 +27,7 @@ package opensesim.sesim.interfaces;
import java.util.HashMap;
import javax.swing.JPanel;
import opensesim.World;
import opensesim.world.World;
import opensesim.util.IDGenerator;
import opensesim.util.IDGenerator.Id;

View File

@ -25,7 +25,7 @@
*/
package opensesim.util;
import opensesim.AbstractAsset;
import opensesim.world.AbstractAsset;
/**
*

View File

@ -37,7 +37,7 @@ import java.util.Objects;
public class IDGenerator {
public static class Id {
public static class Id implements Comparable<Id>{
final Long value;
public Id(String id) {
@ -62,6 +62,15 @@ public class IDGenerator {
public String toString() {
return value.toString();
}
@Override
public int compareTo(Id o) {
if (this.value>o.value)
return 1;
if (this.value<o.value)
return -1;
return 0;
}
}

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim;
package opensesim.world;
import java.util.logging.Level;

View File

@ -23,9 +23,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim;
package opensesim.world;
import opensesim.Exchange;
import opensesim.world.Exchange;
import java.util.concurrent.ConcurrentHashMap;
import opensesim.sesim.interfaces.Asset;
import opensesim.sesim.interfaces.Trader;
@ -42,8 +42,5 @@ public class Account {
Account(Exchange exchange){
assets = new ConcurrentHashMap<>();
}
}

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim;
package opensesim.world;
import opensesim.sesim.AssetPair;
import opensesim.sesim.interfaces.FeeModel;

View File

@ -23,16 +23,15 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim;
package opensesim.world;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.SortedSet;
import java.util.TreeSet;
import opensesim.World;
import opensesim.world.World;
import opensesim.sesim.AssetPair;
import opensesim.sesim.Order;
import opensesim.sesim.interfaces.Configurable;
import org.json.JSONObject;
@ -78,7 +77,8 @@ public class Exchange implements Configurable{
}
public Order createOrder(Account account, AssetPair pair, Order.Type type, double volume, double limit) {
Order o = new Order(world,account,pair,type,volume,limit);
return null;
}

View File

@ -0,0 +1,174 @@
/*
* Copyo (c) 2018, 7u83 <7u83@mail.ru>
* All os reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyo notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyo notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.world;
import opensesim.world.Account;
import opensesim.world.World;
import opensesim.sesim.AssetPair;
import opensesim.util.IDGenerator;
import opensesim.util.IDGenerator.Id;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class Order implements Comparable<Order> {
@Override
public int compareTo(Order o) {
{
double d;
switch (this.type) {
case BUYLIMIT:
case STOPBUY:
case BUY:
d = o.limit - this.limit;
break;
case SELLLIMIT:
case STOPLOSS:
case SELL:
d = this.limit - o.limit;
break;
default:
d = 0;
}
if (d != 0) {
return d > 0 ? 1 : -1;
}
d = o.initial_volume - this.initial_volume;
if (d != 0) {
return d > 0 ? 1 : -1;
}
return this.id.compareTo(o.id);
}
}
public enum OrderStatus {
OPEN, PARTIALLY_EXECUTED, CLOSED, CANCELED
}
/**
* Definition of order types
*/
public enum Type {
BUYLIMIT, SELLLIMIT, STOPLOSS, STOPBUY, BUY, SELL
}
protected OrderStatus status;
protected Type type;
protected double limit;
protected double volume;
protected final double initial_volume;
protected final Id id;
protected final long created;
protected final Account account;
double cost;
World world;
Order(World world, Account account, AssetPair pair, Type type,
double volume, double limit) {
this.account = account;
this.type = type;
this.limit = limit;
this.volume = volume;
this.initial_volume = this.volume;
this.created = 0;
this.status = OrderStatus.OPEN;
this.cost = 0;
// id = Order.idGenerator.getNext();
this.world=world;
// id = world.
id = null;
}
public Id getID() {
return id;
}
public double getVolume() {
return volume;
}
public double getLimit() {
return limit;
}
public Type getType() {
return type;
}
public double getExecuted() {
return initial_volume - volume;
}
public double getInitialVolume() {
return initial_volume;
}
public double getCost() {
return cost;
}
public double getAvaragePrice() {
double e = getExecuted();
if (e <= 0) {
return -1;
}
return cost / e;
}
public Account getAccount() {
return account;
}
public OrderStatus getOrderStatus() {
return status;
}
public long getCreated() {
return created;
}
/**
* Get the stock symbol that this order belongs to
*
* @return Stock symbol
*/
public String getStockSymbol() {
// return stock.getSymbol();
return null;
}
}

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim;
package opensesim.world;
import java.util.ArrayList;
import java.util.Collection;
@ -44,9 +44,16 @@ import org.json.JSONObject;
*/
public class World implements Configurable {
public static final class JKEYS {
public static final String ASSETS = "assets";
public static final String EXCHANGES = "exchanges";
}
HashMap<Id, AbstractAsset> assetsById = new HashMap<>();
HashMap<String, AbstractAsset> assetsBySymbol = new HashMap<>();
IDGenerator assetIdGenerator = new IDGenerator();
IDGenerator orderIdGenerator = new IDGenerator();
HashSet<AssetPair> assetPairs = new HashSet<>();
@ -54,8 +61,10 @@ public class World implements Configurable {
/**
* Create a World object.
*
* @param world
*/
public World() {
public World(JSONObject world) {
}

View File

@ -1,111 +0,0 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim;
import opensesim.sesim.Assets.BasicAsset;
import opensesim.sesim.AssetPair;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AssetPairTest {
public AssetPairTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getAsset method, of class AssetPair.
*/
@Test
public void testGetAsset() {
System.out.println("getAsset");
AssetPair instance = new AssetPair(null,null);
opensesim.sesim.interfaces.Asset expResult = null;
opensesim.sesim.interfaces.Asset result = instance.getAsset();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
}
/**
* Test of getCurrency method, of class AssetPair.
*/
@Test
public void testGetCurrency() {
System.out.println("getCurrency");
AssetPair instance = new AssetPair(null,null);
opensesim.sesim.interfaces.Asset expResult = null;
opensesim.sesim.interfaces.Asset result = instance.getCurrency();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
}
/**
* Test of getSymbol method, of class AssetPair.
*/
@Test
public void testGetSymbol() {
System.out.println("getSymbol");
BasicAsset asset = new opensesim.sesim.Assets.BasicAsset("AAPL", "Apple", "Apple Inc.");
BasicAsset currency = new opensesim.sesim.Assets.BasicAsset("EUR", "Euro", "Euro desc");
AssetPair instance = new AssetPair(asset,currency);
String expResult = "AAPL/EUR";
String result = instance.getSymbol();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
}
}

View File

@ -1,230 +0,0 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim;
import opensesim.sesim.Assets.BasicAsset;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AssetTest {
public AssetTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getSymbol method, of class Asset.
*/
@Test
public void testGetSymbol() {
System.out.println("getSymbol");
BasicAsset instance = new BasicAsset();
String expResult = "EUR";
instance.setSymbol(expResult);
String result = instance.getSymbol();
assertEquals(expResult, result);
}
/**
* Test of getConfig method, of class Asset.
*/
@Test
public void testGetConfig() {
System.out.println("getConfig");
BasicAsset instance = new BasicAsset();
int decimals = 17;
String symbol = "EUR";
String description = "Eruo - Europaen currency";
String name = "Euro";
instance.setDecimals(decimals);
instance.setName(name);
instance.setDescription(description);
instance.setSymbol(symbol);
JSONObject result = instance.getConfig();
assertEquals(symbol, result.getString(BasicAsset.JSON_SYMBOL));
assertEquals(name, result.getString(BasicAsset.JSON_NAME));
assertEquals(description, result.getString(BasicAsset.JSON_DESCRIPTION));
assertEquals(decimals, result.getInt(BasicAsset.JSON_DECIMALS));
}
/**
* Test of putConfig method, of class Asset.
*/
@Test
public void testPutConfig() {
System.out.println("putConfig");
int decimals = 17;
String symbol = "EUR";
String name = "Euro";
String description = "Eruo - Europaen currency";
JSONObject cfg = new JSONObject();
cfg.put(BasicAsset.JSON_SYMBOL, symbol);
cfg.put(BasicAsset.JSON_NAME, name);
cfg.put(BasicAsset.JSON_DESCRIPTION, description);
cfg.put(BasicAsset.JSON_DECIMALS, decimals);
BasicAsset instance = new BasicAsset();
instance.putConfig(cfg);
assertEquals(symbol,instance.getSymbol());
assertEquals(name,instance.getName());
assertEquals(description,instance.getDescription());
assertEquals(decimals,instance.getDecimals());
}
/**
* Test of setSymbol method, of class Asset.
*/
@Test
public void testSetSymbol() {
System.out.println("setSymbol");
String symbol = "EUR";
BasicAsset instance = new BasicAsset();
instance.setSymbol(symbol);
String result = instance.getSymbol();
assertEquals(symbol, result);
}
/**
* Test of getName method, of class Asset.
*/
@Test
public void testGetName() {
System.out.println("getName");
BasicAsset instance = new BasicAsset();
String expResult = "Euro";
instance.setName(expResult);
String result = instance.getName();
assertEquals(expResult, result);
}
/**
* Test of setName method, of class Asset.
*/
@Test
public void testSetName() {
System.out.println("setName");
String name = "Euro";
BasicAsset instance = new BasicAsset();
instance.setName(name);
String result = instance.getName();
assertEquals(name, result);
}
/**
* Test of getDescription method, of class Asset.
*/
@Test
public void testGetDescription() {
System.out.println("getDescription");
BasicAsset instance = new BasicAsset();
String expResult = "Euro - European currency";
instance.setDescription(expResult);
String result = instance.getDescription();
assertEquals(expResult, result);
}
/**
* Test of setDescription method, of class Asset.
*/
@Test
public void testSetDescription() {
System.out.println("setDescription");
String description = "Eruo - Eruopean currency";
BasicAsset instance = new BasicAsset();
instance.setDescription(description);
String result = instance.getDescription();
assertEquals(description, result);
}
/**
* Test of getDecimals method, of class Asset.
*/
@Test
public void testGetDecimals() {
System.out.println("getDecimals");
BasicAsset instance = new BasicAsset();
int expResult = 7;
instance.setDecimals(expResult);
int result = instance.getDecimals();
assertEquals(expResult, result);
}
/**
* Test of setDecimals method, of class Asset.
*/
@Test
public void testSetDecimals() {
System.out.println("setDecimals");
int decimals;
decimals = 350;
BasicAsset instance = new BasicAsset();
instance.setDecimals(decimals);
int result = instance.getDecimals();
assertEquals(decimals, result);
}
}

View File

@ -1,76 +0,0 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim;
import opensesim.Exchange;
import opensesim.sesim.Assets.BasicAsset;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class ExchangeTest {
public ExchangeTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of add method, of class Exchange.
*/
@Test
public void testAdd() {
System.out.println("add");
BasicAsset a = new BasicAsset();
a.setSymbol("EUR");
Exchange instance = new Exchange();
instance.add(a);
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
}
}