-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move random string generation to one place
- Loading branch information
1 parent
9e93112
commit 6ace832
Showing
3 changed files
with
57 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Kitodo/src/test/java/org/kitodo/production/helper/HelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo project. | ||
* | ||
* It is licensed under GNU General Public License version 3 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* GPL3-License.txt file that was distributed with this source code. | ||
*/ | ||
|
||
package org.kitodo.production.helper; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class HelperTest { | ||
|
||
@Test | ||
void generateRandomStringOnlyLetters() { | ||
String randomString = Helper.generateRandomString(10); | ||
assertTrue(StringUtils.isAlpha(randomString), "Generated string contains not only letters"); | ||
} | ||
|
||
@Test | ||
void generateRandomStringOnlyNumbers() { | ||
String randomString = Helper.generateRandomString(10, false, true); | ||
assertTrue(StringUtils.isNumeric(randomString), "Generated string contains not only numbers"); | ||
} | ||
|
||
@Test | ||
void generateRandomStringLettersAndNumbers() { | ||
String randomString = Helper.generateRandomString(10, true, true); | ||
assertTrue(StringUtils.isAlphanumeric(randomString), "Generated string contains not only letters and numbers"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters