This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-278
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-278 by this push:
new cb74e43 WIP.
cb74e43 is described below
commit cb74e43f25e40fbd83a272155cbdca9bd8142036
Author: Sergey Kamov <[email protected]>
AuthorDate: Wed Mar 24 11:25:32 2021 +0300
WIP.
---
.../idl/compiler/functions/NCIdlFunctions.scala | 34 +++++++++++-----------
.../compiler/functions/NCIdlFunctionsCompany.scala | 2 +-
.../compiler/functions/NCIdlFunctionsMeta.scala | 4 +--
.../compiler/functions/NCIdlFunctionsRequest.scala | 25 ++++++++++++----
.../compiler/functions/NCIdlFunctionsUser.scala | 2 +-
5 files changed, 41 insertions(+), 26 deletions(-)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctions.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctions.scala
index 58237ba..05ecc35 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctions.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctions.scala
@@ -77,17 +77,17 @@ private[functions] trait NCIdlFunctions {
}
protected def ctx(
- usr: NCUser = null,
- comp: NCCompany = null,
- srvReqId: String = null,
- normTxt: String = null,
- recTimestamp: Long = 0,
- remAddress: String = null,
- clientAgent: String = null,
+ reqUsr: NCUser = null,
+ reqComp: NCCompany = null,
+ reqSrvReqId: String = null,
+ reqNormText: String = null,
+ reqTstamp: Long = 0,
+ reqAddr: String = null,
+ reqAgent: String = null,
reqData: ScalaMeta = Map.empty[String, AnyRef],
- intentMeta: ScalaMeta = Map.empty[String, Object],
- convMeta: ScalaMeta = Map.empty[String, Object],
- fragMeta: ScalaMeta = Map.empty[String, Object]
+ intentMeta: ScalaMeta = Map.empty[String, AnyRef],
+ convMeta: ScalaMeta = Map.empty[String, AnyRef],
+ fragMeta: ScalaMeta = Map.empty[String, AnyRef]
): NCIdlContext =
NCIdlContext(
intentMeta = intentMeta,
@@ -95,13 +95,13 @@ private[functions] trait NCIdlFunctions {
fragMeta = fragMeta,
req =
new NCRequest() {
- override def getUser: NCUser = usr
- override def getCompany: NCCompany = comp
- override def getServerRequestId: String = srvReqId
- override def getNormalizedText: String = normTxt
- override def getReceiveTimestamp: Long = recTimestamp
- override def getRemoteAddress: Optional[String] =
Optional.ofNullable(remAddress)
- override def getClientAgent: Optional[String] =
Optional.ofNullable(clientAgent)
+ override def getUser: NCUser = reqUsr
+ override def getCompany: NCCompany = reqComp
+ override def getServerRequestId: String = reqSrvReqId
+ override def getNormalizedText: String = reqNormText
+ override def getReceiveTimestamp: Long = reqTstamp
+ override def getRemoteAddress: Optional[String] =
Optional.ofNullable(reqAddr)
+ override def getClientAgent: Optional[String] =
Optional.ofNullable(reqAgent)
override def getRequestData: util.Map[String, AnyRef] =
reqData.asJava
}
)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCompany.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCompany.scala
index 4f81bc9..cad2b16 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCompany.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCompany.scala
@@ -59,7 +59,7 @@ class NCIdlFunctionsCompany extends NCIdlFunctions {
}
private def test(comp: NCCompany): Unit = {
- val idlCtx = ctx(comp = comp)
+ val idlCtx = ctx(reqComp = comp)
def mkTestDesc(truth: String): TestDesc = TestDesc(truth = truth,
idlCtx = idlCtx)
def get(opt: Optional[String]): String = if (opt.isEmpty) null else
s"'${opt.get()}'"
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMeta.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMeta.scala
index 91f5a4e..47deffb 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMeta.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMeta.scala
@@ -71,7 +71,7 @@ class NCIdlFunctionsMeta extends NCIdlFunctions {
def testMetaUser(): Unit =
testValue(
"meta_user",
- ctx(usr =
+ ctx(reqUsr =
new NCUser {
override def getId: Long = -1
override def getFirstName: Optional[String] =
Optional.empty()
@@ -90,7 +90,7 @@ class NCIdlFunctionsMeta extends NCIdlFunctions {
def testMetaCompany(): Unit =
testValue(
"meta_company",
- ctx(comp =
+ ctx(reqComp =
new NCCompany {
override def getId: Long = -1
override def getName: String = "name"
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsRequest.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsRequest.scala
index d28cdad..b756389 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsRequest.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsRequest.scala
@@ -25,13 +25,28 @@ import org.junit.jupiter.api.Test
class NCIdlFunctionsRequest extends NCIdlFunctions {
@Test
def test(): Unit = {
- val idlCtx = ctx(srvReqId = "req.id")
+ val reqSrvReqId = "id"
+ val reqNormText = "some text"
+ val reqTstamp: java.lang.Long = 123
+ val reqAddr = "address"
+ val reqAgent = "agent"
+
+ val idlCtx = ctx(
+ reqSrvReqId = reqSrvReqId,
+ reqNormText = reqNormText,
+ reqTstamp = reqTstamp,
+ reqAddr = reqAddr,
+ reqAgent = reqAgent
+ )
+
+ def mkTestDesc(truth: String): TestDesc = TestDesc(truth = truth,
idlCtx = idlCtx)
test(
- TestDesc(
- truth = s"req_id() == '${idlCtx.req.getServerRequestId}'",
- idlCtx = idlCtx
- )
+ mkTestDesc(s"req_id() == '$reqSrvReqId'"),
+ mkTestDesc(s"req_normtext() == '$reqNormText'"),
+ mkTestDesc(s"req_tstamp() == $reqTstamp"),
+ mkTestDesc(s"req_addr() == '$reqAddr'"),
+ mkTestDesc(s"req_agent() == '$reqAgent'"),
)
}
}
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsUser.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsUser.scala
index cbbaf1f..ba08d84 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsUser.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsUser.scala
@@ -59,7 +59,7 @@ class NCIdlFunctionsUser extends NCIdlFunctions {
}
private def test(usr: NCUser): Unit = {
- val idlCtx = ctx(usr = usr)
+ val idlCtx = ctx(reqUsr = usr)
def mkTestDesc(truth: String): TestDesc = TestDesc(truth = truth,
idlCtx = idlCtx)
def get(opt: Optional[String]): String = if (opt.isEmpty) null else
s"'${opt.get()}'"