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 1ef0aec WIP.
1ef0aec is described below
commit 1ef0aec2958b7fdf4ada836dcb18e48710defe67
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Mar 25 13:49:20 2021 +0300
WIP.
---
.../nlpcraft/model/dialog/NCDialogSpec2.scala | 64 ++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec2.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec2.scala
new file mode 100644
index 0000000..4a42136
--- /dev/null
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec2.scala
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nlpcraft.model.dialog
+
+import org.apache.nlpcraft.model.{NCDialogFlowItem, NCElement, NCIntent,
NCModel, NCResult}
+import org.apache.nlpcraft.{NCTestContext, NCTestElement, NCTestEnvironment}
+import org.junit.jupiter.api.Test
+
+import java.util
+
+/**
+ * Test model.
+ */
+class NCDialogSpecModelFlow2 {
+ def invalidDef1(flow: java.util.List[NCDialogFlowItem]): String = null
+ def invalidDef2(): Boolean = true
+ def validDef(flow: java.util.List[NCDialogFlowItem]): Boolean = true
+}
+
+class NCDialogSpecModel2 extends NCModel {
+ override def getId: String = this.getClass.getSimpleName
+ override def getName: String = this.getClass.getSimpleName
+ override def getVersion: String = "1.0.0"
+
+ override def getElements: util.Set[NCElement] = Set(NCTestElement("a1"),
NCTestElement("a2"), NCTestElement("a3"))
+
+ @NCIntent("intent=onA1
flow=/org.apache.nlpcraft.model.dialog.NCDialogSpecModelFlow2#invalidDef2/
term~{id() == 'a1'}")
+ def onA1(): NCResult = NCResult.text("ok")
+
+ @NCIntent("intent=onA2
flow=/org.apache.nlpcraft.model.dialog.NCDialogSpecModelFlow2#validDef/
term~{id() == 'a2'}")
+ def onA2(): NCResult = NCResult.text("ok")
+
+ @NCIntent("intent=onA3
flow=/org.apache.nlpcraft.model.dialog.NCDialogSpecModelFlow2#validDef/
term~{id() == 'a3'}")
+ def onA3(): NCResult = NCResult.text("ok")
+}
+
+/**
+ * @see NCDialogSpecModel
+ */
+@NCTestEnvironment(model = classOf[NCDialogSpecModel], startClient = true)
+class NCDialogSpec2 extends NCTestContext {
+ @Test
+ private[dialog] def test(): Unit = {
+ require(getClient.ask("a1").isFailed)
+ require(getClient.ask("a2").isFailed)
+
+ checkIntent("a3", "onA3")
+ }
+}