Skip to content

Commit

Permalink
#1061 introduce new view port action to include key of created row of…
Browse files Browse the repository at this point in the history
… a table in the response
  • Loading branch information
naleeha committed Jan 2, 2024
1 parent 4e88476 commit 95aebe1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.typesafe.scalalogging.StrictLogging
import org.finos.toolbox.time.Clock
import org.finos.vuu.core.module.basket.BasketConstants.Side
import org.finos.vuu.core.module.basket.BasketModule
import org.finos.vuu.core.module.basket.BasketModule.{BasketConstituentTable}
import org.finos.vuu.core.module.basket.BasketModule.BasketConstituentTable
import org.finos.vuu.core.table.{DataTable, RowData, RowWithData, TableContainer}
import org.finos.vuu.net.rpc.RpcHandler
import org.finos.vuu.net.{ClientSessionId, RequestContext}
Expand All @@ -15,11 +15,9 @@ import java.util.concurrent.atomic.AtomicInteger
object BasketTradeId {

private val counter: AtomicInteger = new AtomicInteger(0)
var current:String = "NoneInitalised" //this is for testing but only works if tests that use this doesnt run in parallel
def oneNew(user:String): String = {
val counterValue = counter.incrementAndGet()
current = user + "-" + "".padTo(5 - counterValue.toString.length, "0").mkString + counterValue
current
user + "-" + "".padTo(5 - counterValue.toString.length, "0").mkString + counterValue
}
}

Expand Down Expand Up @@ -103,7 +101,7 @@ class BasketService(val table: DataTable, val tableContainer: TableContainer, va
logger.error("Cannot find the Basket Trading Constituent.")
}

NoAction()
ViewPortCreateSuccess(basketTradeId)
}

override def menuItems(): ViewPortMenu = ViewPortMenu(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import org.finos.vuu.api.ViewPortDef
import org.finos.vuu.core.module.TableDefContainer
import org.finos.vuu.core.module.basket.service.{BasketServiceIF, BasketTradeId, BasketTradingServiceIF}
import org.finos.vuu.core.module.price.PriceModule
import org.finos.vuu.core.table.TableTestHelper.combineQs
import org.finos.vuu.order.oms.OmsApi
import org.finos.vuu.test.VuuServerTestCase
import org.finos.vuu.util.table.TableAsserts.assertVpEq
import org.finos.vuu.viewport.ViewPortCreateSuccess
import org.scalatest.prop.Tables.Table

class BasketCreateTest extends VuuServerTestCase {
Expand Down Expand Up @@ -54,21 +54,24 @@ class BasketCreateTest extends VuuServerTestCase {

val basketService = vuuServer.getViewPortRpcServiceProxy[BasketServiceIF](viewportBasket)

val action = basketService.createBasket(".FTSE", "TestBasket")(vuuServer.requestContext)
val vpAction = basketService.createBasket(".FTSE", "TestBasket")(vuuServer.requestContext)

assert(vpAction.isInstanceOf[ViewPortCreateSuccess])
val basketTradeInstanceId = vpAction.asInstanceOf[ViewPortCreateSuccess].key

val viewportBasketTrading = vuuServer.createViewPort(BasketModule.NAME, BasketTradingTable)

val basketTradingService = vuuServer.getViewPortRpcServiceProxy[BasketTradingServiceIF](viewportBasketTrading)

//CJS: I don't like this forced cast, need to look at that a bit
basketTradingService.editCellAction().func(BasketTradeId.current, BT.Units, 100.asInstanceOf[Object], viewportBasketTrading, vuuServer.session)
basketTradingService.editCellAction().func(basketTradeInstanceId, BT.Units, 100.asInstanceOf[Object], viewportBasketTrading, vuuServer.session)

vuuServer.runOnce()

assertVpEq(combineQsForVp(viewportBasketTrading)) {
Table(
("basketId", "instanceId", "basketName", "units", "status", "filledPct", "totalNotionalUsd", "totalNotional", "fxRateToUsd", "side"),
(".FTSE", BasketTradeId.current, "TestBasket", 100, "OFF-MARKET", null, null, null, null, "BUY")
(".FTSE", basketTradeInstanceId, "TestBasket", 100, "OFF-MARKET", null, null, null, null, "BUY")
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.finos.vuu.core.module.price.PriceModule
import org.finos.vuu.order.oms.OmsApi
import org.finos.vuu.test.{TestVuuServer, VuuServerTestCase}
import org.finos.vuu.util.table.TableAsserts.assertVpEq
import org.finos.vuu.viewport.ViewPortCreateSuccess
import org.scalatest.prop.Tables.Table

class BasketMutateOffMarketTest extends VuuServerTestCase {
Expand Down Expand Up @@ -68,8 +69,9 @@ class BasketMutateOffMarketTest extends VuuServerTestCase {

Then("Get the Basket RPC Service and call create basket")
val basketService = vuuServer.getViewPortRpcServiceProxy[BasketServiceIF](vpBasket)
basketService.createBasket(".FTSE", "MyCustomBasket")(vuuServer.requestContext)
val basketTradeInstanceId = BasketTradeId.current
val vpAction = basketService.createBasket(".FTSE", "MyCustomBasket")(vuuServer.requestContext)
assert(vpAction.isInstanceOf[ViewPortCreateSuccess])
val basketTradeInstanceId = vpAction.asInstanceOf[ViewPortCreateSuccess].key

val vpBasketTrading = vuuServer.createViewPort(BasketModule.NAME, BasketTradingTable)

Expand Down Expand Up @@ -152,8 +154,7 @@ class BasketMutateOffMarketTest extends VuuServerTestCase {

vuuServer.login("testUser", "testToken2")

GivenBasketTradeExist(vuuServer, ".FTSE", "MyCustomBasket")
val basketTradeInstanceId = BasketTradeId.current
val basketTradeInstanceId = GivenBasketTradeExist(vuuServer, ".FTSE", "MyCustomBasket")

val vpBasketTrading = vuuServer.createViewPort(BasketModule.NAME, BasketTradingTable)
val vpBasketTradingCons = vuuServer.createViewPort(BasketModule.NAME, BasketTradingConstituentTable)
Expand Down Expand Up @@ -233,7 +234,7 @@ class BasketMutateOffMarketTest extends VuuServerTestCase {
// }
}

def GivenBasketTradeExist(vuuServer: TestVuuServer, basketId: String, basketTradeName: String): Unit = {
def GivenBasketTradeExist(vuuServer: TestVuuServer, basketId: String, basketTradeName: String): String = {
val basketProvider = vuuServer.getProvider(BasketModule.NAME, BasketModule.BasketTable)
basketProvider.tick(".FTSE", Map(B.Id -> ".FTSE", B.Name -> ".FTSE 100", B.NotionalValue -> 1000001, B.NotionalValueUsd -> 1500001))

Expand All @@ -244,6 +245,8 @@ class BasketMutateOffMarketTest extends VuuServerTestCase {

val vpBasket = vuuServer.createViewPort(BasketModule.NAME, BasketModule.BasketTable)
val basketService = vuuServer.getViewPortRpcServiceProxy[BasketServiceIF](vpBasket)
basketService.createBasket(basketId, basketTradeName)(vuuServer.requestContext)
val vpAction = basketService.createBasket(basketId, basketTradeName)(vuuServer.requestContext)
assert(vpAction.isInstanceOf[ViewPortCreateSuccess])
vpAction.asInstanceOf[ViewPortCreateSuccess].key
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.finos.vuu.core.module.price.PriceModule
import org.finos.vuu.order.oms.OmsApi
import org.finos.vuu.test.VuuServerTestCase
import org.finos.vuu.util.table.TableAsserts.assertVpEq
import org.finos.vuu.viewport.ViewPortCreateSuccess
import org.scalatest.prop.Tables.Table

class BasketSendToMarketTest extends VuuServerTestCase {
Expand Down Expand Up @@ -50,8 +51,9 @@ class BasketSendToMarketTest extends VuuServerTestCase {
Then("Get the Basket RPC Service and call create basket")
val basketService = vuuServer.getViewPortRpcServiceProxy[BasketServiceIF](vpBasket)

basketService.createBasket(".FTSE", "TestBasket")(vuuServer.requestContext)
val basketTradeInstanceId = BasketTradeId.current
val vpAction = basketService.createBasket(".FTSE", "TestBasket")(vuuServer.requestContext)
assert(vpAction.isInstanceOf[ViewPortCreateSuccess])
val basketTradeInstanceId = vpAction.asInstanceOf[ViewPortCreateSuccess].key

val vpBasketTrading = vuuServer.createViewPort(BasketModule.NAME, BasketTradingTable)
val vpBasketTradingCons = vuuServer.createViewPort(BasketModule.NAME, BasketTradingConstituentTable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ import org.finos.vuu.net.rpc.VsJsonTypeResolver
@JsonTypeIdResolver(classOf[VsJsonTypeResolver])
trait ViewPortAction {}



case class NoAction() extends ViewPortAction

case class OpenDialogViewPortAction(table: ViewPortTable, renderComponent: String = "grid") extends ViewPortAction


case class CloseDialogViewPortAction(vpId: String) extends ViewPortAction

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
Expand All @@ -27,5 +24,6 @@ case class CloseDialogViewPortAction(vpId: String) extends ViewPortAction
new Type(value = classOf[ViewPortEditFailure], name = "VP_EDIT_FAILURE"),
new Type(value = classOf[ViewPortRpcSuccess], name = "VP_RPC_SUCCESS"),
new Type(value = classOf[ViewPortRpcFailure], name = "VP_RPC_FAILURE"),
new Type(value = classOf[ViewPortCreateSuccess], name = "VP_CREATE_SUCCESS"),
))
trait ViewPortActionMixin {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ case class ViewPortEditSuccess() extends ViewPortEditAction {}
case class ViewPortRpcSuccess() extends ViewPortAction {}
case class ViewPortRpcFailure(msg: String) extends ViewPortAction {}
case class ViewPortEditFailure(msg: String) extends ViewPortEditAction {}
case class ViewPortCreateSuccess(key:String) extends ViewPortAction

case class ViewPortEditCellAction(filter: String, func: (String, String, Object, ViewPort, ClientSessionId) => ViewPortEditAction){
final val rpcName = "VP_EDIT_CELL"
Expand Down

0 comments on commit 95aebe1

Please sign in to comment.