From 0ac0ce7a07dbff9881e3bf7dcaafd8e34baf380f Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 7 Jun 2023 20:34:49 +0100 Subject: [PATCH] #744 removed emptybviewport on disable call --- .../core/module/editable/EditableModule.scala | 2 +- .../editable/FixSequenceRpcService.scala | 2 +- .../vuu/viewport/ViewPortContainer.scala | 3 +- .../disable/DisableViewPortTest.scala | 67 +++++++++++++++++++ 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 vuu/src/test/scala/org/finos/vuu/viewport/disable/DisableViewPortTest.scala diff --git a/vuu/src/main/scala/org/finos/vuu/core/module/editable/EditableModule.scala b/vuu/src/main/scala/org/finos/vuu/core/module/editable/EditableModule.scala index 6bfa77050..718f2ee2c 100644 --- a/vuu/src/main/scala/org/finos/vuu/core/module/editable/EditableModule.scala +++ b/vuu/src/main/scala/org/finos/vuu/core/module/editable/EditableModule.scala @@ -32,7 +32,7 @@ object EditableModule extends DefaultModule { SessionTableDef( name = "fixSequenceReset", keyField = "process-id", - columns = Columns.fromNames("process-id:String", "sequenceNumber:Long") + columns = Columns.fromNames("process-id:String", "sequenceNumber:Int") ), (table, _, _, _) => ViewPortDef( columns = table.getTableDef.columns, diff --git a/vuu/src/main/scala/org/finos/vuu/core/module/editable/FixSequenceRpcService.scala b/vuu/src/main/scala/org/finos/vuu/core/module/editable/FixSequenceRpcService.scala index cbb7d4b46..22b4a1e42 100644 --- a/vuu/src/main/scala/org/finos/vuu/core/module/editable/FixSequenceRpcService.scala +++ b/vuu/src/main/scala/org/finos/vuu/core/module/editable/FixSequenceRpcService.scala @@ -36,7 +36,7 @@ class FixSequenceRpcService(implicit clock: Clock) extends RpcHandler with EditR val table = vp.table.asTable val primaryKeys = table.primaryKeys val headKey = primaryKeys.head - val sequencerNumber = table.pullRow(headKey).get("sequenceNumber").asInstanceOf[Long] + val sequencerNumber = table.pullRow(headKey).get("sequenceNumber").asInstanceOf[Int].toLong if (sequencerNumber > 0) { logger.info("I would now send this fix seq to a fix engine to reset, we're all good:" + sequencerNumber) diff --git a/vuu/src/main/scala/org/finos/vuu/viewport/ViewPortContainer.scala b/vuu/src/main/scala/org/finos/vuu/viewport/ViewPortContainer.scala index 171190a8e..c5051b9a0 100644 --- a/vuu/src/main/scala/org/finos/vuu/viewport/ViewPortContainer.scala +++ b/vuu/src/main/scala/org/finos/vuu/viewport/ViewPortContainer.scala @@ -845,7 +845,8 @@ class ViewPortContainer(val tableContainer: TableContainer, val providerContaine } } else { - viewPort.setKeys(ImmutableArray.empty[String]) + //do not set keys to empty + //viewPort.setKeys(ImmutableArray.empty[String]) } } diff --git a/vuu/src/test/scala/org/finos/vuu/viewport/disable/DisableViewPortTest.scala b/vuu/src/test/scala/org/finos/vuu/viewport/disable/DisableViewPortTest.scala new file mode 100644 index 000000000..ca924bc30 --- /dev/null +++ b/vuu/src/test/scala/org/finos/vuu/viewport/disable/DisableViewPortTest.scala @@ -0,0 +1,67 @@ +package org.finos.vuu.viewport.disable + +import org.finos.vuu.api._ +import org.finos.vuu.client.messages.RequestId +import org.finos.vuu.core.table.TableTestHelper._ +import org.finos.vuu.core.table.{Columns, TableContainer, ViewPortColumnCreator} +import org.finos.vuu.net.{ClientSessionId, FilterSpec} +import org.finos.vuu.provider.{JoinTableProviderImpl, MockProvider, ProviderContainer} +import org.finos.vuu.util.OutboundRowPublishQueue +import org.finos.vuu.util.table.TableAsserts._ +import org.finos.toolbox.jmx.{MetricsProvider, MetricsProviderImpl} +import org.finos.toolbox.lifecycle.LifecycleContainer +import org.finos.toolbox.time.{Clock, DefaultClock} +import org.finos.vuu.viewport.{AbstractViewPortTestCase, ViewPortRange} +import org.scalatest.GivenWhenThen +import org.scalatest.featurespec.AnyFeatureSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.prop.Tables.Table + +class DisableViewPortTest extends AbstractViewPortTestCase with Matchers with GivenWhenThen { + + Feature("Disable Viewport example") { + + Scenario("Check that a viewport is not emptied when disabled") { + + Given("we've created a viewport with orders in and a calc'd column 2") + val (viewPortContainer, orders, ordersProvider, session, outQueue, highPriorityQueue) = createDefaultViewPortInfra() + + val viewPortColumns = ViewPortColumnCreator.create(orders, List("orderId", "trader", "tradeTime", "quantity", "ric")) + + createNOrderRowsNoSleep(ordersProvider, 10)(timeProvider) + + val viewPort = viewPortContainer.create(RequestId.oneNew(), session, outQueue, highPriorityQueue, orders, ViewPortRange(0, 10), viewPortColumns) + + viewPortContainer.runOnce() + + val combinedUpdates = combineQs(viewPort) + + //this result is not ideal, need to fix, logic operators currently 'eat' the error message from the missing column + //it should return a compound error + assertVpEq(combinedUpdates) { + Table( + ("orderId", "trader", "ric", "tradeTime", "quantity"), + ("NYC-0000", "chris", "VOD.L", 1311544800L, 100), + ("NYC-0001", "chris", "VOD.L", 1311544800L, 101), + ("NYC-0002", "chris", "VOD.L", 1311544800L, 102), + ("NYC-0003", "chris", "VOD.L", 1311544800L, 103), + ("NYC-0004", "chris", "VOD.L", 1311544800L, 104), + ("NYC-0005", "chris", "VOD.L", 1311544800L, 105), + ("NYC-0006", "chris", "VOD.L", 1311544800L, 106), + ("NYC-0007", "chris", "VOD.L", 1311544800L, 107), + ("NYC-0008", "chris", "VOD.L", 1311544800L, 108), + ("NYC-0009", "chris", "VOD.L", 1311544800L, 109) + ) + } + + viewPortContainer.disableViewPort(viewPort.id) + + viewPortContainer.runOnce() + + val combinedUpdates2 = combineQs(viewPort) + + combinedUpdates2.size should equal(0) + + } + } +}