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/25 09:02:24 UTC
[incubator-nlpcraft] branch master updated: Sql generator tool test
added.
This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/master by this push:
new 9077ce6 Sql generator tool test added.
9077ce6 is described below
commit 9077ce6ff47aa8c62502faa089d0af59cb0d05fa
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Mon Jan 25 12:02:08 2021 +0300
Sql generator tool test added.
---
.../nlpcraft/examples/sql/NCSqlGeneratorSpec.scala | 70 ++++++++++++++++++++++
1 file changed, 70 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..8d4e0e3
--- /dev/null
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlGeneratorSpec.scala
@@ -0,0 +1,70 @@
+/*
+ * 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(
+ Array(
+ s"--url=${SqlServer.H2_URL}",
+ s"--driver=org.h2.Driver",
+ s"--schema=PUBLIC",
+ s"--out=$PATH"
+ )
+ )
+}