From de9342faecd2a6cf4608a67ef160c0b48f6e2fec Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 22 Apr 2021 07:42:25 -0400 Subject: [PATCH 1/4] Add changes for building --- parent-java/pom.xml | 2 +- .../lang/tutorial/tests/LintcodeTest.java | 6 - toolkits/codebank/pom.xml | 6 +- .../codebank/common/model}/ListNode.java | 2 +- .../codebank/common/model}/TreeNode.java | 2 +- .../model/entity/BBSOssezForumAttach.java | 2 +- .../model/entity/BBSOssezForumPost.java | 2 +- .../common/model/request/TopicRequest.java | 2 +- .../common/model/response/MyFileResponse.java | 2 +- .../common/model/response/SearchResponse.java | 2 +- .../codebank}/tests/VariableTest.java | 113 ++++++++------- ...ntCode0007SerializeAndDeserializeTest.java | 4 +- .../lintcode/LintCode0069LevelOrderTest.java | 2 +- .../lintcode/LintCode0102HasCycleTest.java | 2 +- .../LintCode0165MergeTwoListsTest.java | 2 +- .../LintCode0425LetterCombinationsTest.java | 0 .../lintcode/LintCode0433NumIslandsTest.java | 0 .../lintcode/LintCode1480DotProductTest.java | 0 .../model/entity/BBSOssezForumAttach.java | 2 +- .../model/entity/BBSOssezForumPost.java | 2 +- .../common/model/request/TopicRequest.java | 2 +- .../common/model/response/MyFileResponse.java | 2 +- .../common/model/response/SearchResponse.java | 2 +- .../tests}/DiscourseTopicsImportTest.java | 8 +- .../discourse/DiscourseTopicsImportTest.java | 133 ------------------ 25 files changed, 89 insertions(+), 213 deletions(-) rename {src/main/java/com/ossez/lang/tutorial/models => toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model}/ListNode.java (76%) rename {src/main/java/com/ossez/lang/tutorial/models => toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model}/TreeNode.java (79%) rename toolkits/codebank/src/main/java/com/ossez/toolkits/{codebak => codebank}/common/model/entity/BBSOssezForumAttach.java (94%) rename toolkits/codebank/src/main/java/com/ossez/toolkits/{codebak => codebank}/common/model/entity/BBSOssezForumPost.java (96%) rename toolkits/codebank/src/main/java/com/ossez/toolkits/{codebak => codebank}/common/model/request/TopicRequest.java (96%) rename toolkits/{discourse/src/main/java/com/ossez/toolkits/codebak => codebank/src/main/java/com/ossez/toolkits/codebank}/common/model/response/MyFileResponse.java (98%) rename toolkits/codebank/src/main/java/com/ossez/toolkits/{codebak => codebank}/common/model/response/SearchResponse.java (92%) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/VariableTest.java (76%) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java (95%) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/lintcode/LintCode0069LevelOrderTest.java (97%) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/lintcode/LintCode0102HasCycleTest.java (95%) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/lintcode/LintCode0165MergeTwoListsTest.java (96%) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/lintcode/LintCode0425LetterCombinationsTest.java (100%) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/lintcode/LintCode0433NumIslandsTest.java (100%) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/lintcode/LintCode1480DotProductTest.java (100%) rename toolkits/discourse/src/main/java/com/ossez/toolkits/{codebak => codebank}/common/model/entity/BBSOssezForumAttach.java (94%) rename toolkits/discourse/src/main/java/com/ossez/toolkits/{codebak => codebank}/common/model/entity/BBSOssezForumPost.java (96%) rename toolkits/discourse/src/main/java/com/ossez/toolkits/{codebak => codebank}/common/model/request/TopicRequest.java (96%) rename toolkits/{codebank/src/main/java/com/ossez/toolkits/codebak => discourse/src/main/java/com/ossez/toolkits/codebank}/common/model/response/MyFileResponse.java (98%) rename toolkits/discourse/src/main/java/com/ossez/toolkits/{codebak => codebank}/common/model/response/SearchResponse.java (92%) rename toolkits/{codebank/src/test/java/com/ossez/toolkits/discourse => discourse/src/test/java/com/ossez/toolkits/codebank/tests}/DiscourseTopicsImportTest.java (95%) delete mode 100644 toolkits/discourse/src/test/java/com/ossez/toolkits/discourse/DiscourseTopicsImportTest.java diff --git a/parent-java/pom.xml b/parent-java/pom.xml index 7946e7b3ab..cf646e0c92 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -10,7 +10,7 @@ com.ossez - java-tutorials + parent-modules 0.0.1 diff --git a/src/test/java/com/ossez/lang/tutorial/tests/LintcodeTest.java b/src/test/java/com/ossez/lang/tutorial/tests/LintcodeTest.java index 7cf699092d..139295c4b1 100644 --- a/src/test/java/com/ossez/lang/tutorial/tests/LintcodeTest.java +++ b/src/test/java/com/ossez/lang/tutorial/tests/LintcodeTest.java @@ -2,17 +2,11 @@ package com.ossez.lang.tutorial.tests; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; -import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.management.ListenerNotFoundException; - import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/toolkits/codebank/pom.xml b/toolkits/codebank/pom.xml index 9364a13ffc..e9ff9aadc8 100644 --- a/toolkits/codebank/pom.xml +++ b/toolkits/codebank/pom.xml @@ -41,15 +41,15 @@ - discourse + codebank org.apache.maven.plugins maven-compiler-plugin ${maven-compiler-plugin.version} - ${java.version} - ${java.version} + 11 + 11 diff --git a/src/main/java/com/ossez/lang/tutorial/models/ListNode.java b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/ListNode.java similarity index 76% rename from src/main/java/com/ossez/lang/tutorial/models/ListNode.java rename to toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/ListNode.java index d4fffc8cd5..29814fd94a 100644 --- a/src/main/java/com/ossez/lang/tutorial/models/ListNode.java +++ b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/ListNode.java @@ -1,4 +1,4 @@ -package com.ossez.lang.tutorial.models; +package com.ossez.toolkits.codebank.common.model; /** * diff --git a/src/main/java/com/ossez/lang/tutorial/models/TreeNode.java b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/TreeNode.java similarity index 79% rename from src/main/java/com/ossez/lang/tutorial/models/TreeNode.java rename to toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/TreeNode.java index 8051f395f4..e773805229 100644 --- a/src/main/java/com/ossez/lang/tutorial/models/TreeNode.java +++ b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/TreeNode.java @@ -1,4 +1,4 @@ -package com.ossez.lang.tutorial.models; +package com.ossez.toolkits.codebank.common.model; /** * diff --git a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumAttach.java b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumAttach.java similarity index 94% rename from toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumAttach.java rename to toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumAttach.java index aa983fa094..7a949bc647 100644 --- a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumAttach.java +++ b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumAttach.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.entity; +package com.ossez.toolkits.codebank.common.model.entity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumPost.java b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumPost.java similarity index 96% rename from toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumPost.java rename to toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumPost.java index 01b7b74fd8..3b6e7c3bf0 100644 --- a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumPost.java +++ b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumPost.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.entity; +package com.ossez.toolkits.codebank.common.model.entity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/request/TopicRequest.java b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/request/TopicRequest.java similarity index 96% rename from toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/request/TopicRequest.java rename to toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/request/TopicRequest.java index d1fdae3112..3e0fa1db22 100644 --- a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/request/TopicRequest.java +++ b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/request/TopicRequest.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.request; +package com.ossez.toolkits.codebank.common.model.request; import java.io.Serializable; diff --git a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/response/MyFileResponse.java b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/response/MyFileResponse.java similarity index 98% rename from toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/response/MyFileResponse.java rename to toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/response/MyFileResponse.java index 6fb32dec9d..1ffd613eff 100644 --- a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/response/MyFileResponse.java +++ b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/response/MyFileResponse.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.response; +package com.ossez.toolkits.codebank.common.model.response; import java.io.Serializable; diff --git a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/response/SearchResponse.java b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/response/SearchResponse.java similarity index 92% rename from toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/response/SearchResponse.java rename to toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/response/SearchResponse.java index 8dcaeb5e99..232ae6aa8c 100644 --- a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/response/SearchResponse.java +++ b/toolkits/codebank/src/main/java/com/ossez/toolkits/codebank/common/model/response/SearchResponse.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.response; +package com.ossez.toolkits.codebank.common.model.response; import java.io.Serializable; import java.util.Date; diff --git a/src/test/java/com/ossez/lang/tutorial/tests/VariableTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/VariableTest.java similarity index 76% rename from src/test/java/com/ossez/lang/tutorial/tests/VariableTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/VariableTest.java index a7112e3aea..f2935594dd 100644 --- a/src/test/java/com/ossez/lang/tutorial/tests/VariableTest.java +++ b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/VariableTest.java @@ -1,49 +1,64 @@ -package com.ossez.lang.tutorial.tests; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import junit.framework.TestCase; - -/** - * Object of VariableOssez - * - * @author YuCheng - * - */ -class OssezVariable { - int s1, s2; - static int s3; - - OssezVariable(int x, int y, int z) { - s1 = x; - s2 = y; - s3 = z; - } -} - -/** - * - * @author YuCheng - * - */ -public class VariableTest extends TestCase { - - private final static Logger logger = LoggerFactory.getLogger(VariableTest.class); - - /** - * Do RetsServerConnection Test - */ - @Test - public void testStaticVariableChange() { - - OssezVariable objA = new OssezVariable(1, 2, 3); - logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objA.s1, objA.s2, OssezVariable.s3); - - OssezVariable objB = new OssezVariable(4, 5, 6); - logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objA.s1, objA.s2, OssezVariable.s3); - logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objB.s1, objB.s2, OssezVariable.s3); - } - -} +package com.ossez.lang.tutorial.tests; + +import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.TestCase; + +/** + * Object of VariableOssez + * + * @author YuCheng + * + */ + +class OssezVariable { + int s1, s2; + static int s3; + + OssezVariable(int x, int y, int z) { + s1 = x; + s2 = y; + s3 = z; + } +} + +/** + * + * @author YuCheng + * + */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class VariableTest extends TestCase { + + private final static Logger logger = LoggerFactory.getLogger(VariableTest.class); + + + @BeforeAll + protected void setUp() throws Exception { + } + + @AfterAll + protected void tearDown() throws Exception { + } + + + /** + * Do RetsServerConnection Test + */ + @Test + public void testStaticVariableChange() { + + OssezVariable objA = new OssezVariable(1, 2, 3); + logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objA.s1, objA.s2, OssezVariable.s3); + + OssezVariable objB = new OssezVariable(4, 5, 6); + logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objA.s1, objA.s2, OssezVariable.s3); + logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objB.s1, objB.s2, OssezVariable.s3); + } + +} diff --git a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java similarity index 95% rename from src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java index cb900c3f37..05fba483a4 100644 --- a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java +++ b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java @@ -1,4 +1,4 @@ -package com.ossez.lang.tutorial.tests.lintcode; +package com.ossez.toolkits.codebank.tests.lintcode; import java.util.ArrayList; @@ -6,7 +6,7 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.ossez.lang.tutorial.models.TreeNode; +import com.ossez.toolkits.codebank.common.model.TreeNode; /** *

diff --git a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0069LevelOrderTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0069LevelOrderTest.java similarity index 97% rename from src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0069LevelOrderTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0069LevelOrderTest.java index f0f661947a..78a738dcc2 100644 --- a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0069LevelOrderTest.java +++ b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0069LevelOrderTest.java @@ -9,7 +9,7 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.ossez.lang.tutorial.models.TreeNode; +import com.ossez.toolkits.codebank.common.model.TreeNode; /** *

diff --git a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0102HasCycleTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0102HasCycleTest.java similarity index 95% rename from src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0102HasCycleTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0102HasCycleTest.java index 7ded09697e..8bdd3d867d 100644 --- a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0102HasCycleTest.java +++ b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0102HasCycleTest.java @@ -4,7 +4,7 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.ossez.lang.tutorial.models.ListNode; +import com.ossez.toolkits.codebank.common.model.ListNode; /** *

diff --git a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0165MergeTwoListsTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0165MergeTwoListsTest.java similarity index 96% rename from src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0165MergeTwoListsTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0165MergeTwoListsTest.java index 5bfac549d6..2633f64505 100644 --- a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0165MergeTwoListsTest.java +++ b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0165MergeTwoListsTest.java @@ -4,7 +4,7 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.ossez.lang.tutorial.models.ListNode; +import com.ossez.toolkits.codebank.common.model.ListNode; /** *

diff --git a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0425LetterCombinationsTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0425LetterCombinationsTest.java similarity index 100% rename from src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0425LetterCombinationsTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0425LetterCombinationsTest.java diff --git a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0433NumIslandsTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0433NumIslandsTest.java similarity index 100% rename from src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0433NumIslandsTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode0433NumIslandsTest.java diff --git a/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode1480DotProductTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode1480DotProductTest.java similarity index 100% rename from src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode1480DotProductTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/lintcode/LintCode1480DotProductTest.java diff --git a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumAttach.java b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumAttach.java similarity index 94% rename from toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumAttach.java rename to toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumAttach.java index aa983fa094..7a949bc647 100644 --- a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumAttach.java +++ b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumAttach.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.entity; +package com.ossez.toolkits.codebank.common.model.entity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumPost.java b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumPost.java similarity index 96% rename from toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumPost.java rename to toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumPost.java index 01b7b74fd8..3b6e7c3bf0 100644 --- a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/entity/BBSOssezForumPost.java +++ b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/entity/BBSOssezForumPost.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.entity; +package com.ossez.toolkits.codebank.common.model.entity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/request/TopicRequest.java b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/request/TopicRequest.java similarity index 96% rename from toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/request/TopicRequest.java rename to toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/request/TopicRequest.java index d1fdae3112..3e0fa1db22 100644 --- a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/request/TopicRequest.java +++ b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/request/TopicRequest.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.request; +package com.ossez.toolkits.codebank.common.model.request; import java.io.Serializable; diff --git a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/response/MyFileResponse.java b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/response/MyFileResponse.java similarity index 98% rename from toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/response/MyFileResponse.java rename to toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/response/MyFileResponse.java index 6fb32dec9d..1ffd613eff 100644 --- a/toolkits/codebank/src/main/java/com/ossez/toolkits/codebak/common/model/response/MyFileResponse.java +++ b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/response/MyFileResponse.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.response; +package com.ossez.toolkits.codebank.common.model.response; import java.io.Serializable; diff --git a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/response/SearchResponse.java b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/response/SearchResponse.java similarity index 92% rename from toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/response/SearchResponse.java rename to toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/response/SearchResponse.java index 8dcaeb5e99..232ae6aa8c 100644 --- a/toolkits/discourse/src/main/java/com/ossez/toolkits/codebak/common/model/response/SearchResponse.java +++ b/toolkits/discourse/src/main/java/com/ossez/toolkits/codebank/common/model/response/SearchResponse.java @@ -1,4 +1,4 @@ -package com.ossez.toolkits.codebak.common.model.response; +package com.ossez.toolkits.codebank.common.model.response; import java.io.Serializable; import java.util.Date; diff --git a/toolkits/codebank/src/test/java/com/ossez/toolkits/discourse/DiscourseTopicsImportTest.java b/toolkits/discourse/src/test/java/com/ossez/toolkits/codebank/tests/DiscourseTopicsImportTest.java similarity index 95% rename from toolkits/codebank/src/test/java/com/ossez/toolkits/discourse/DiscourseTopicsImportTest.java rename to toolkits/discourse/src/test/java/com/ossez/toolkits/codebank/tests/DiscourseTopicsImportTest.java index 74756c0231..020b656bb8 100644 --- a/toolkits/codebank/src/test/java/com/ossez/toolkits/discourse/DiscourseTopicsImportTest.java +++ b/toolkits/discourse/src/test/java/com/ossez/toolkits/codebank/tests/DiscourseTopicsImportTest.java @@ -1,8 +1,8 @@ -package com.ossez.toolkits.discourse; +package com.ossez.toolkits.codebank.tests; import com.google.gson.Gson; -import com.ossez.toolkits.codebak.common.model.entity.BBSOssezForumPost; -import com.ossez.toolkits.codebak.common.model.request.TopicRequest; +import com.ossez.toolkits.codebank.common.model.entity.BBSOssezForumPost; +import com.ossez.toolkits.codebank.common.model.request.TopicRequest; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; @@ -74,8 +74,8 @@ public class DiscourseTopicsImportTest { private void processPost(Long tid) throws IOException { String postCtx = StringUtils.EMPTY; -// BBSOssezForumPost bbsOssezForumPost = PostFactory.getBBSOssezForumPostTid(tid); BBSOssezForumPost bbsOssezForumPost = new BBSOssezForumPost(); +// BBSOssezForumPost bbsOssezForumPost = PostFactory.getBBSOssezForumPostTid(tid); // if (bbsOssezForumPost == null) // return; // diff --git a/toolkits/discourse/src/test/java/com/ossez/toolkits/discourse/DiscourseTopicsImportTest.java b/toolkits/discourse/src/test/java/com/ossez/toolkits/discourse/DiscourseTopicsImportTest.java deleted file mode 100644 index 3f955858de..0000000000 --- a/toolkits/discourse/src/test/java/com/ossez/toolkits/discourse/DiscourseTopicsImportTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.ossez.toolkits.discourse; - -import com.google.gson.Gson; -import com.ossez.toolkits.codebak.common.model.entity.BBSOssezForumPost; -import com.ossez.toolkits.codebak.common.model.request.TopicRequest; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.math.NumberUtils; -import org.apache.http.HttpHeaders; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.joda.time.DateTime; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * Test Logger and function - * - * @author YuCheng Hu - */ -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class DiscourseTopicsImportTest { - private static Logger logger = LoggerFactory.getLogger(DiscourseTopicsImportTest.class); - - - @BeforeAll - protected void setUp() throws Exception { - } - - @AfterAll - protected void tearDown() throws Exception { - } - - /** - * Tests search functionality for the customer object. - */ - @Test - public void testPost() throws IOException, InterruptedException { - List idList = FileUtils.readLines(new File("C:\\Users\\yhu\\Pictures\\Pics\\2021-01\\1.txt")); - for (String id : idList) { - processPost(NumberUtils.toLong(id)); - Thread.sleep(6000); -// break; - - } - - - // make sure the customer was found -// assertNotNull(bbsOssezForumPost); - } - - @Test - public void testDateTime() throws IOException { - DateTime dateTime = new DateTime(1256834117 * 1000L); - System.out.println(dateTime.toString()); - - } - - private void processPost(Long tid) throws IOException { - String postCtx = StringUtils.EMPTY; - - BBSOssezForumPost bbsOssezForumPost = new BBSOssezForumPost(); -// BBSOssezForumPost bbsOssezForumPost = PostFactory.getBBSOssezForumPostTid(tid); -// if (bbsOssezForumPost == null) -// return; -// -// logger.debug("Questions Content - {}", bbsOssezForumPost.getSubject()); -// -// String postCtx = bbsOssezForumPost.getMessage(); -//// logger.debug(">>>>{}", postCtx); -// -// -// String pattern = "\\[attach\\]((\\d)*?)\\[\\/attach\\]"; -// -// // Create a Pattern object -// Pattern r = Pattern.compile(pattern); -// -// // Now create matcher object. -// Matcher m = r.matcher(postCtx); -// -// while (m.find()) { -// String attachId = StringUtils.substringBetween(m.group(0), "[attach]", "[/attach]"); -// logger.debug("{}", attachId); -// BBSOssezForumAttach bbsOssezForumAttach = PostFactory.getBBSOssezForumAttach(NumberUtils.toLong(attachId)); -// if (bbsOssezForumAttach!= null) { -// String fullURL = "![](https://cdn.ossez.com/com-ossez-www/data/attachment/forum/" + bbsOssezForumAttach.getAttachment() + ")"; -// postCtx = StringUtils.replace(postCtx, m.group(0), fullURL); -// } -// } - - logger.debug("{}", postCtx); - - - CloseableHttpClient client = HttpClients.createDefault(); - - HttpPost httpPost = new HttpPost("https://www.ossez.com/posts.json"); - httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8"); - httpPost.setHeader("Api-Key", "XXXX"); - httpPost.setHeader("Api-Username", "XXXX"); - - TopicRequest topicRequest = new TopicRequest(); - topicRequest.setTitle(bbsOssezForumPost.getSubject()); - topicRequest.setRaw(postCtx); - topicRequest.setCreated_at(new DateTime(bbsOssezForumPost.getDateline() * 1000L).toString() ); - topicRequest.setCategory(30); - - StringEntity postingString = new StringEntity(new Gson().toJson(topicRequest), StandardCharsets.UTF_8); - - httpPost.setEntity(postingString); - - - CloseableHttpResponse response = client.execute(httpPost); - - logger.info("{}", EntityUtils.toString(response.getEntity()), StandardCharsets.UTF_8); - client.close(); - } - -} From 38ad1198b14607a319d49a9588b91febd4865604 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 22 Apr 2021 07:47:49 -0400 Subject: [PATCH 2/4] Fixed issue for groupid --- toolkits/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toolkits/pom.xml b/toolkits/pom.xml index e3860756da..506dcb2618 100644 --- a/toolkits/pom.xml +++ b/toolkits/pom.xml @@ -2,6 +2,8 @@ 4.0.0 + + com.ossez toolkits toolkits pom From 3404acc5434e63d324b3b06278ff8fd9240d328f Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 22 Apr 2021 08:52:41 -0400 Subject: [PATCH 3/4] Move file from old source folder to code test bank --- .../toolkits/codebank}/tests/codility/CodilityBinaryGapTest.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {src/test/java/com/ossez/lang/tutorial => toolkits/codebank/src/test/java/com/ossez/toolkits/codebank}/tests/codility/CodilityBinaryGapTest.java (100%) diff --git a/src/test/java/com/ossez/lang/tutorial/tests/codility/CodilityBinaryGapTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/codility/CodilityBinaryGapTest.java similarity index 100% rename from src/test/java/com/ossez/lang/tutorial/tests/codility/CodilityBinaryGapTest.java rename to toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/codility/CodilityBinaryGapTest.java From 6baa2c473f2e8cfbf686012b37172e0b18a57a04 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 22 Apr 2021 08:58:31 -0400 Subject: [PATCH 4/4] Add new test to find first unique Character --- .../LeetCode0387FirstUniqueCharacterTest.java | 59 +++++++++++++++++++ .../test/resources/{log4j.xml => log4j2.xml} | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/leetcode/LeetCode0387FirstUniqueCharacterTest.java rename toolkits/codebank/src/test/resources/{log4j.xml => log4j2.xml} (89%) diff --git a/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/leetcode/LeetCode0387FirstUniqueCharacterTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/leetcode/LeetCode0387FirstUniqueCharacterTest.java new file mode 100644 index 0000000000..7573d85a09 --- /dev/null +++ b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/leetcode/LeetCode0387FirstUniqueCharacterTest.java @@ -0,0 +1,59 @@ +package com.ossez.toolkits.codebank.tests.leetcode; + +import com.ossez.toolkits.codebank.common.model.TreeNode; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; + +/** + *

+ * 7 + *

+ *

+ * + * @author YuCheng + * + */ +public class LeetCode0387FirstUniqueCharacterTest { + + private final static Logger logger = LoggerFactory.getLogger(LeetCode0387FirstUniqueCharacterTest.class); + + /** + * + */ + @Test + public void testMain() { + logger.debug("BEGIN"); + String data = "leetcode"; + + System.out.println(firstUniqChar(data)); + + } + + /** + * Deserialize from array to tree + * + * @param data + * @return + */ + private int firstUniqChar(String data) { + // NULL CHECK + if (data.equals("")) { + return -1; + } + + + return 0; + + } + + + +} diff --git a/toolkits/codebank/src/test/resources/log4j.xml b/toolkits/codebank/src/test/resources/log4j2.xml similarity index 89% rename from toolkits/codebank/src/test/resources/log4j.xml rename to toolkits/codebank/src/test/resources/log4j2.xml index 4c1a066f00..f87d408794 100644 --- a/toolkits/codebank/src/test/resources/log4j.xml +++ b/toolkits/codebank/src/test/resources/log4j2.xml @@ -6,7 +6,7 @@ - +