From 39c2e719e869b037f7de0b32851872a03235507f Mon Sep 17 00:00:00 2001 From: Na Lee Ha Date: Fri, 15 Dec 2023 16:57:28 +0000 Subject: [PATCH] #1052 test cleanup --- .../basket/BasketMutateOffMarketTest.scala | 87 +++++++++---------- .../finos/vuu/csv/CsvStaticLoaderTests.scala | 7 +- 2 files changed, 44 insertions(+), 50 deletions(-) diff --git a/example/basket/src/test/scala/org/finos/vuu/core/module/basket/BasketMutateOffMarketTest.scala b/example/basket/src/test/scala/org/finos/vuu/core/module/basket/BasketMutateOffMarketTest.scala index 666091a19..c54e31162 100644 --- a/example/basket/src/test/scala/org/finos/vuu/core/module/basket/BasketMutateOffMarketTest.scala +++ b/example/basket/src/test/scala/org/finos/vuu/core/module/basket/BasketMutateOffMarketTest.scala @@ -188,50 +188,49 @@ class BasketMutateOffMarketTest extends VuuServerTestCase { } //TODO join table cannot be tested currently as it doesnt get updated when underlying table gets updated -// Scenario("Adding new constituents by ric should add it to basket trading") { -// import BasketModule._ -// implicit val clock: Clock = new TestFriendlyClock(10001L) -// implicit val lifecycle: LifecycleContainer = new LifecycleContainer() -// implicit val tableDefContainer: TableDefContainer = new TableDefContainer(Map()) -// implicit val metricsProvider: MetricsProvider = new MetricsProviderImpl -// -// val omsApi = OmsApi() -// withVuuServer(PriceModule(), BasketModule(omsApi)) { -// vuuServer => -// -// vuuServer.login("testUser", "testToken2") -// -// GivenBasketTradeExist(vuuServer, ".FTSE", "MyCustomBasket") -// val basketTradeInstanceId = BasketTradeId.current -// -// val vpBasketTrading = vuuServer.createViewPort(BasketModule.NAME, BasketTradingTable) -// val vpBasketTradingCons = vuuServer.createViewPort(BasketModule.NAME, BasketTradingConstituentTable) -// val vpBasketTradingConsJoin = vuuServer.createViewPort(BasketModule.NAME, BasketTradingConstituentJoin) -// val basketTradingConstituentJoinService = vuuServer.getViewPortRpcServiceProxy[BasketTradingConstituentJoinServiceIF](vpBasketTradingConsJoin) -// -// vuuServer.runOnce() -// -// When("we edit the side of the parent basket to same side as current value") -// basketTradingConstituentJoinService.addConstituent("0001.HK")(vuuServer.requestContext) -// vuuServer.runOnce() -// -// Then("get all the updates that have occurred for all view ports from the outbound queue") -// val updates = combineQs(vpBasketTradingConsJoin) -// -// //todo should basketid be where the stock was sourced from? in this case .HSI? -// -// And("assert the basket trading constituent table has added row") -// assertVpEq(filterByVp(vpBasketTradingCons, updates)) { -// Table( -// ("quantity", "side", "instanceId", "instanceIdRic", "basketId", "ric", "description", "notionalUsd", "notionalLocal", "venue", "algo", "algoParams", "pctFilled", "weighting", "priceSpread", "limitPrice", "priceStrategyId", "filledQty", "orderStatus"), -// (10L, "BUY", basketTradeInstanceId, s"$basketTradeInstanceId.BP.L", ".FTSE", "BP.L", "Beyond Petroleum", null, null, null, -1, null, null, 0.1, null, null, 2, 0, "PENDING"), -// (10L, "SELL", basketTradeInstanceId, s"$basketTradeInstanceId.BT.L", ".FTSE", "BT.L", "British Telecom", null, null, null, -1, null, null, 0.1, null, null, 2, 0, "PENDING"), -// (10L, "BUY", basketTradeInstanceId, s"$basketTradeInstanceId.VOD.L", ".FTSE", "VOD.L", "Vodafone", null, null, null, -1, null, null, 0.1, null, null, 2, 0, "PENDING"), -// (10L, "BUY", basketTradeInstanceId, s"$basketTradeInstanceId.0001.HK", ".FTSE", "0001.HK", "", null, null, null, -1, null, null, 0.1, null, null, 2, 0, "PENDING") -// ) -// } -// } -// } + ignore("Adding new constituents by ric should add it to basket trading") { + import BasketModule._ + implicit val clock: Clock = new TestFriendlyClock(10001L) + implicit val lifecycle: LifecycleContainer = new LifecycleContainer() + implicit val tableDefContainer: TableDefContainer = new TableDefContainer(Map()) + implicit val metricsProvider: MetricsProvider = new MetricsProviderImpl + + val omsApi = OmsApi() + withVuuServer(PriceModule(), BasketModule(omsApi)) { + vuuServer => + + vuuServer.login("testUser", "testToken2") + + val basketTradeInstanceId = GivenBasketTradeExist(vuuServer, ".FTSE", "MyCustomBasket") + + val vpBasketTrading = vuuServer.createViewPort(BasketModule.NAME, BasketTradingTable) + val vpBasketTradingCons = vuuServer.createViewPort(BasketModule.NAME, BasketTradingConstituentTable) + val vpBasketTradingConsJoin = vuuServer.createViewPort(BasketModule.NAME, BasketTradingConstituentJoin) + val basketTradingConstituentJoinService = vuuServer.getViewPortRpcServiceProxy[BasketTradingConstituentJoinServiceIF](vpBasketTradingConsJoin) + + vuuServer.runOnce() + + When("we edit the side of the parent basket to same side as current value") + basketTradingConstituentJoinService.addConstituent("0001.HK")(vuuServer.requestContext) + vuuServer.runOnce() + + Then("get all the updates that have occurred for all view ports from the outbound queue") + val updates = combineQs(vpBasketTradingConsJoin) + + //todo should basketid be where the stock was sourced from? in this case .HSI? + + And("assert the basket trading constituent table has added row") + assertVpEq(filterByVp(vpBasketTradingCons, updates)) { + Table( + ("quantity", "side", "instanceId", "instanceIdRic", "basketId", "ric", "description", "notionalUsd", "notionalLocal", "venue", "algo", "algoParams", "pctFilled", "weighting", "priceSpread", "limitPrice", "priceStrategyId", "filledQty", "orderStatus"), + (10L, "BUY", basketTradeInstanceId, s"$basketTradeInstanceId.BP.L", ".FTSE", "BP.L", "Beyond Petroleum", null, null, null, -1, null, null, 0.1, null, null, 2, 0, "PENDING"), + (10L, "SELL", basketTradeInstanceId, s"$basketTradeInstanceId.BT.L", ".FTSE", "BT.L", "British Telecom", null, null, null, -1, null, null, 0.1, null, null, 2, 0, "PENDING"), + (10L, "BUY", basketTradeInstanceId, s"$basketTradeInstanceId.VOD.L", ".FTSE", "VOD.L", "Vodafone", null, null, null, -1, null, null, 0.1, null, null, 2, 0, "PENDING"), + (10L, "BUY", basketTradeInstanceId, s"$basketTradeInstanceId.0001.HK", ".FTSE", "0001.HK", "", null, null, null, -1, null, null, 0.1, null, null, 2, 0, "PENDING") + ) + } + } + } } def GivenBasketTradeExist(vuuServer: TestVuuServer, basketId: String, basketTradeName: String): String = { diff --git a/example/basket/src/test/scala/org/finos/vuu/csv/CsvStaticLoaderTests.scala b/example/basket/src/test/scala/org/finos/vuu/csv/CsvStaticLoaderTests.scala index 03609aae7..e2d6ed5d0 100644 --- a/example/basket/src/test/scala/org/finos/vuu/csv/CsvStaticLoaderTests.scala +++ b/example/basket/src/test/scala/org/finos/vuu/csv/CsvStaticLoaderTests.scala @@ -10,12 +10,7 @@ class CsvStaticLoaderTests extends AnyFeatureSpec{ Feature("CSV loading Test Case") { Scenario("Can successfully load and parse basket constituents") { - var path = getClass.getResource("/constituents") - //his.class.getResourceAsStream("/myfile") - var x = ClassLoader.getSystemResource("") -// var x = Source.fromURL(path) -// var B = Source.fromResource("/static") - val testResourcePath = this.getClass().getResource("/constituents").getPath + val testResourcePath = this.getClass.getResource("/constituents").getPath val constituents = CsvStaticLoader.loadConstituent(".FTSE100", Some(testResourcePath)) assert(constituents.length == 3)