Skip to content

Commit

Permalink
#1434 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
naleeha authored and keikeicheung committed Aug 20, 2024
1 parent c2ddb3e commit 1939d0f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 49 deletions.
16 changes: 9 additions & 7 deletions vuu/src/test/scala/org/finos/vuu/wsapi/TableWSApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import org.finos.vuu.wsapi.helpers.{FakeDataSource, TestProvider}

class TableWSApiTest extends WebSocketApiTestBase {

private val moduleName = "TEST"

Feature("Server web socket api") {
Scenario("client requests to get table metadata for a table") {

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

Then("return view port columns in response")
val response = vuuClient.awaitForMsgWithBody[GetTableMetaResponse]
Expand All @@ -29,7 +31,7 @@ class TableWSApiTest extends WebSocketApiTestBase {

Scenario("client requests to get table metadata for a table with no view port def defined") {

vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable("TableMetaDefaultVPTest", "TEST")))
vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable("TableMetaDefaultVPTest", moduleName)))

Then("return table columns as default view port columns in response")
val response = vuuClient.awaitForMsgWithBody[GetTableMetaResponse]
Expand All @@ -42,22 +44,22 @@ class TableWSApiTest extends WebSocketApiTestBase {

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

vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable("DoesNotExist", "TEST")))
vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable("DoesNotExist", moduleName)))

Then("return error response with helpful message")
val response = vuuClient.awaitForMsgWithBody[ErrorResponse]
assert(response.isDefined)
response.get.msg shouldEqual "No such table found with name DoesNotExist in module TEST"
response.get.msg shouldEqual "No such table found with name DoesNotExist in module " + moduleName
}

Scenario("client requests to get table metadata for null table name") {

vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable(null, "TEST")))
vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable(null, moduleName)))

Then("return error response with helpful message")
val response = vuuClient.awaitForMsgWithBody[ErrorResponse]
assert(response.isDefined)
response.get.msg shouldEqual "No such table found with name null in module TEST. Table name and module should not be null"
response.get.msg shouldEqual "No such table found with name null in module " + moduleName + ". Table name and module should not be null"
}
}

Expand Down Expand Up @@ -93,7 +95,7 @@ class TableWSApiTest extends WebSocketApiTestBase {
.build()
)

ModuleFactory.withNamespace("TEST")
ModuleFactory.withNamespace(moduleName)
.addTableForTest(tableDef, viewPortDefFactory, providerFactory)
.addTableForTest(tableDef2)
.asModule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {

}


Scenario("Type ahead request that start with a string for a column") {

Then("create viewport")
Expand Down Expand Up @@ -90,6 +89,8 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {
}

Scenario("Type ahead assert only top 10 return and only unique") {}
//create multiple view ports
// check type ahead work on view port columns rather than table columns
Scenario("Type ahead request for view port that does not exist") {}
Scenario("Type ahead request for column that does not exist") {}
Scenario("Type ahead request for empty table") {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.finos.vuu.wsapi.helpers

class FakeDataSource(rows: Map[String, Map[String, Any]]) {
type RowKey = String
type ColumnName = String

def get(): Map[RowKey, Map[ColumnName, Any]] = {
rows
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.finos.vuu.core.module.{ModuleFactory, ModuleFactoryNode, TableDefCont
import org.finos.vuu.core.table.{DataTable, TableContainer}
import org.finos.vuu.provider.{MockProvider, Provider, ProviderContainer}


object TestExtension {
implicit class ModuleFactoryExtension(val moduleFactoryNode: ModuleFactoryNode) {

Expand All @@ -33,35 +32,3 @@ object TestExtension {

}
}
class TestModuleBuilder(moduleName:String)(implicit clock: Clock, lifecycle: LifecycleContainer, tableDefContainer: TableDefContainer){

private var moduleFactory = ModuleFactory.withNamespace(moduleName)

def withTable(tableDef: TableDef, viewPortDef: ViewPortDef): TestModuleBuilder = {
moduleFactory = moduleFactory.addTable(
tableDef,
(table, _) => new MockProvider(table),
(_, _, _, _) => viewPortDef
)
this
}

def build(moduleName: String, tableDef: TableDef, viewPortDef: ViewPortDef)(implicit clock: Clock, lifecycle: LifecycleContainer, tableDefContainer: TableDefContainer): ViewServerModule =
ModuleFactory.withNamespace(moduleName)
.addTable(
tableDef,
(table, _) => new MockProvider(table),
(_, _, _, _) => viewPortDef
)
.asModule()

def build(moduleName: String, tableDef: TableDef)(implicit clock: Clock, lifecycle: LifecycleContainer, tableDefContainer: TableDefContainer): ViewServerModule =
ModuleFactory.withNamespace(moduleName)
.addTable(
tableDef,
(table, _) => new MockProvider(table)
)
.asModule()


}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,3 @@ class TestProvider(table: DataTable, fakeDataSource: FakeDataSource)(implicit cl

override val lifecycleId: String = s"TestProvider ${table.name}"
}
class FakeDataSource(rows: Map[String, Map[String, Any]]) {
type RowKey = String
type ColumnName = String

def get(): Map[RowKey, Map[ColumnName, Any]] = {
rows
}
}

0 comments on commit 1939d0f

Please sign in to comment.