From cc2bc357ce3c21a0b092af8b2ba3e174d10cac81 Mon Sep 17 00:00:00 2001 From: gotty Date: Tue, 23 Apr 2019 18:57:50 +0300 Subject: [PATCH] [LIB-9] Fix name of chesshog-dbetude module --- chesshog-dbetude/pom.xml | 4 +- .../org/hedgecode/chess/db/CreateDBTest.groovy | 34 ++++++++ chesshog-qrcode/pom.xml | 5 ++ .../chess/qrcode/ChessQRCodeReaderTest.java | 37 +++++++++ .../chess/qrcode/ChessQRCodeWriterTest.java | 92 ++++++++++++++++++++++ 5 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 chesshog-dbetude/src/test/groovy/org/hedgecode/chess/db/CreateDBTest.groovy create mode 100644 chesshog-qrcode/src/test/java/org/hedgecode/chess/qrcode/ChessQRCodeReaderTest.java create mode 100644 chesshog-qrcode/src/test/java/org/hedgecode/chess/qrcode/ChessQRCodeWriterTest.java diff --git a/chesshog-dbetude/pom.xml b/chesshog-dbetude/pom.xml index 0cf4a35..d051ce0 100644 --- a/chesshog-dbetude/pom.xml +++ b/chesshog-dbetude/pom.xml @@ -31,9 +31,9 @@ 0.1-SNAPSHOT jar - Hedgecode ChessHog DB Engine + Hedgecode ChessHog DB Etude - Hedgecode ChessHog DB Engine Module. + Hedgecode ChessHog DB Etude Module. diff --git a/chesshog-dbetude/src/test/groovy/org/hedgecode/chess/db/CreateDBTest.groovy b/chesshog-dbetude/src/test/groovy/org/hedgecode/chess/db/CreateDBTest.groovy new file mode 100644 index 0000000..d5204db --- /dev/null +++ b/chesshog-dbetude/src/test/groovy/org/hedgecode/chess/db/CreateDBTest.groovy @@ -0,0 +1,34 @@ +/* + * 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 diff --git a/chesshog-qrcode/pom.xml b/chesshog-qrcode/pom.xml index 1c14a06..3c4b577 100644 --- a/chesshog-qrcode/pom.xml +++ b/chesshog-qrcode/pom.xml @@ -52,6 +52,11 @@ ${chessHogVersion} + org.hedgecode.chess + chesshog-graphics + ${chessHogVersion} + + com.google.zxing core ${zxingVersion} diff --git a/chesshog-qrcode/src/test/java/org/hedgecode/chess/qrcode/ChessQRCodeReaderTest.java b/chesshog-qrcode/src/test/java/org/hedgecode/chess/qrcode/ChessQRCodeReaderTest.java new file mode 100644 index 0000000..d4bd77d --- /dev/null +++ b/chesshog-qrcode/src/test/java/org/hedgecode/chess/qrcode/ChessQRCodeReaderTest.java @@ -0,0 +1,37 @@ +/* + * 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 diff --git a/chesshog-qrcode/src/test/java/org/hedgecode/chess/qrcode/ChessQRCodeWriterTest.java b/chesshog-qrcode/src/test/java/org/hedgecode/chess/qrcode/ChessQRCodeWriterTest.java new file mode 100644 index 0000000..f4a606f --- /dev/null +++ b/chesshog-qrcode/src/test/java/org/hedgecode/chess/qrcode/ChessQRCodeWriterTest.java @@ -0,0 +1,92 @@ +/* + * 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 -- 2.10.0