Skip to content

Commit

Permalink
finos#1052 test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
naleeha authored and chrisjstevo committed Jan 4, 2024
1 parent f642702 commit 39c2e71
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 39c2e71

Please sign in to comment.