You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2021/01/24 08:29:17 UTC

[incubator-nlpcraft] branch NLPCRAFT-226 created (now 39e3e9e)

This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a change to branch NLPCRAFT-226
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git.


      at 39e3e9e  WIP.

This branch includes the following new commits:

     new 39e3e9e  WIP.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-nlpcraft] 01/01: WIP.

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-226
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git

commit 39e3e9e7684e274fbf59ffffe25c70c06e2faf16
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Sun Jan 24 11:29:03 2021 +0300

    WIP.
---
 .../nlpcraft/examples/sql/NCSqlGeneratorSpec.scala | 71 ++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlGeneratorSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlGeneratorSpec.scala
new file mode 100644
index 0000000..5fa33cd
--- /dev/null
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlGeneratorSpec.scala
@@ -0,0 +1,71 @@
+/*
+ * 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.examples.sql
+
+import org.apache.nlpcraft.examples.sql.db.SqlServer
+import org.apache.nlpcraft.model.tools.sqlgen.impl.NCSqlModelGeneratorImpl
+import org.junit.jupiter.api.{AfterEach, BeforeEach, Test}
+
+import java.io.File
+
+/**
+  * SQL generator smoke test, based on H2 example database.
+  *
+  * @see SqlModel
+  */
+class NCSqlGeneratorSpec {
+    private final val PATH = "sql.gen.out.yaml"
+
+    private var sqlStarted = false
+
+    @BeforeEach
+    def start(): Unit = {
+        SqlServer.start()
+
+        sqlStarted = true
+    }
+
+    @AfterEach
+    def stop(): Unit = {
+        sqlStarted = false
+
+        val f = new File(PATH)
+
+        if (f.exists()) {
+            if (f.delete())
+                println(s"Test output deleted: ${f.getAbsolutePath}")
+            else
+                System.err.println(s"Couldn't delete file: ${f.getAbsolutePath}")
+        }
+
+        if (sqlStarted)
+            SqlServer.stop()
+    }
+
+    @Test
+    def test(): Unit =
+        NCSqlModelGeneratorImpl.process(
+            repl = false,
+            Array(
+                "--url", SqlServer.H2_URL,
+                "--driver", "org.h2.Driver",
+                "--schema", "PUBLIC",
+                "--out", PATH
+            )
+        )
+}