From 7b4d2e6871414046ad768a107d6e14c269f0cc74 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Fri, 2 Feb 2024 16:33:46 -0500 Subject: [PATCH] Update the source code to add validation --- .idea/checkstyle-idea.xml | 16 ++++ .idea/compiler.xml | 1 + .idea/encodings.xml | 2 + .idea/vcs.xml | 1 + .../util/CaseInsensitiveTreeMapTest.java | 80 +++++++++++-------- pom.xml | 1 + .../ossez/usreio/tests/client/AllTests.java | 1 + validation | 1 + 8 files changed, 68 insertions(+), 35 deletions(-) create mode 100644 .idea/checkstyle-idea.xml create mode 160000 validation diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml new file mode 100644 index 0000000..f5b372c --- /dev/null +++ b/.idea/checkstyle-idea.xml @@ -0,0 +1,16 @@ + + + + 10.12.5 + JavaOnly + true + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 485de99..1a4e48d 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -8,6 +8,7 @@ + diff --git a/.idea/encodings.xml b/.idea/encodings.xml index cbddad9..f758a22 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -7,5 +7,7 @@ + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1dd..ce03a1e 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/client/src/test/java/com/ossez/usreio/tests/common/util/CaseInsensitiveTreeMapTest.java b/client/src/test/java/com/ossez/usreio/tests/common/util/CaseInsensitiveTreeMapTest.java index 17b8d0b..c26ed00 100644 --- a/client/src/test/java/com/ossez/usreio/tests/common/util/CaseInsensitiveTreeMapTest.java +++ b/client/src/test/java/com/ossez/usreio/tests/common/util/CaseInsensitiveTreeMapTest.java @@ -1,54 +1,64 @@ package com.ossez.usreio.tests.common.util; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import com.ossez.usreio.common.util.CaseInsensitiveTreeMap; import junit.framework.TestCase; +import org.apache.commons.lang3.StringUtils; public class CaseInsensitiveTreeMapTest extends TestCase { - private CaseInsensitiveTreeMap map; + private CaseInsensitiveTreeMap map; - @Override - protected void setUp() throws Exception { - super.setUp(); - this.map = new CaseInsensitiveTreeMap(); - } + @Override + protected void setUp() throws Exception { + super.setUp(); + this.map = new CaseInsensitiveTreeMap(); + } - @Override - protected void tearDown() throws Exception { - super.tearDown(); - this.map = null; - } + @Override + protected void tearDown() throws Exception { + super.tearDown(); + this.map = null; + } - public void testGetPut() throws Exception { - this.map.put("A", "X"); - assertEquals("X", this.map.get("A")); - assertEquals("X", this.map.get("a")); + public void testGetPut() throws Exception { - this.map.put("a", "Y"); - assertEquals("Y", this.map.get("a")); - assertEquals("Y", this.map.get("A")); + List numbers = List.of(1, 2, 3, 4, 5, 6, 7); + List result = new ArrayList(); + for (int i = numbers.size() - 1; i >= 0; i--) { + result.add(numbers.get(i)); - assertEquals(1, this.map.size()); - } - public void testContainsKey() throws Exception { - this.map.put("A", "X"); - assertTrue(this.map.containsKey("A")); - assertTrue(this.map.containsKey("a")); - } + } + System.out.println(result); + } - public void testClone() throws Exception { - Map otherMap = new HashMap(); - otherMap.put("A", "X"); - otherMap.put("a", "Y"); - assertEquals(2, otherMap.size()); + private String alertText(String inputText) { + if (StringUtils.isBlank(inputText)) + return inputText; - CaseInsensitiveTreeMap newCitm = new CaseInsensitiveTreeMap(otherMap); - assertEquals(1, newCitm.size()); - // no guarantee of *which* value we'll get, just that they'll be equal - assertEquals(this.map.get("a"), this.map.get("A")); - } + return inputText.charAt(inputText.length() - 1) + alertText(inputText.substring(0, inputText.length() - 1)); + } + + public void testContainsKey() throws Exception { + this.map.put("A", "X"); + assertTrue(this.map.containsKey("A")); + assertTrue(this.map.containsKey("a")); + } + + public void testClone() throws Exception { + Map otherMap = new HashMap(); + otherMap.put("A", "X"); + otherMap.put("a", "Y"); + assertEquals(2, otherMap.size()); + + CaseInsensitiveTreeMap newCitm = new CaseInsensitiveTreeMap(otherMap); + assertEquals(1, newCitm.size()); + // no guarantee of *which* value we'll get, just that they'll be equal + assertEquals(this.map.get("a"), this.map.get("A")); + } } diff --git a/pom.xml b/pom.xml index 3611628..f6b60d1 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,7 @@ common client + validation diff --git a/src/test/java/com/ossez/usreio/tests/client/AllTests.java b/src/test/java/com/ossez/usreio/tests/client/AllTests.java index 1a9bd6c..bc1527e 100644 --- a/src/test/java/com/ossez/usreio/tests/client/AllTests.java +++ b/src/test/java/com/ossez/usreio/tests/client/AllTests.java @@ -13,6 +13,7 @@ public class AllTests { public static Test suite() { TestSuite suite; + suite = new TestSuite(); /*suite.addTestSuite(GetMetadataRequestTest.class); suite.addTestSuite(GetMetadataResponseTest.class); diff --git a/validation b/validation new file mode 160000 index 0000000..bb415ec --- /dev/null +++ b/validation @@ -0,0 +1 @@ +Subproject commit bb415ec2142a5f08c14b499e03092b96ad3d38c6