Skip to content

Commit

Permalink
#1415 added failing test for asserting view port columns are returned…
Browse files Browse the repository at this point in the history
… when getting table metadata
  • Loading branch information
naleeha authored and keikeicheung committed Jul 22, 2024
1 parent 51beb4f commit 3335381
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
18 changes: 18 additions & 0 deletions vuu/src/test/scala/org/finos/vuu/net/TestModuleFactory.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.finos.vuu.net

import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.time.Clock
import org.finos.vuu.api.{TableDef, ViewPortDef}
import org.finos.vuu.core.module.{ModuleFactory, TableDefContainer, ViewServerModule}
import org.finos.vuu.provider.MockProvider

object TestModuleFactory {
def build(moduleName: String, tableDef: TableDef, viewPortDef: ViewPortDef)(implicit time: Clock, lifecycle: LifecycleContainer, tableDefContainer: TableDefContainer): ViewServerModule =
ModuleFactory.withNamespace(moduleName)
.addTable(
tableDef,
(table, _) => new MockProvider(table),
(_, _, _, _) => viewPortDef
)
.asModule()
}
32 changes: 28 additions & 4 deletions vuu/src/test/scala/org/finos/vuu/net/WebSocketApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.finos.vuu.net
import org.finos.toolbox.jmx.{MetricsProvider, MetricsProviderImpl}
import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.time.{Clock, DefaultClock}
import org.finos.vuu.api.{ColumnBuilder, NoRpcHandler, TableDef, ViewPortDef}
import org.finos.vuu.core._
import org.finos.vuu.core.module.{TableDefContainer, TestModule}
import org.finos.vuu.net.auth.AlwaysHappyAuthenticator
Expand All @@ -18,6 +19,7 @@ class WebSocketApiTest extends AnyFeatureSpec with BeforeAndAfterAll with GivenW

implicit val timeProvider: Clock = new DefaultClock
implicit val lifecycle: LifecycleContainer = new LifecycleContainer
implicit val tableDefContainer: TableDefContainer = new TableDefContainer
var viewServerClient: ViewServerClient = _
var vuuClient: TestVuuClient = _
var tokenId: String = _
Expand Down Expand Up @@ -46,6 +48,27 @@ class WebSocketApiTest extends AnyFeatureSpec with BeforeAndAfterAll with GivenW
val http = 10011
val ws = 10013

val tableDef = TableDef(
name = "TableMetaTest",
keyField = "Id",
columns =
new ColumnBuilder()
.addString("Id")
.addString("Name")
.addInt("Account")
.build()
)
val viewPortDef = ViewPortDef(
columns =
new ColumnBuilder()
.addString("Id")
.addInt("Account")
.build(),
service = NoRpcHandler
)

val module = TestModuleFactory.build("TEST", tableDef, viewPortDef)

val config = VuuServerConfig(
VuuHttp2ServerOptions()
.withWebRoot("vuu/src/main/resources/www")
Expand All @@ -63,7 +86,7 @@ class WebSocketApiTest extends AnyFeatureSpec with BeforeAndAfterAll with GivenW
VuuThreadingOptions(),
VuuClientConnectionOptions()
.withHeartbeatDisabled()
).withModule(TestModule())
).withModule(module)

val viewServer = new VuuServer(config)

Expand All @@ -83,14 +106,15 @@ class WebSocketApiTest extends AnyFeatureSpec with BeforeAndAfterAll with GivenW
Feature("Server web socket api") {
Scenario("client requests to get table metadata for a table") {

vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable("instruments", "TEST")))
vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable("TableMetaTest", "TEST")))

Then("return table data in response")
Then("return view port columns in response")
val response = vuuClient.awaitForMsgWithBody[GetTableMetaResponse]
assert(response.isDefined)

val responseMessage = response.get
responseMessage.columns.length shouldEqual 5
responseMessage.columns.length shouldEqual 2
responseMessage.columns shouldEqual Array("Id", "Account")
}

Scenario("client requests to get table metadata for a non existent") {
Expand Down

0 comments on commit 3335381

Please sign in to comment.