From 9d264c37128744187788972fa26f3ff7552db83b Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Thu, 15 Jun 2023 11:42:09 -0700 Subject: [PATCH 01/11] Alvin code review files --- src/main/java/StringManipulation.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/StringManipulation.java b/src/main/java/StringManipulation.java index 4deb6f1..06599e5 100644 --- a/src/main/java/StringManipulation.java +++ b/src/main/java/StringManipulation.java @@ -1,5 +1,4 @@ public class StringManipulation implements StringManipulationInterface { - @Override public String getString() { return null; @@ -7,6 +6,7 @@ public String getString() { @Override public void setString(String string) { + } @Override @@ -20,12 +20,12 @@ public String removeNthCharacter(int n, boolean maintainSpacing) { } @Override - public String[] getSubStrings(int startWord, int endWord) { + public String[] getSubStrings(int startWord, int endWord){ return null; } @Override - public String restoreString(int[] indices) { + public String restoreString(int[] indices){ return null; } From b88848315ae5fe5d5197672608f100cb918e19ba Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Thu, 15 Jun 2023 11:51:49 -0700 Subject: [PATCH 02/11] Alvin redo files --- src/main/java/StringManipulation.java | 111 +++++++++++++++-- src/test/java/StringManipulationTest.java | 139 ++++++++++++---------- 2 files changed, 179 insertions(+), 71 deletions(-) diff --git a/src/main/java/StringManipulation.java b/src/main/java/StringManipulation.java index 06599e5..721413b 100644 --- a/src/main/java/StringManipulation.java +++ b/src/main/java/StringManipulation.java @@ -1,33 +1,126 @@ +//Alvin Bautista +//CS 410 - JUNIT Assignment +//06112023 + +package main.java; + public class StringManipulation implements StringManipulationInterface { + + private String string; //stores the string to manipulate + @Override public String getString() { - return null; + return this.string; //return the string stored in this object } @Override public void setString(String string) { - + this.string = string; //set the string stored in this object } @Override public int count() { - return 0; + //check if the string is null or empty + if (this.string == null || this.string.trim().isEmpty()) { + return 0; + } + //split the string into words and return the number of words + return this.string.trim().split("\\s+").length; } @Override public String removeNthCharacter(int n, boolean maintainSpacing) { - return null; + //validate n + if (n <= 0) { + throw new IllegalArgumentException("n should be greater than 0"); + } + + //special case when n is 1 + if (n == 1) { + return this.string; //return original string + } + + //validate the string + if (this.string == null) { + throw new IndexOutOfBoundsException("String is null"); + } + + //validate that n is not greater than string length + if (n > this.string.length()) { + throw new IndexOutOfBoundsException("n is greater than the string length"); + } + + //initialize a StringBuilder to build the result + StringBuilder result = new StringBuilder(); + + //loop through characters of the string + for (int i = 1; i <= this.string.length(); i++) { + //append character to result if its position is not a multiple of n + if (i % n != 0) { + result.append(this.string.charAt(i - 1)); + } else { + //append space to result if maintainSpacing is true and position is multiple of n + if (maintainSpacing) { + result.append(' '); + } + } + } + + //return the resulting string + return result.toString(); } @Override - public String[] getSubStrings(int startWord, int endWord){ - return null; + public String[] getSubStrings(int startWord, int endWord) { + //validate startWord and endWord + if (startWord <= 0 || endWord <= 0 || startWord > endWord) { + throw new IllegalArgumentException("Invalid startWord or endWord"); + } + + //validate the string + if (this.string == null) { + throw new IndexOutOfBoundsException("String is null"); + } + + //split string into words + String[] words = this.string.split("\\s+"); + + //check if there are enough words to get the substring + if (endWord > words.length) { + throw new IndexOutOfBoundsException("String has fewer than endWord words"); + } + + //create array to store the substrings + String[] subStrings = new String[endWord - startWord + 1]; + + //copy the substrings into the array + System.arraycopy(words, startWord - 1, subStrings, 0, subStrings.length); + + //return the substrings array + return subStrings; } @Override - public String restoreString(int[] indices){ - return null; - } + public String restoreString(int[] indices) { + //validate the indices and the string + if (indices == null || this.string == null || indices.length != this.string.length() || indices.length == 0) { + throw new IllegalArgumentException("String and indices should have the same non-zero length"); + } + //create an array to store characters in the restored order + char[] restored = new char[this.string.length()]; + //loop through the indices + for (int i = 0; i < indices.length; i++) { + //validate each index + if (indices[i] < 0 || indices[i] >= this.string.length()) { + throw new IndexOutOfBoundsException("Index out of bounds"); + } + //place each character at the correct position + restored[indices[i]] = this.string.charAt(i); + } + + //return the restored string + return new String(restored); + } } diff --git a/src/test/java/StringManipulationTest.java b/src/test/java/StringManipulationTest.java index 6692c2c..1e9cafa 100644 --- a/src/test/java/StringManipulationTest.java +++ b/src/test/java/StringManipulationTest.java @@ -1,149 +1,164 @@ +//Alvin Bautista +//CS 410 - JUNIT Assignment +//06112023 + +package test.java; + +import main.java.StringManipulation; +import main.java.StringManipulationInterface; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.*; public class StringManipulationTest { - private StringManipulationInterface manipulatedstring; + private StringManipulationInterface manipulatedString; //object to be tested @BeforeEach public void setUp() { - manipulatedstring = new StringManipulation(); + manipulatedString = new StringManipulation(); //initialize object before each test } @AfterEach public void tearDown() { - manipulatedstring = null; + manipulatedString = null; //cleanup after each test } @Test public void testCount1() { - manipulatedstring.setString("This is my string"); - int length = manipulatedstring.count(); - assertEquals(4, length); + manipulatedString.setString("This is my string"); //setting string + int length = manipulatedString.count(); //count words + assertEquals(4, length); //assert expected value } @Test public void testCount2() { - fail("Not yet implemented"); + manipulatedString.setString("One more test case"); //setting string + assertEquals(4, manipulatedString.count()); //directly asserting expected value } @Test public void testCount3() { - fail("Not yet implemented"); + manipulatedString.setString(""); //setting empty string + assertEquals(0, manipulatedString.count()); //asserting count is 0 } @Test public void testCount4() { - fail("Not yet implemented"); + manipulatedString.setString("Single"); //setting single word + assertEquals(1, manipulatedString.count()); //asserting count is 1 } @Test public void testRemoveNthCharacter1() { - manipulatedstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); - assertEquals("I' bttr uts0e 16tsinths trn6 rgh?", manipulatedstring.removeNthCharacter(3, false)); + manipulatedString.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); //setting string + assertEquals("I' bttr uts0e 16tsinths trn6 rgh?", manipulatedString.removeNthCharacter(3, false)); //asserting removal of characters } @Test public void testRemoveNthCharacter2() { - manipulatedstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); - assertEquals("I' b tt r ut s0 e 16 ts in th s tr n6 r gh ?", manipulatedstring.removeNthCharacter(3, true)); + manipulatedString.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); //setting string + assertEquals("I' b tt r ut s0 e 16 ts in th s tr n6 r gh ?", manipulatedString.removeNthCharacter(3, true)); //asserting removal with spaces } @Test public void testRemoveNthCharacter3() { - fail("Not yet implemented"); + manipulatedString.setString("Example text for test case."); //setting string + assertEquals("Eapetx o etcs.", manipulatedString.removeNthCharacter(2, false)); //asserting removal of characters } @Test public void testRemoveNthCharacter4() { - fail("Not yet implemented"); + manipulatedString.setString("Example text for test case."); //setting string + assertEquals("Example text for test case.", manipulatedString.removeNthCharacter(1, false)); //asserting no change for n=1 } @Test public void testRemoveNthCharacter5() { - fail("Not yet implemented"); + manipulatedString.setString("Small"); //setting string + assertEquals("Sal", manipulatedString.removeNthCharacter(2, false)); //asserting removal of characters } @Test public void testRemoveNthCharacter6() { - fail("Not yet implemented"); + manipulatedString.setString("Small"); //setting string + assertEquals("S a l", manipulatedString.removeNthCharacter(2, true)); //asserting removal with spaces } @Test public void testRemoveNthCharacter7() { - fail("Not yet implemented"); + assertThrows(IndexOutOfBoundsException.class, () -> manipulatedString.removeNthCharacter(20, true)); //asserting exception for out of bounds } @Test - public void testGeSubStrings1() { - manipulatedstring.setString("This is my string"); - String [] sStings = manipulatedstring.getSubStrings(3, 4); + public void testGetSubStrings1() { + manipulatedString.setString("This is my string"); //setting string + String [] sStings = manipulatedString.getSubStrings(3, 4); //get substring array - assertEquals(sStings[0], "my"); + assertEquals(sStings[0], "my"); //asserting elements assertEquals(sStings[1], "string"); } @Test - public void testGeSubStrings2() { - fail("Not yet implemented"); - } - @Test - public void testGeSubStrings3() { - fail("Not yet implemented"); - } - @Test - public void testGeSubStrings4() { - fail("Not yet implemented"); + public void testGetSubStrings2() { + manipulatedString.setString("A B C D E"); //setting string + String[] subStrings = manipulatedString.getSubStrings(2, 4); //get substring array + assertEquals("B", subStrings[0]); //asserting elements + assertEquals("C", subStrings[1]); + assertEquals("D", subStrings[2]); } + @Test - public void testGeSubStrings5() { - fail("Not yet implemented"); + public void testGetSubStrings3() { + manipulatedString.setString("One Two"); //setting string + String[] subStrings = manipulatedString.getSubStrings(1, 2); //get substring array + assertEquals("One", subStrings[0]); //asserting elements + assertEquals("Two", subStrings[1]); } + @Test - public void testGeSubStrings6() { - fail("Not yet implemented"); + public void testGetSubStrings4() { + assertThrows(IllegalArgumentException.class, () -> manipulatedString.getSubStrings(3, 2)); //asserting exception for invalid arguments } @Test - public void testRestoreString1() - { - manipulatedstring.setString("art"); - int [] array; - array=new int[]{1,0,2}; - String restoreString = manipulatedstring.restoreString(array); - assertEquals(restoreString, "rat"); + public void testGetSubStrings5() { + manipulatedString.setString("Short"); //setting string + assertThrows(IndexOutOfBoundsException.class, () -> manipulatedString.getSubStrings(1, 2)); //asserting exception for out of bounds } @Test - public void testRestoreString2() - { - fail("Not yet implemented"); - + public void testGetSubStrings6() { + manipulatedString.setString("Just One"); //setting string + String[] subStrings = manipulatedString.getSubStrings(1, 1); //get substring array + assertEquals("Just", subStrings[0]); //asserting element } @Test - public void testRestoreString3() - { - fail("Not yet implemented"); - + public void testRestoreString1() { + manipulatedString.setString("art"); //setting string + int[] array = {1, 0, 2}; //indices array + String restoreString = manipulatedString.restoreString(array); //restoring string + assertEquals(restoreString, "rat"); //asserting restored string } @Test - public void testRestoreString4() - { - fail("Not yet implemented"); - + public void testRestoreString2() { + assertThrows(IllegalArgumentException.class, () -> { + manipulatedString.setString("invalid"); //setting string + int[] array = {1, 0}; //invalid indices array + manipulatedString.restoreString(array); //should throw exception + }); } @Test - public void testRestoreString5() - { - fail("Not yet implemented"); - + public void testRestoreString3() { + assertThrows(IllegalArgumentException.class, () -> { + manipulatedString.setString("outofbounds"); //setting string + int[] array = {1, 0, 20}; //out of bounds indices array + manipulatedString.restoreString(array); //should throw exception + }); } - -} +} \ No newline at end of file From 4bad74e5e3b3e2766b37ce5f7eefa6e8c9bdb2e8 Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Thu, 15 Jun 2023 19:18:50 -0700 Subject: [PATCH 03/11] Updated import errors and package remove --- src/main/java/StringManipulation.java | 2 -- src/test/java/StringManipulationTest.java | 4 ---- 2 files changed, 6 deletions(-) diff --git a/src/main/java/StringManipulation.java b/src/main/java/StringManipulation.java index 721413b..66b94c0 100644 --- a/src/main/java/StringManipulation.java +++ b/src/main/java/StringManipulation.java @@ -2,8 +2,6 @@ //CS 410 - JUNIT Assignment //06112023 -package main.java; - public class StringManipulation implements StringManipulationInterface { private String string; //stores the string to manipulate diff --git a/src/test/java/StringManipulationTest.java b/src/test/java/StringManipulationTest.java index 1e9cafa..784ed82 100644 --- a/src/test/java/StringManipulationTest.java +++ b/src/test/java/StringManipulationTest.java @@ -2,10 +2,6 @@ //CS 410 - JUNIT Assignment //06112023 -package test.java; - -import main.java.StringManipulation; -import main.java.StringManipulationInterface; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; From 495822a4e7e43e817e4e683d820897d63ce27292 Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Fri, 16 Jun 2023 20:00:17 -0700 Subject: [PATCH 04/11] updated - added restore test cases missing --- src/test/java/StringManipulationTest.java | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/test/java/StringManipulationTest.java b/src/test/java/StringManipulationTest.java index 784ed82..64ddbe5 100644 --- a/src/test/java/StringManipulationTest.java +++ b/src/test/java/StringManipulationTest.java @@ -157,4 +157,45 @@ public void testRestoreString3() { manipulatedString.restoreString(array); //should throw exception }); } + + @Test + public void testRestoreString4() { + // Test case to verify the restoreString() method when the input string is "team" + manipulatedstring.setString("team"); + // and the indices array is {-1, 0, 1, 2}. + int[] array = new int[]{-1, 0, 1, 2}; + // It should throw an IndexOutOfBoundsException. + assertThrows(IndexOutOfBoundsException.class, ()->{manipulatedstring.restoreString(array);}); + } + + @Test + public void testRestoreString5(){ + // Test case to verify the restoreString() method when the input string is "group" + manipulatedstring.setString("group"); + // and the indices array is {5, 0, 1, 2, 3}. + int[] array = new int[]{5, 0, 1, 2, 3}; + // It should throw an IndexOutOfBoundsException. + assertThrows(IndexOutOfBoundsException.class, ()->{manipulatedstring.restoreString(array);}); + } + + @Test + public void testRestoreString6() { + // Test case to verify the restoreString() method when the input string is null + manipulatedstring.setString(null); + // and the indices array is {2, 3, 5, 4, 1, 0}. + int[] array = new int[]{2, 3, 5, 4, 1, 0}; + // It should throw a NullPointerException. + assertThrows(NullPointerException.class, ()->{manipulatedstring.restoreString(array);}); + } + + @Test + public void testRestoreString7() { + // Test case to verify the restoreString() method when the input string is "MASTER" + manipulatedstring.setString("MASTER"); + // and the indices array is {2, 3, 5, 4, 1, 0}. + int[] array = new int[]{2, 3, 5, 4, 1, 0}; + // It should return the expected output "STREAM". + assertEquals("STREAM", manipulatedstring.restoreString(array)); + } + } \ No newline at end of file From b05c2d8fed89096b3a5fa4eac1bed1e789b157cd Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Fri, 16 Jun 2023 20:09:15 -0700 Subject: [PATCH 05/11] test pom remove last line --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6330c14..f3623ae 100644 --- a/pom.xml +++ b/pom.xml @@ -74,4 +74,4 @@ - + \ No newline at end of file From 104097cd11151d84d17cf17ee9d31d4c0987e638 Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Fri, 16 Jun 2023 20:15:19 -0700 Subject: [PATCH 06/11] test pom 2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f3623ae..6330c14 100644 --- a/pom.xml +++ b/pom.xml @@ -74,4 +74,4 @@ - \ No newline at end of file + From bab87a6cdf249c6026ed1760c5b4cf5f9e25cbad Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Fri, 16 Jun 2023 20:18:46 -0700 Subject: [PATCH 07/11] test yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0fbc4f2..72c3016 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: java -jdk: openjdk17 +jdk: openjdk19 jobs: include: - script: mvn clean verify package From d07d1d00d9be112c8c1238383c219a9570800127 Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Fri, 16 Jun 2023 20:29:06 -0700 Subject: [PATCH 08/11] test back og yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 72c3016..0fbc4f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: java -jdk: openjdk19 +jdk: openjdk17 jobs: include: - script: mvn clean verify package From b0c7a74205398cfbbf2e0564c3ced8038065df77 Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Fri, 16 Jun 2023 20:42:04 -0700 Subject: [PATCH 09/11] try 4 --- src/test/java/StringManipulationTest.java | 36 +++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/test/java/StringManipulationTest.java b/src/test/java/StringManipulationTest.java index 64ddbe5..42c4baf 100644 --- a/src/test/java/StringManipulationTest.java +++ b/src/test/java/StringManipulationTest.java @@ -157,45 +157,45 @@ public void testRestoreString3() { manipulatedString.restoreString(array); //should throw exception }); } - + @Test public void testRestoreString4() { - // Test case to verify the restoreString() method when the input string is "team" - manipulatedstring.setString("team"); - // and the indices array is {-1, 0, 1, 2}. - int[] array = new int[]{-1, 0, 1, 2}; - // It should throw an IndexOutOfBoundsException. - assertThrows(IndexOutOfBoundsException.class, ()->{manipulatedstring.restoreString(array);}); + // Test case to verify the restoreString() method when the input string is "team" + manipulatedString.setString("team"); + // and the indices array is {-1, 0, 1, 2}. + int[] array = new int[]{-1, 0, 1, 2}; + // It should throw an IndexOutOfBoundsException. + assertThrows(IndexOutOfBoundsException.class, ()->{manipulatedString.restoreString(array);}); } - + @Test public void testRestoreString5(){ // Test case to verify the restoreString() method when the input string is "group" - manipulatedstring.setString("group"); + manipulatedString.setString("group"); // and the indices array is {5, 0, 1, 2, 3}. int[] array = new int[]{5, 0, 1, 2, 3}; // It should throw an IndexOutOfBoundsException. - assertThrows(IndexOutOfBoundsException.class, ()->{manipulatedstring.restoreString(array);}); + assertThrows(IndexOutOfBoundsException.class, ()->{manipulatedString.restoreString(array);}); } - + @Test public void testRestoreString6() { // Test case to verify the restoreString() method when the input string is null - manipulatedstring.setString(null); + manipulatedString.setString(null); // and the indices array is {2, 3, 5, 4, 1, 0}. int[] array = new int[]{2, 3, 5, 4, 1, 0}; // It should throw a NullPointerException. - assertThrows(NullPointerException.class, ()->{manipulatedstring.restoreString(array);}); - } - + assertThrows(NullPointerException.class, ()->{manipulatedString.restoreString(array);}); + } + @Test public void testRestoreString7() { // Test case to verify the restoreString() method when the input string is "MASTER" - manipulatedstring.setString("MASTER"); + manipulatedString.setString("MASTER"); // and the indices array is {2, 3, 5, 4, 1, 0}. int[] array = new int[]{2, 3, 5, 4, 1, 0}; // It should return the expected output "STREAM". - assertEquals("STREAM", manipulatedstring.restoreString(array)); + assertEquals("STREAM", manipulatedString.restoreString(array)); } - + } \ No newline at end of file From ab14bb2568773d38a6936ef67dbb2cb4517fd182 Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Fri, 16 Jun 2023 21:02:41 -0700 Subject: [PATCH 10/11] offline pass cases --- src/main/java/StringManipulation.java | 2 +- src/test/java/StringManipulationTest.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/StringManipulation.java b/src/main/java/StringManipulation.java index 66b94c0..53f45de 100644 --- a/src/main/java/StringManipulation.java +++ b/src/main/java/StringManipulation.java @@ -114,7 +114,7 @@ public String restoreString(int[] indices) { if (indices[i] < 0 || indices[i] >= this.string.length()) { throw new IndexOutOfBoundsException("Index out of bounds"); } - //place each character at the correct position + //place each character at the correct position according to the indices array restored[indices[i]] = this.string.charAt(i); } diff --git a/src/test/java/StringManipulationTest.java b/src/test/java/StringManipulationTest.java index 42c4baf..5ce90a4 100644 --- a/src/test/java/StringManipulationTest.java +++ b/src/test/java/StringManipulationTest.java @@ -184,18 +184,17 @@ public void testRestoreString6() { manipulatedString.setString(null); // and the indices array is {2, 3, 5, 4, 1, 0}. int[] array = new int[]{2, 3, 5, 4, 1, 0}; - // It should throw a NullPointerException. - assertThrows(NullPointerException.class, ()->{manipulatedString.restoreString(array);}); + // It should throw an IllegalArgumentException. + assertThrows(IllegalArgumentException.class, ()->{manipulatedString.restoreString(array);}); } @Test public void testRestoreString7() { // Test case to verify the restoreString() method when the input string is "MASTER" manipulatedString.setString("MASTER"); - // and the indices array is {2, 3, 5, 4, 1, 0}. - int[] array = new int[]{2, 3, 5, 4, 1, 0}; - // It should return the expected output "STREAM". - assertEquals("STREAM", manipulatedString.restoreString(array)); + // and the indices array is {5, 4, 0, 1, 2, 3}. + int[] array = new int[]{5, 4, 0, 1, 2, 3}; + // It should return the expected output "STERAM". + assertEquals("STERAM", manipulatedString.restoreString(array)); } - } \ No newline at end of file From 2720c519e0155232f74f9c74bfb02b5cd877a20b Mon Sep 17 00:00:00 2001 From: ACBxBC Date: Fri, 16 Jun 2023 21:57:16 -0700 Subject: [PATCH 11/11] Refactor improvement regarding Mark Bonner's suggestion to account for whitepsaces in the #7 test case for restoreString. --- src/test/java/StringManipulationTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/StringManipulationTest.java b/src/test/java/StringManipulationTest.java index 5ce90a4..7c261da 100644 --- a/src/test/java/StringManipulationTest.java +++ b/src/test/java/StringManipulationTest.java @@ -190,11 +190,11 @@ public void testRestoreString6() { @Test public void testRestoreString7() { - // Test case to verify the restoreString() method when the input string is "MASTER" - manipulatedString.setString("MASTER"); - // and the indices array is {5, 4, 0, 1, 2, 3}. - int[] array = new int[]{5, 4, 0, 1, 2, 3}; - // It should return the expected output "STERAM". - assertEquals("STERAM", manipulatedString.restoreString(array)); + // Test case to verify the restoreString() method when the input string is "MASTER IS" + manipulatedString.setString("MASTER IS"); + // and the indices array is {5, 4, 0, 1, 2, 3, 6, 7, 8}. + int[] array = new int[]{5, 4, 0, 1, 2, 3, 6, 7, 8}; + // It should return the expected output "STERAM IS". + assertEquals("STERAM IS", manipulatedString.restoreString(array)); } } \ No newline at end of file