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 53658f8  WIP.
53658f8 is described below

commit 53658f89b04bc1965691dc8f93f1e1e196445c6f
Author: Sergey Kamov <[email protected]>
AuthorDate: Tue Mar 23 21:19:55 2021 +0300

    WIP.
---
 .../compiler/functions/NCIdlFunctionsCompany.scala | 36 +++++++++++++++++-----
 1 file changed, 29 insertions(+), 7 deletions(-)

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 6ac6b0f..bb82d90 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
@@ -30,8 +30,8 @@ import scala.collection.JavaConverters._
 class NCIdlFunctionsCompany extends NCIdlFunctions {
     @Test
     def test(): Unit = {
-        val comp = new NCCompany {
-            override def getId: Long = -1 // TODO: No REST API data
+        test(new NCCompany {
+            override def getId: Long = -1 // TODO: No REST API data (comp_id() 
cannot be used)
             override def getName: String = "name"
             override def getWebsite: Optional[String] = Optional.of("website")
             override def getCountry: Optional[String] = Optional.of("country")
@@ -41,15 +41,37 @@ class NCIdlFunctionsCompany extends NCIdlFunctions {
             override def getPostalCode: Optional[String] = Optional.of("code")
             override def getMetadata: util.Map[String, AnyRef] =
                 Map("k1" → "v1").map(p ⇒ p._1 → 
p._2.asInstanceOf[AnyRef]).asJava
-        }
+        })
 
+        test(new NCCompany {
+            override def getId: Long = -1 // TODO: No REST API data (comp_id() 
cannot be used)
+            override def getName: String = "name"
+            override def getWebsite: Optional[String] = Optional.empty()
+            override def getCountry: Optional[String] = Optional.empty()
+            override def getRegion: Optional[String] = Optional.empty()
+            override def getCity: Optional[String] = Optional.empty()
+            override def getAddress: Optional[String] = Optional.empty()
+            override def getPostalCode: Optional[String] = Optional.empty()
+            override def getMetadata: util.Map[String, AnyRef] =
+                Map("k1" → "v1").map(p ⇒ p._1 → 
p._2.asInstanceOf[AnyRef]).asJava
+        })
+
+    }
+
+    private def test(comp: NCCompany): Unit = {
         val idlCtx = ctx(comp = comp)
 
+        def mkTestDesc(truth: String): TestDesc = TestDesc(truth = truth, 
idlCtx = idlCtx)
+        def get(opt: Optional[String]): String = if (opt.isEmpty) null else 
opt.get()
+
         test(
-            TestDesc(
-                truth = s"comp_name() == '${comp.getName}'",
-                idlCtx = idlCtx
-            )
+            mkTestDesc(s"comp_name() == '${comp.getName}'"),
+            mkTestDesc(s"comp_website() == '${get(comp.getWebsite)}'"),
+            mkTestDesc(s"comp_country() == '${get(comp.getCity)}'"),
+            mkTestDesc(s"comp_region() == '${get(comp.getRegion)}'"),
+            mkTestDesc(s"comp_city() == '${get(comp.getCity)}'"),
+            mkTestDesc(s"comp_addr() == '${get(comp.getAddress)}'"),
+            mkTestDesc(s"comp_postcode() == '${get(comp.getPostalCode)}'")
         )
     }
 }

Reply via email to