From f2bfaee5d769443c7dc02ef0cc8fbc80d9f69072 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@mail.ru> Date: Wed, 5 Dec 2018 20:07:36 +0100 Subject: [PATCH] WorldAdm generates --- nbproject/project.properties | 2 +- src/opensesim/world/Account.java | 21 +++++++++++++++++++++ src/opensesim/world/World.java | 4 ++++ src/opensesim/world/WorldAdm.java | 3 ++- test/opensesim/world/ExchangeTest.java | 19 +++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index 629da03..cb1916b 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Wed, 05 Dec 2018 19:04:38 +0100 +#Wed, 05 Dec 2018 20:01:07 +0100 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= diff --git a/src/opensesim/world/Account.java b/src/opensesim/world/Account.java index df7dbc1..0fcbd55 100644 --- a/src/opensesim/world/Account.java +++ b/src/opensesim/world/Account.java @@ -25,8 +25,12 @@ */ package opensesim.world; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; import opensesim.world.Exchange; import java.util.concurrent.ConcurrentHashMap; +import static jdk.vm.ci.code.CodeUtil.K; import opensesim.sesim.interfaces.Asset; import opensesim.sesim.interfaces.Trader; @@ -38,9 +42,26 @@ public class Account { ConcurrentHashMap assets; Trader owner; + Exchange exchange; + + public Map getAssets() { + return Collections.unmodifiableMap(assets); + } + + public Trader getOwner() { + return owner; + } + + public Exchange getExchange() { + return exchange; + } Account(Exchange exchange){ assets = new ConcurrentHashMap<>(); } + + Account(long masterKey){ + + } } diff --git a/src/opensesim/world/World.java b/src/opensesim/world/World.java index bb3a02f..2cfc1be 100644 --- a/src/opensesim/world/World.java +++ b/src/opensesim/world/World.java @@ -124,6 +124,10 @@ public class World implements GetJson { this.masterkey=masterkey; putJson(cfg); } + + public boolean checkMasterKey(long masterkey){ + return masterkey == this.masterkey; + } private AbstractAsset createAsset_p(JSONObject cfg) throws SeSimException { AbstractAsset a; diff --git a/src/opensesim/world/WorldAdm.java b/src/opensesim/world/WorldAdm.java index 92b4495..e02dd65 100644 --- a/src/opensesim/world/WorldAdm.java +++ b/src/opensesim/world/WorldAdm.java @@ -25,6 +25,7 @@ */ package opensesim.world; +import java.util.Random; import org.json.JSONObject; /** @@ -35,7 +36,7 @@ public class WorldAdm { public World world; public long masterKey; public WorldAdm(JSONObject cfg){ - masterKey = 123456; + masterKey = new Random().nextLong(); world = new World(cfg,masterKey); } diff --git a/test/opensesim/world/ExchangeTest.java b/test/opensesim/world/ExchangeTest.java index 1f573ec..59fa8f9 100644 --- a/test/opensesim/world/ExchangeTest.java +++ b/test/opensesim/world/ExchangeTest.java @@ -61,4 +61,23 @@ public class ExchangeTest { } + + + /** + * Test of createAccount method, of class Exchange. + */ + @Test + public void testCreateAccount() { + System.out.println("createAccount"); + Exchange instance = new Exchange(null,(JSONObject)null); + Account expResult = null; + Account result = instance.createAccount(); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + + + }