Skip to content

Commit

Permalink
#1213 resolved issue with fake table
Browse files Browse the repository at this point in the history
  • Loading branch information
chris committed Dec 13, 2024
1 parent aa163d0 commit ae9a2c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.finos.vuu.core.module.metrics
import org.finos.toolbox.jmx.{MetricsProvider, MetricsProviderImpl}
import org.finos.toolbox.lifecycle.{LifeCycleComponentContext, LifecycleContainer, LifecycleEnabled}
import org.finos.toolbox.time.{Clock, TestFriendlyClock}
import org.finos.vuu.core.table.{DataTable, TableContainer}
import org.finos.vuu.core.table.{DataTable, RowData, TableContainer}
import org.finos.vuu.core.table.TableMockFactory._
import org.finos.vuu.test.TestFriendlyJoinTableProvider
import org.scalamock.scalatest.MockFactory
Expand Down Expand Up @@ -34,10 +34,10 @@ class MetricsTableProviderTest extends AnyFeatureSpec with Matchers with MockFac

metricsTableProvider.runOnce()

(mockTable.processUpdate _).verify("instrumentsSessionTable_1", *, *).once
(mockTable.processUpdate _).verify("instrumentsSessionTable_2", *, *).once
(mockTable.processUpdate _).verify("fills_table", *, *).once
(mockTable.processUpdate _).verify("other", *, *).once
(mockTable.processUpdate(_: String, _: RowData, _: Long)).verify("instrumentsSessionTable_1", *, *).once
(mockTable.processUpdate(_: String, _: RowData, _: Long)).verify("instrumentsSessionTable_2", *, *).once
(mockTable.processUpdate(_: String, _: RowData, _: Long)).verify("fills_table", *, *).once
(mockTable.processUpdate(_: String, _: RowData, _: Long)).verify("other", *, *).once
}
}
}
10 changes: 7 additions & 3 deletions vuu/src/test/scala/org/finos/vuu/test/FakeInMemoryTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ package org.finos.vuu.test

import org.finos.vuu.api.TableDef
import org.finos.vuu.core.index.IndexedField
import org.finos.vuu.core.row.RowBuilder
import org.finos.vuu.core.table.{Column, ColumnValueProvider, DataTable, KeyObserver, RowData, RowKeyUpdate, RowWithData, TableData, TablePrimaryKeys}
import org.finos.vuu.viewport.{RowProcessor, ViewPortColumns}

class FakeInMemoryTable(val instanceName: String, val tableDef: TableDef) extends DataTable {

private val rowMap = scala.collection.mutable.HashMap.empty[String, RowWithData]
private val rowMap = scala.collection.mutable.HashMap.empty[String, RowData]

override def name: String = instanceName
override def getTableDef: TableDef = tableDef

override def processUpdate(rowKey: String, rowUpdate: RowWithData, timeStamp: Long): Unit =
override def newRow(key: String): RowBuilder = ???
override def rowBuilder: RowBuilder = ???

override def processUpdate(rowKey: String, rowUpdate: RowData, timeStamp: Long): Unit =
rowMap += (rowKey -> rowUpdate)

override def pullRow(key: String): RowData =
rowMap.getOrElse(key, throw new Exception(s"Could not find row data for key $key in table $name"))

def pullAllRows() : List[RowWithData] = rowMap.values.toList
def pullAllRows() : List[RowData] = rowMap.values.toList

override protected def createDataTableData(): TableData = ???

Expand Down

0 comments on commit ae9a2c0

Please sign in to comment.