-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
065ea84
commit ce4ab99
Showing
14 changed files
with
199 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
example/main-java/src/main/java/org/finos/vuu/person/UpdateNameRequestParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.finos.vuu.person; | ||
|
||
import java.io.Serializable; | ||
|
||
public class UpdateNameRequestParam implements Serializable { | ||
private String id; | ||
private String name; | ||
|
||
public UpdateNameRequestParam(String id, String name){ | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public String Id() {return id;} | ||
public String Name() {return name;} | ||
} |
5 changes: 5 additions & 0 deletions
5
example/main-java/src/main/java/org/finos/vuu/person/manual/TestParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.finos.vuu.person.manual; | ||
|
||
public class TestParam { | ||
public Object Id; | ||
} |
115 changes: 115 additions & 0 deletions
115
example/main-java/src/test/java/org/finos/vuu/PersonRpcHandlerWSApiTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package org.finos.vuu | ||
|
||
import org.finos.toolbox.time.DefaultClock | ||
import org.finos.vuu.core.module.{TableDefContainer, ViewServerModule} | ||
import org.finos.vuu.module.JavaExampleModule | ||
import org.finos.vuu.net._ | ||
import org.finos.vuu.viewport.{ViewPortRange, ViewPortTable} | ||
import org.finos.vuu.wsapi.WebSocketApiTestBase | ||
|
||
class PersonRpcHandlerWSApiTest extends WebSocketApiTestBase { | ||
|
||
private val tableName = "PersonManualMapped" | ||
private val moduleName = JavaExampleModule.NAME | ||
|
||
Feature("[Web Socket API] Person Rpc Test") { | ||
Scenario("Type ahead for a column") { | ||
|
||
Given("a view port exist") | ||
val viewPortId: String = createViewPort | ||
|
||
When("request typeahead for Name column") | ||
val getTypeAheadRequest = createTypeAheadRequest(viewPortId, "PersonManualMapped", "Name") | ||
val requestId = vuuClient.send(sessionId, tokenId, getTypeAheadRequest) | ||
|
||
Then("return unique values in that column") | ||
val response = vuuClient.awaitForResponse(requestId) | ||
|
||
val responseBody = assertBodyIsInstanceOf[RpcResponseNew](response) | ||
responseBody.rpcName shouldEqual "getUniqueFieldValues" | ||
|
||
val result = assertAndCastAsInstanceOf[RpcSuccessResult](responseBody.result) | ||
result.data shouldEqual List("Adam", "Natalie") | ||
|
||
And("return No Action") | ||
responseBody.action shouldBe a[NoneAction] | ||
} | ||
|
||
Scenario("Custom Rpc request with a reference type as param") { | ||
|
||
Given("a view port exist") | ||
val viewPortId: String = createViewPort | ||
|
||
When("request GetAccountId given the row key") | ||
val getTypeAheadRequest = RpcRequest( | ||
ViewPortContext(viewPortId), | ||
"GetAccountId", | ||
params = Map("rowKey" -> "uniqueId1")) | ||
val requestId = vuuClient.send(sessionId, tokenId, getTypeAheadRequest) | ||
|
||
Then("return account number for person with that id") | ||
val response = vuuClient.awaitForResponse(requestId) | ||
|
||
val responseBody = assertBodyIsInstanceOf[RpcResponseNew](response) | ||
responseBody.rpcName shouldEqual "GetAccountId" | ||
|
||
val result = assertAndCastAsInstanceOf[RpcSuccessResult](responseBody.result) | ||
result.data shouldEqual 56440 | ||
|
||
And("return No Action") | ||
responseBody.action shouldBe a[NoneAction] | ||
} | ||
|
||
|
||
Scenario("Custom Rpc request with object as params") { | ||
|
||
Given("a view port exist") | ||
val viewPortId: String = createViewPort | ||
|
||
|
||
When("request update name") | ||
val getTypeAheadRequest = RpcRequest( | ||
ViewPortContext(viewPortId), | ||
"UpdateName", | ||
params = Map("Id" -> "uniqueId1", "Name" -> "Chris")) | ||
val requestId = vuuClient.send(sessionId, tokenId, getTypeAheadRequest) | ||
|
||
Then("return success response") | ||
val response = vuuClient.awaitForResponse(requestId) | ||
|
||
val responseBody = assertBodyIsInstanceOf[RpcResponseNew](response) | ||
responseBody.rpcName shouldEqual "UpdateName" | ||
|
||
val result = assertAndCastAsInstanceOf[RpcSuccessResult](responseBody.result) | ||
|
||
And("return No Action") | ||
responseBody.action shouldBe a[NoneAction] | ||
|
||
And("return row update with new name") | ||
} | ||
} | ||
|
||
override protected def defineModuleWithTestTables(): ViewServerModule = | ||
new JavaExampleModule().create(new TableDefContainer(), new DefaultClock()) | ||
|
||
|
||
private def createViewPort = { | ||
val createViewPortRequest = CreateViewPortRequest(ViewPortTable(tableName, moduleName), ViewPortRange(1, 100), columns = Array("Id", "Name")) | ||
vuuClient.send(sessionId, tokenId, createViewPortRequest) | ||
val viewPortCreateResponse = vuuClient.awaitForMsgWithBody[CreateViewPortSuccess] | ||
val viewPortId = viewPortCreateResponse.get.viewPortId | ||
viewPortId | ||
} | ||
|
||
|
||
private def createTypeAheadRequest(viewPortId: String, tableName: String, columnName: String): RpcRequest = { | ||
RpcRequest( | ||
ViewPortContext(viewPortId), | ||
RpcNames.UniqueFieldValuesRpc, | ||
params = Map( | ||
"table" -> tableName, | ||
"module" -> moduleName, | ||
"column" -> columnName | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
package org.finos.vuu.net.rpc | ||
|
||
import org.finos.vuu.net.RequestContext | ||
import org.finos.vuu.viewport.ViewPortColumns | ||
|
||
object Rpc { | ||
type Function = RpcParams => RpcFunctionResult | ||
type FunctionName = String | ||
} | ||
|
||
class RpcParams( | ||
val params: Array[Any], | ||
val namedParams: Map[String, Any], | ||
val viewPortColumns: Option[ViewPortColumns], | ||
val ctx: RequestContext) | ||
|
||
trait RpcFunctionResult {} | ||
|
||
case class RpcFunctionSuccess(optionalResult: Option[Any]) extends RpcFunctionResult { | ||
def this(result: Any) = this(Some(result)) | ||
|
||
def this() = this(None) | ||
} | ||
|
||
case class RpcFunctionFailure(code: Int, error: String, exception: Exception) extends RpcFunctionResult { | ||
def this(error: String) = this(1, error, null) | ||
} |
23 changes: 0 additions & 23 deletions
23
vuu/src/main/scala/org/finos/vuu/net/rpc/RpcMethodHandler.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.