This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-283
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-283 by this push:
new 00471d2 WIP.
00471d2 is described below
commit 00471d25a6e47427936dbc3b8d22fb262e79df0a
Author: Sergey Kamov <[email protected]>
AuthorDate: Fri Mar 26 14:42:07 2021 +0300
WIP.
---
.../main/scala/org/apache/nlpcraft/common/util/NCUtils.scala | 5 ++++-
.../scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala | 10 +++++-----
.../model/intent/idl/compiler/functions/NCIdlFunctions.scala | 5 ++++-
.../intent/idl/compiler/functions/NCIdlFunctionsCustom.scala | 2 +-
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
index bfdc3c2..0634dd6 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
@@ -1956,10 +1956,13 @@ object NCUtils extends LazyLogging {
try {
val obj: Any = objFac()
+ if (obj == null)
+ throw new NCE(s"Invalid 'null' object created for method:
$mtdName")
+
val argClazz = classTag[T].runtimeClass
val retClazz = classTag[R].runtimeClass
- def mkErrors = s"[name=$mtdName, argType=$argClazz,
retType=$retClazz]"
+ def mkErrors = s"[name=${obj.getClass.getName}#$mtdName,
argType=$argClazz, retType=$retClazz]"
val mtd =
try
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala
index efb52d1..3ebd2b5 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala
@@ -74,12 +74,12 @@ class NCDialogSpecModel extends NCModel {
def trueAlwaysInternal(flow: java.util.List[NCDialogFlowItem]): Boolean =
true
- @NCIntent("intent=onA10 flow=/trueAlwaysInternal/ term~{tok_id() ==
'a10'}")
+ @NCIntent("intent=onA10 flow=/#trueAlwaysInternal/ term~{tok_id() ==
'a10'}")
def onA10(): NCResult = NCResult.text("ok")
- def falseAlwaysInternal(flow: java.util.List[NCDialogFlowItem]): Boolean =
true
+ def falseAlwaysInternal(flow: java.util.List[NCDialogFlowItem]): Boolean =
false
- @NCIntent("intent=onA11 flow=/falseAlwaysInternal/ term~{tok_id() ==
'a11'}")
+ @NCIntent("intent=onA11 flow=/#falseAlwaysInternal/ term~{tok_id() ==
'a11'}")
def onA11(): NCResult = NCResult.text("ok")
}
@@ -177,8 +177,8 @@ class NCDialogSpec extends NCTestContext {
@Test
private[dialog] def test6(): Unit = {
// Always 'true'.
- require(getClient.ask("10").isOk)
+ require(getClient.ask("a10").isOk)
// Always 'false'.
- require(getClient.ask("11").isFailed)
+ require(getClient.ask("a11").isFailed)
}
}
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 204a9cd..d034a19 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
@@ -34,7 +34,8 @@ import scala.language.implicitConversions
private[functions] trait NCIdlFunctions {
private final val MODEL_ID = "test.mdl.id"
- final val MODEL: NCModel = new NCModel {
+ // It shouldn't be anonimous class because we need access to
'trueAlwaysCustomToken' method via reflection.
+ class TestModel extends NCModel {
override val getId: String = MODEL_ID
override val getName: String = MODEL_ID
override val getVersion: String = "1.0.0"
@@ -45,6 +46,8 @@ private[functions] trait NCIdlFunctions {
new NCTokenPredicateResult(true, 1)
}
+ final val MODEL: NCModel = new TestModel()
+
@BeforeEach
def before(): Unit = NCIdlCompilerGlobal.clearCache(MODEL_ID)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCustom.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCustom.scala
index a12de38..1edd7cc 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCustom.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCustom.scala
@@ -74,7 +74,7 @@ class NCIdlFunctionsCustom extends NCIdlFunctions {
),
TestDesc(
// Method defined in model.
- truth = s"trueAlwaysCustomToken",
+ truth = s"#trueAlwaysCustomToken",
isCustom = true,
token = Some(tkn(txt = "any"))
)