<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
- <name>Hedgecode ChessHog DB Engine</name>
+ <name>Hedgecode ChessHog DB Etude</name>
<description>
- Hedgecode ChessHog DB Engine Module.
+ Hedgecode ChessHog DB Etude Module.
</description>
<properties>
--- /dev/null
+/*
+ * Copyright (c) 2018. Developed by Hedgecode.
+ *
+ * Licensed 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.hedgecode.chess.db
+
+/**
+ *
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+
+import javax.persistence.Persistence
+
+def factory = Persistence.createEntityManagerFactory("db-etude-persistence-unit")
+def manager = factory.createEntityManager()
+
+manager.getTransaction().begin()
+
+//manager.persist new ServerNode(firstName: "Test", lastName: "Server")
+
+manager.getTransaction().commit()
\ No newline at end of file
<version>${chessHogVersion}</version>
</dependency>
<dependency>
+ <groupId>org.hedgecode.chess</groupId>
+ <artifactId>chesshog-graphics</artifactId>
+ <version>${chessHogVersion}</version>
+ </dependency>
+ <dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>${zxingVersion}</version>
--- /dev/null
+/*
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
+ *
+ * Licensed 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.hedgecode.chess.qrcode;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link ChessQRCodeWriter}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class ChessQRCodeReaderTest extends Assert {
+
+ @Test
+ public void decode() throws Exception {
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
+ *
+ * Licensed 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.hedgecode.chess.qrcode;
+
+import java.io.File;
+
+import javax.imageio.ImageIO;
+
+import org.hedgecode.chess.img.DiagramBuilder;
+import org.hedgecode.chess.img.ImageFormat;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import org.hedgecode.chess.Builders;
+import org.hedgecode.chess.Parsers;
+import org.hedgecode.chess.position.Position;
+
+/**
+ * Tests for {@link ChessQRCodeWriter}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class ChessQRCodeWriterTest extends Assert {
+
+ private static final String QR_CODE_IMAGE_PATH = "./QRCodeTest.png";
+
+ @Test
+ public void generate() throws Exception {
+ //String expected = "rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq d6 0 2";
+ String expected = "1r2k1r1/pbppnp1p/1b3P2/8/Q7/B1PB1q2/P4PPP/3R2K1 w - - 0 21";
+ //String expected = "4kb1r/p2n1ppp/4q3/4p1B1/4P3/1Q6/PPP2PPP/2KR4 w k - 0 16";
+
+ Position expectedPosition = Parsers.FEN.parser().parse(
+ expected
+ );
+
+ ChessQRCodeWriter.getInstance().write(
+ ChessQRCodeMode.TCD,
+ Builders.TCD.builder().build(expectedPosition),
+ ImageFormat.PNG,
+ QR_CODE_IMAGE_PATH
+ );
+
+ File file = new File(QR_CODE_IMAGE_PATH);
+ String actual = ChessQRCodeReader.getInstance().read(
+ file
+ ).getContents();
+
+ Position actualPosition = Parsers.TCD.parser().parse(
+ actual
+ );
+
+
+/*
+ assertNotNull(actual);
+ assertEquals(expected, actual);
+*/
+
+ System.out.println(actual);
+
+ ImageIO.write(
+ DiagramBuilder.getInstance().build(actualPosition, "test", "shade"),
+ "PNG",
+ new File("chessboard.png")
+ );
+
+
+ System.out.println(
+ Builders.ASCII.builder().build(actualPosition)
+ );
+
+
+ }
+
+}
\ No newline at end of file