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
|
@ -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
|
@Test
|
||||||
void encodeArticleTitle() {
|
void encodeArticleTitle() {
|
||||||
VigenereCipher cipher = new VigenereCipher();
|
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
|
@Test
|
||||||
void encodeArticleTitleMoreCharacters() {
|
void encodeArticleTitleMoreCharacters() {
|
||||||
VigenereCipher cipher = new VigenereCipher("ABCDEFGHIJKLMNOPQRSTUVWXYZ ");
|
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
|
@Test
|
||||||
|
@ -56,8 +56,21 @@ public class VigenereCipherUnitTest {
|
||||||
@Test
|
@Test
|
||||||
void decodeArticleTitleMoreCharacters() {
|
void decodeArticleTitleMoreCharacters() {
|
||||||
VigenereCipher cipher = new VigenereCipher("ABCDEFGHIJKLMNOPQRSTUVWXYZ ");
|
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-5</module>
|
||||||
<module>algorithms-miscellaneous-6</module>
|
<module>algorithms-miscellaneous-6</module>
|
||||||
<module>algorithms-miscellaneous-7</module>
|
<module>algorithms-miscellaneous-7</module>
|
||||||
|
<module>algorithms-miscellaneous-8</module>
|
||||||
<module>algorithms-searching</module>
|
<module>algorithms-searching</module>
|
||||||
<module>algorithms-sorting</module>
|
<module>algorithms-sorting</module>
|
||||||
<module>algorithms-sorting-2</module>
|
<module>algorithms-sorting-2</module>
|
||||||
|
@ -34,4 +35,4 @@
|
||||||
<tradukisto.version>1.0.1</tradukisto.version>
|
<tradukisto.version>1.0.1</tradukisto.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue