Skip to content

Commit c24cc40

Browse files
committed
Made style changes
According to PMD...
1 parent 87f15fb commit c24cc40

4 files changed

Lines changed: 60 additions & 85 deletions

File tree

src/test/java/com/thealgorithms/ciphers/MyColumnarTranspositionCipherTest.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package com.thealgorithms.ciphers;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertFalse;
5-
import static org.junit.jupiter.api.Assertions.assertNotEquals;
6-
import static org.junit.jupiter.api.Assertions.assertNotNull;
7-
import static org.junit.jupiter.api.Assertions.assertThrows;
8-
3+
import org.junit.jupiter.api.Assertions;
94
import org.junit.jupiter.api.BeforeEach;
105
import org.junit.jupiter.api.Test;
116

@@ -23,23 +18,23 @@ public void setUp() {
2318
void shouldNotProduceNullOrEmptyEncryptedText() {
2419
String encrypted = ColumnarTranspositionCipher.encrypt(plaintext, keyword);
2520

26-
assertNotNull(encrypted, "Encrypted text should not be null");
27-
assertFalse(encrypted.isEmpty(), "Encrypted text should not be empty");
21+
Assertions.assertNotNull(encrypted, "Encrypted text should not be null");
22+
Assertions.assertFalse(encrypted.isEmpty(), "Encrypted text should not be empty");
2823
}
2924

3025
@Test
3126
void shouldChangePlaintextToEncrypted() {
3227
String encrypted = ColumnarTranspositionCipher.encrypt(plaintext, keyword);
3328

34-
assertNotEquals(plaintext, encrypted, "Encrypted text should differ from plaintext");
29+
Assertions.assertNotEquals(plaintext, encrypted, "Encrypted text should differ from plaintext");
3530
}
3631

3732
@Test
3833
void shouldEncryptDetermenistically() {
3934
String encrypted1 = ColumnarTranspositionCipher.encrypt(plaintext, keyword);
4035
String encrypted2 = ColumnarTranspositionCipher.encrypt(plaintext, keyword);
4136

42-
assertEquals(encrypted1, encrypted2, "Encryptions should be equal");
37+
Assertions.assertEquals(encrypted1, encrypted2, "Encryptions should be equal");
4338
}
4439

4540
@Test
@@ -49,7 +44,7 @@ void shouldProduceDifferentEncryptionsWithDifferentKeywoards() {
4944
String encrypted1 = ColumnarTranspositionCipher.encrypt(plaintext, keyword);
5045
String encrypted2 = ColumnarTranspositionCipher.encrypt(plaintext, keyword2);
5146

52-
assertNotEquals(encrypted1, encrypted2, "Should produce different encryptions");
47+
Assertions.assertNotEquals(encrypted1, encrypted2, "Should produce different encryptions");
5348
}
5449

5550
@Test
@@ -60,7 +55,7 @@ void shouldMatchWithUnsortedKeyword() {
6055
String encrypted = ColumnarTranspositionCipher.encrypt(myPlaintext, myKeyword);
6156
String expected = "8≈7≈2≈4≈5≈3≈6≈19";
6257

63-
assertEquals(expected, encrypted, "Should match");
58+
Assertions.assertEquals(expected, encrypted, "Should match");
6459
}
6560

6661
@Test
@@ -70,7 +65,7 @@ void shouldMatchEncryptionAndDecryptionWithNoSpacesOrPadding() {
7065
ColumnarTranspositionCipher.encrypt(myPlaintext, keyword);
7166
String decrypted = ColumnarTranspositionCipher.decrypt();
7267

73-
assertEquals(myPlaintext, decrypted, "Decrypted text should match original plaintext");
68+
Assertions.assertEquals(myPlaintext, decrypted, "Decrypted text should match original plaintext");
7469
}
7570

7671
@Test
@@ -80,7 +75,7 @@ void shouldNotContainPaddingInDecryption() {
8075
ColumnarTranspositionCipher.encrypt(myPlaintext, keyword);
8176
String decrypted = ColumnarTranspositionCipher.decrypt();
8277

83-
assertFalse(decrypted.contains("≈"), "Should not contain padding characters");
78+
Assertions.assertFalse(decrypted.contains("≈"), "Should not contain padding characters");
8479
}
8580

8681
@Test
@@ -90,7 +85,7 @@ void shouldEncryptWithKeywordLongerThanPlaintext() {
9085

9186
String encryption = ColumnarTranspositionCipher.encrypt(myPlaintext, myKeyword);
9287

93-
assertNotNull(encryption, "Should encrypt where plaintext.length() < keyword.length()");
88+
Assertions.assertNotNull(encryption, "Should encrypt where plaintext.length() < keyword.length()");
9489
}
9590

9691
@Test
@@ -100,7 +95,7 @@ void shouldEncryptWithKeywordWithSameLengthAsPlaintext() {
10095

10196
String encryption = ColumnarTranspositionCipher.encrypt(myPlaintext, myKeyword);
10297

103-
assertNotNull(encryption, "Should encrypt where plaintext.length() == keyword.length()");
98+
Assertions.assertNotNull(encryption, "Should encrypt where plaintext.length() == keyword.length()");
10499
}
105100

106101
@Test
@@ -111,7 +106,7 @@ void shouldProduceDifferentEncryptionForSameKeywordButSortedDifferently() {
111106
String encrypted1 = ColumnarTranspositionCipher.encrypt(plaintext, unsertedKeyword1);
112107
String encrypted2 = ColumnarTranspositionCipher.encrypt(plaintext, unsertedKeyword2);
113108

114-
assertNotEquals(encrypted1, encrypted2, "Should differ with different keywords");
109+
Assertions.assertNotEquals(encrypted1, encrypted2, "Should differ with different keywords");
115110
}
116111

117112
@Test
@@ -120,13 +115,13 @@ void shouldEncryptWithCustomAbecedarium() {
120115

121116
String encryption = ColumnarTranspositionCipher.encrypt(plaintext, keyword, myAbecedarium);
122117

123-
assertNotNull(encryption, "Should encrypt with custom abecedarium");
118+
Assertions.assertNotNull(encryption, "Should encrypt with custom abecedarium");
124119
}
125120

126121
@Test
127122
void shouldNotEncryptWithInvalidAbecedarium() {
128123
String myAbecedarium = "abcde";
129124

130-
assertThrows(NullPointerException.class, () -> ColumnarTranspositionCipher.encrypt(plaintext, keyword, myAbecedarium), "Should throw error when keyword contains characters not present in abecedarium");
125+
Assertions.assertThrows(NullPointerException.class, () -> ColumnarTranspositionCipher.encrypt(plaintext, keyword, myAbecedarium), "Should throw error when keyword contains characters not present in abecedarium");
131126
}
132127
}

src/test/java/com/thealgorithms/datastructures/trees/AVLSimpleTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ void tearDown() {
3535
======================== */
3636

3737
String getExpectedTree() {
38-
return ("""
38+
return """
3939
10=>20<=30
4040
END=>10<=END
4141
END=>30<=END
42-
2""")
42+
2"""
4343
.replace("\n", "");
4444
}
4545

@@ -66,7 +66,7 @@ void testTreeCreation() {
6666

6767
tree.display();
6868

69-
String expectedTree = ("""
69+
String expectedTree = """
7070
15=>25<=30
7171
10=>15<=19
7272
5=>10<=END
@@ -76,7 +76,7 @@ void testTreeCreation() {
7676
END=>20<=END
7777
27=>30<=END
7878
END=>27<=END
79-
4""")
79+
4"""
8080
.replace("\n", "");
8181

8282
assertEquals(expectedTree, getActualTree());
@@ -125,19 +125,19 @@ void testRotatesNotTriggeredWhenBFEqualsOne(int node, String expectedTree) {
125125

126126
public static Stream<Arguments> getTreeNodesInputForBFEqualsOneRotations() {
127127
return Stream.of(
128-
Arguments.of(5, ("""
128+
Arguments.of(5, """
129129
10=>20<=30
130130
5=>10<=END
131131
END=>5<=END
132132
END=>30<=END
133-
3""")
133+
3"""
134134
.replace("\n", "")),
135-
Arguments.of(35, ("""
135+
Arguments.of(35, """
136136
10=>20<=30
137137
END=>10<=END
138138
END=>30<=35
139139
END=>35<=END
140-
3""")
140+
3"""
141141
.replace("\n", ""))
142142
);
143143
}

src/test/java/com/thealgorithms/datastructures/trees/GenericTreeTest.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
package com.thealgorithms.datastructures.trees;
22

3-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4-
import static org.junit.jupiter.api.Assertions.assertEquals;
5-
import static org.junit.jupiter.api.Assertions.assertFalse;
6-
import static org.junit.jupiter.api.Assertions.assertThrows;
7-
import static org.junit.jupiter.api.Assertions.assertTrue;
8-
93
import com.thealgorithms.devutils.ConsoleInterceptor;
104
import java.util.InputMismatchException;
115
import org.junit.jupiter.api.AfterEach;
6+
import org.junit.jupiter.api.Assertions;
127
import org.junit.jupiter.api.BeforeEach;
138
import org.junit.jupiter.api.Test;
149
import org.junit.jupiter.params.ParameterizedTest;
@@ -71,49 +66,49 @@ String getConsoleOutput() {
7166
void testCreateValidTree() {
7267
tree.display();
7368

74-
assertEquals(getExpectedTree(), getConsoleOutput());
69+
Assertions.assertEquals(getExpectedTree(), getConsoleOutput());
7570
}
7671

7772
@Test
7873
void testCreateValidTreeIsNotEmpty() {
7974
tree.display();
8075

81-
assertDoesNotThrow(interceptor::getAndClearConsoleOutput);
76+
Assertions.assertDoesNotThrow(interceptor::getAndClearConsoleOutput);
8277
}
8378

8479
@Test
8580
void testCreateInValidTree() {
8681
String invalidTreeValues = "a\nb\nc\n";
8782
interceptor.mockInput(invalidTreeValues);
8883

89-
assertThrows(InputMismatchException.class, GenericTree::new);
84+
Assertions.assertThrows(InputMismatchException.class, GenericTree::new);
9085
}
9186

9287
@Test
9388
void testGettingCorrectSizeOfTree() {
94-
assertEquals(9, tree.size2call());
89+
Assertions.assertEquals(9, tree.size2call());
9590
}
9691

9792
@Test
9893
void testGettingTheMaximalValueOfTreesNodes() {
99-
assertEquals(342, tree.maxcall());
94+
Assertions.assertEquals(342, tree.maxcall());
10095
}
10196

10297
@Test
10398
void testGettingTheHeightOfTree() {
104-
assertEquals(2, tree.heightcall());
99+
Assertions.assertEquals(2, tree.heightcall());
105100
}
106101

107102
@ParameterizedTest
108103
@ValueSource(ints = {40, 34, 1, 32, 342, 123, 98, 35})
109104
void testFindingAllPresentValuesInTree(int value) {
110-
assertTrue(tree.findcall(value));
105+
Assertions.assertTrue(tree.findcall(value));
111106
}
112107

113108
@ParameterizedTest
114109
@ValueSource(ints = {41, 31, 2, 52, 542, 223, 92, 38})
115110
void testFindingAbsentValuesInTree(int value) {
116-
assertFalse(tree.findcall(value));
111+
Assertions.assertFalse(tree.findcall(value));
117112
}
118113

119114
@Test
@@ -124,32 +119,32 @@ void testFindingAllNodesOfCertainDepthInTree() {
124119
tree.depthcaller(i);
125120
}
126121

127-
assertEquals("4034132342121239835", getConsoleOutput());
122+
Assertions.assertEquals("4034132342121239835", getConsoleOutput());
128123
}
129124

130125
@Test
131126
void testPreOrderPrintsAsExpected() {
132127
tree.preordercall();
133-
assertEquals("40 34 1 32 123 342 98 35 12 .", getConsoleOutput());
128+
Assertions.assertEquals("40 34 1 32 123 342 98 35 12 .", getConsoleOutput());
134129
}
135130

136131
@Test
137132
void testPostOrderPrintsAsExpected() {
138133
tree.postordercall();
139-
assertEquals("34 1 123 32 98 35 342 12 40 .", getConsoleOutput());
134+
Assertions.assertEquals("34 1 123 32 98 35 342 12 40 .", getConsoleOutput());
140135
}
141136

142137
@Test
143138
void testLevelOrderPrintsAsExpected() {
144139
tree.levelorder();
145-
assertEquals("40 34 1 32 342 12 123 98 35 .", getConsoleOutput());
140+
Assertions.assertEquals("40 34 1 32 342 12 123 98 35 .", getConsoleOutput());
146141
}
147142

148143
@Test
149144
void testLeavesAreRemoved() {
150145
tree.removeleavescall();
151146
tree.display();
152147

153-
assertEquals("40=>32 342 .32=>.342=>.", getConsoleOutput());
148+
Assertions.assertEquals("40=>32 342 .32=>.342=>.", getConsoleOutput());
154149
}
155150
}

0 commit comments

Comments
 (0)