Updates for BAEL-7496 (#16150)
* Moved vigenere cipher code to a new module * New test case for encoding and decoding together
This commit is contained in:
		
							parent
							
								
									1d289c30b9
								
							
						
					
					
						commit
						30a5cddce0
					
				
							
								
								
									
										16
									
								
								algorithms-modules/algorithms-miscellaneous-8/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								algorithms-modules/algorithms-miscellaneous-8/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||
|     <modelVersion>4.0.0</modelVersion> | ||||
|     <artifactId>algorithms-miscellaneous-8</artifactId> | ||||
|     <version>0.0.1-SNAPSHOT</version> | ||||
|     <name>algorithms-miscellaneous-8</name> | ||||
| 
 | ||||
|     <parent> | ||||
|         <groupId>com.baeldung</groupId> | ||||
|         <artifactId>algorithms-modules</artifactId> | ||||
|         <version>1.0.0-SNAPSHOT</version> | ||||
|     </parent> | ||||
| 
 | ||||
| </project> | ||||
| @ -24,17 +24,17 @@ public class VigenereCipherUnitTest { | ||||
|     @Test | ||||
|     void encodeArticleTitle() { | ||||
|         VigenereCipher cipher = new VigenereCipher(); | ||||
|         String output = cipher.encode("VEGENERE CIPHER IN JAVA", "BAELDUNG"); | ||||
|         String output = cipher.encode("VIGENERE CIPHER IN JAVA", "BAELDUNG"); | ||||
| 
 | ||||
|         Assertions.assertEquals("XFLQRZFL EJUTIM WU LBAM", output); | ||||
|         Assertions.assertEquals("XJLQRZFL EJUTIM WU LBAM", output); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     void encodeArticleTitleMoreCharacters() { | ||||
|         VigenereCipher cipher = new VigenereCipher("ABCDEFGHIJKLMNOPQRSTUVWXYZ "); | ||||
|         String output = cipher.encode("VEGENERE CIPHER IN JAVA", "BAELDUNG"); | ||||
|         String output = cipher.encode("VIGENERE CIPHER IN JAVA", "BAELDUNG"); | ||||
| 
 | ||||
|         Assertions.assertEquals("XFLQRZELBDNALZEGKOEVEPO", output); | ||||
|         Assertions.assertEquals("XJLQRZELBDNALZEGKOEVEPO", output); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
| @ -56,8 +56,21 @@ public class VigenereCipherUnitTest { | ||||
|     @Test | ||||
|     void decodeArticleTitleMoreCharacters() { | ||||
|         VigenereCipher cipher = new VigenereCipher("ABCDEFGHIJKLMNOPQRSTUVWXYZ "); | ||||
|         String output = cipher.decode("XFLQRZELBDNALZEGKOEVEPO", "BAELDUNG"); | ||||
|         String output = cipher.decode("XJLQRZELBDNALZEGKOEVEPO", "BAELDUNG"); | ||||
| 
 | ||||
|         Assertions.assertEquals("VEGENERE CIPHER IN JAVA", output); | ||||
|         Assertions.assertEquals("VIGENERE CIPHER IN JAVA", output); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     void encodeDecodeBaeldung() { | ||||
|         VigenereCipher cipher = new VigenereCipher(); | ||||
| 
 | ||||
|         String input = "BAELDUNG"; | ||||
|         String key = "HELLO"; | ||||
| 
 | ||||
|         String encoded = cipher.encode(input, key); | ||||
|         String decoded = cipher.decode(encoded, key); | ||||
| 
 | ||||
|         Assertions.assertEquals(input, decoded); | ||||
|     } | ||||
| } | ||||
| @ -22,6 +22,7 @@ | ||||
|         <module>algorithms-miscellaneous-5</module> | ||||
|         <module>algorithms-miscellaneous-6</module> | ||||
|         <module>algorithms-miscellaneous-7</module> | ||||
|         <module>algorithms-miscellaneous-8</module> | ||||
|         <module>algorithms-searching</module> | ||||
|         <module>algorithms-sorting</module> | ||||
|         <module>algorithms-sorting-2</module> | ||||
| @ -34,4 +35,4 @@ | ||||
|         <tradukisto.version>1.0.1</tradukisto.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
| </project> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user