Skip to content

Commit 8c875d6

Browse files
committed
finos#1434 assert that only top 10 unique values are returned for typeahead request
1 parent 18b6e8e commit 8c875d6

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

vuu/src/test/scala/org/finos/vuu/wsapi/TableWSApiTest.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import org.finos.vuu.viewport.ViewPortTable
1111
import org.finos.vuu.wsapi.helpers.TestExtension.ModuleFactoryExtension
1212
import org.finos.vuu.wsapi.helpers.{FakeDataSource, TestProvider}
1313

14+
import scala.collection.immutable.ListMap
15+
1416
class TableWSApiTest extends WebSocketApiTestBase {
1517

1618
private val moduleName = "TEST"
@@ -85,7 +87,7 @@ class TableWSApiTest extends WebSocketApiTestBase {
8587
service = new DefaultRpcHandler()
8688
)
8789

88-
val providerFactory = (table: DataTable, _: IVuuServer) => new TestProvider(table, new FakeDataSource(Map()))
90+
val providerFactory = (table: DataTable, _: IVuuServer) => new TestProvider(table, new FakeDataSource(ListMap()))
8991
val tableDef2 = TableDef(
9092
name = "TableMetaDefaultVPTest",
9193
keyField = "Id",
@@ -100,5 +102,4 @@ class TableWSApiTest extends WebSocketApiTestBase {
100102
.addTableForTest(tableDef2)
101103
.asModule()
102104
}
103-
104105
}

vuu/src/test/scala/org/finos/vuu/wsapi/TypeAheadWSApiTest.scala

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import org.finos.vuu.viewport.{DisplayResultAction, ViewPortRange, ViewPortTable
1111
import org.finos.vuu.wsapi.helpers.TestExtension.ModuleFactoryExtension
1212
import org.finos.vuu.wsapi.helpers.{FakeDataSource, TestProvider}
1313

14+
import scala.collection.immutable.ListMap
15+
1416
class TypeAheadWSApiTest extends WebSocketApiTestBase {
1517

1618
private val tableName = "TypeaheadTest"
@@ -42,7 +44,7 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {
4244
))
4345
vuuClient.send(sessionId, tokenId, getTypeAheadRequest)
4446

45-
Then("return top 10 values in that column")
47+
Then("return top 10 unique values in that column")
4648
val response = vuuClient.awaitForMsgWithBody[ViewPortRpcResponse]
4749
assert(response.isDefined)
4850

@@ -51,8 +53,7 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {
5153
val action = response.get.action
5254
action shouldBe a[DisplayResultAction]
5355
val displayResultAction = action.asInstanceOf[DisplayResultAction]
54-
displayResultAction.result shouldEqual List("1235", "45321", "89564")
55-
56+
displayResultAction.result shouldEqual List("12355", "45321", "89564", "42262", "65879", "88875", "45897", "23564", "33657", "99854")
5657
}
5758

5859
Scenario("Type ahead request that start with a string for a column") {
@@ -88,7 +89,6 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {
8889

8990
}
9091

91-
Scenario("Type ahead assert only top 10 return and only unique") {}
9292
//create multiple view ports
9393
// check type ahead work on view port columns rather than table columns
9494
Scenario("Type ahead request for view port that does not exist") {}
@@ -114,16 +114,26 @@ class TypeAheadWSApiTest extends WebSocketApiTestBase {
114114
columns =
115115
new ColumnBuilder()
116116
.addString("Id")
117+
.addString("Name")
117118
.addInt("Account")
118119
.build(),
119120
service = new ViewPortTypeAheadRpcHandler(tableContainer)
120121
)
121122

122-
val dataSource = new FakeDataSource(Map(
123-
"row1" -> Map("Id" -> "row1", "Name" -> "Becky Thatcher", "Account" -> 1235),
123+
val dataSource = new FakeDataSource(ListMap(
124+
"row1" -> Map("Id" -> "row1", "Name" -> "Becky Thatcher", "Account" -> 12355),
124125
"row2" -> Map("Id" -> "row2", "Name" -> "Tom Sawyer", "Account" -> 45321),
125126
"row3" -> Map("Id" -> "row3", "Name" -> "Huckleberry Finn", "Account" -> 89564),
126-
"row4" -> Map("Id" -> "row4", "Name" -> "Tom Thatcher", "Account" -> 1235),
127+
"row4" -> Map("Id" -> "row4", "Name" -> "Tom Thatcher", "Account" -> 12355),
128+
"row5" -> Map("Id" -> "row5", "Name" -> "Sid Sawyer", "Account" -> 42262),
129+
"row6" -> Map("Id" -> "row6", "Name" -> "Joe Harper", "Account" -> 65879),
130+
"row7" -> Map("Id" -> "row7", "Name" -> "Jim Baker", "Account" -> 88875),
131+
"row8" -> Map("Id" -> "row8", "Name" -> "Amy Lawrence", "Account" -> 45897),
132+
"row9" -> Map("Id" -> "row9", "Name" -> "Ben Rodgers", "Account" -> 23564),
133+
"row10" -> Map("Id" -> "row10", "Name" -> "John Murrell", "Account" -> 33657),
134+
"row11" -> Map("Id" -> "row11", "Name" -> "Sally Phelps", "Account" -> 99854),
135+
"row12" -> Map("Id" -> "row12", "Name" -> "Polly Phelps", "Account" -> 78458),
136+
"row13" -> Map("Id" -> "row13", "Name" -> "Polly Phelps", "Account" -> 54874),
127137
))
128138
val providerFactory = (table: DataTable, _: IVuuServer) => new TestProvider(table, dataSource)
129139

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package org.finos.vuu.wsapi.helpers
22

3-
class FakeDataSource(rows: Map[String, Map[String, Any]]) {
3+
import scala.collection.immutable.ListMap
4+
5+
6+
/* Using list map to preserve the order of the row data
7+
*/
8+
9+
class FakeDataSource(rows: ListMap[String, Map[String, Any]]) {
410
type RowKey = String
511
type ColumnName = String
612

7-
def get(): Map[RowKey, Map[ColumnName, Any]] = {
13+
def get(): ListMap[RowKey, Map[ColumnName, Any]] = {
814
rows
915
}
1016
}

0 commit comments

Comments
 (0)