Skip to content

Commit

Permalink
finos#1434 assert that only top 10 unique values are returned for typ…
Browse files Browse the repository at this point in the history
…eahead request
  • Loading branch information
naleeha committed Aug 19, 2024
1 parent 18b6e8e commit 8c875d6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
5 changes: 3 additions & 2 deletions vuu/src/test/scala/org/finos/vuu/wsapi/TableWSApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import org.finos.vuu.viewport.ViewPortTable
import org.finos.vuu.wsapi.helpers.TestExtension.ModuleFactoryExtension
import org.finos.vuu.wsapi.helpers.{FakeDataSource, TestProvider}

import scala.collection.immutable.ListMap

class TableWSApiTest extends WebSocketApiTestBase {

private val moduleName = "TEST"
Expand Down Expand Up @@ -85,7 +87,7 @@ class TableWSApiTest extends WebSocketApiTestBase {
service = new DefaultRpcHandler()
)

val providerFactory = (table: DataTable, _: IVuuServer) => new TestProvider(table, new FakeDataSource(Map()))
val providerFactory = (table: DataTable, _: IVuuServer) => new TestProvider(table, new FakeDataSource(ListMap()))
val tableDef2 = TableDef(
name = "TableMetaDefaultVPTest",
keyField = "Id",
Expand All @@ -100,5 +102,4 @@ class TableWSApiTest extends WebSocketApiTestBase {
.addTableForTest(tableDef2)
.asModule()
}

}
24 changes: 17 additions & 7 deletions vuu/src/test/scala/org/finos/vuu/wsapi/TypeAheadWSApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import org.finos.vuu.viewport.{DisplayResultAction, ViewPortRange, ViewPortTable
import org.finos.vuu.wsapi.helpers.TestExtension.ModuleFactoryExtension
import org.finos.vuu.wsapi.helpers.{FakeDataSource, TestProvider}

import scala.collection.immutable.ListMap

class TypeAheadWSApiTest extends WebSocketApiTestBase {

private val tableName = "TypeaheadTest"
Expand Down Expand Up @@ -42,7 +44,7 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {
))
vuuClient.send(sessionId, tokenId, getTypeAheadRequest)

Then("return top 10 values in that column")
Then("return top 10 unique values in that column")
val response = vuuClient.awaitForMsgWithBody[ViewPortRpcResponse]
assert(response.isDefined)

Expand All @@ -51,8 +53,7 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {
val action = response.get.action
action shouldBe a[DisplayResultAction]
val displayResultAction = action.asInstanceOf[DisplayResultAction]
displayResultAction.result shouldEqual List("1235", "45321", "89564")

displayResultAction.result shouldEqual List("12355", "45321", "89564", "42262", "65879", "88875", "45897", "23564", "33657", "99854")
}

Scenario("Type ahead request that start with a string for a column") {
Expand Down Expand Up @@ -88,7 +89,6 @@ 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") {}
Expand All @@ -114,16 +114,26 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {
columns =
new ColumnBuilder()
.addString("Id")
.addString("Name")
.addInt("Account")
.build(),
service = new ViewPortTypeAheadRpcHandler(tableContainer)
)

val dataSource = new FakeDataSource(Map(
"row1" -> Map("Id" -> "row1", "Name" -> "Becky Thatcher", "Account" -> 1235),
val dataSource = new FakeDataSource(ListMap(
"row1" -> Map("Id" -> "row1", "Name" -> "Becky Thatcher", "Account" -> 12355),
"row2" -> Map("Id" -> "row2", "Name" -> "Tom Sawyer", "Account" -> 45321),
"row3" -> Map("Id" -> "row3", "Name" -> "Huckleberry Finn", "Account" -> 89564),
"row4" -> Map("Id" -> "row4", "Name" -> "Tom Thatcher", "Account" -> 1235),
"row4" -> Map("Id" -> "row4", "Name" -> "Tom Thatcher", "Account" -> 12355),
"row5" -> Map("Id" -> "row5", "Name" -> "Sid Sawyer", "Account" -> 42262),
"row6" -> Map("Id" -> "row6", "Name" -> "Joe Harper", "Account" -> 65879),
"row7" -> Map("Id" -> "row7", "Name" -> "Jim Baker", "Account" -> 88875),
"row8" -> Map("Id" -> "row8", "Name" -> "Amy Lawrence", "Account" -> 45897),
"row9" -> Map("Id" -> "row9", "Name" -> "Ben Rodgers", "Account" -> 23564),
"row10" -> Map("Id" -> "row10", "Name" -> "John Murrell", "Account" -> 33657),
"row11" -> Map("Id" -> "row11", "Name" -> "Sally Phelps", "Account" -> 99854),
"row12" -> Map("Id" -> "row12", "Name" -> "Polly Phelps", "Account" -> 78458),
"row13" -> Map("Id" -> "row13", "Name" -> "Polly Phelps", "Account" -> 54874),
))
val providerFactory = (table: DataTable, _: IVuuServer) => new TestProvider(table, dataSource)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package org.finos.vuu.wsapi.helpers

class FakeDataSource(rows: Map[String, Map[String, Any]]) {
import scala.collection.immutable.ListMap


/* Using list map to preserve the order of the row data
*/

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

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

0 comments on commit 8c875d6

Please sign in to comment.