11package 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 ;
94import org .junit .jupiter .api .BeforeEach ;
105import 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}
0 commit comments