-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Snehit Roda
committed
Nov 2, 2023
1 parent
4dc437d
commit 04a3ad7
Showing
3 changed files
with
197 additions
and
12 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
uPortal-core/src/test/java/org/apereo/portal/FunctionalNameTypeTest.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,63 @@ | ||
package org.apereo.portal; | ||
|
||
import org.apereo.portal.dao.usertype.FunctionalNameType; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author snehitroda | ||
*/ | ||
public class FunctionalNameTypeTest { | ||
|
||
@Test | ||
public void testValidateValidFunctionalName() { | ||
// Arrange | ||
String validFname = "my_functional-name123"; | ||
|
||
// Act & Assert | ||
assertTrue(FunctionalNameType.isValid(validFname)); | ||
} | ||
|
||
@Test | ||
public void testValidateInvalidFunctionalName() { | ||
// Arrange | ||
String invalidFname = "my functional name"; // Contains spaces | ||
|
||
// Act & Assert | ||
assertFalse(FunctionalNameType.isValid(invalidFname)); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testValidateThrowsIllegalArgumentException() { | ||
// Arrange | ||
String invalidFname = "my functional name"; // Contains spaces | ||
|
||
// Act | ||
FunctionalNameType.validate(invalidFname); | ||
} | ||
|
||
@Test | ||
public void testMakeValidNullInput() { | ||
// Arrange | ||
String nullFname = null; | ||
|
||
// Act | ||
String result = FunctionalNameType.makeValid(nullFname); | ||
|
||
// Assert | ||
assertEquals("_", result); | ||
} | ||
|
||
@Test | ||
public void testMakeValidWithSpecialCharacters() { | ||
// Arrange | ||
String fnameWithSpecialChars = "my_functional#name123"; | ||
|
||
// Act | ||
String result = FunctionalNameType.makeValid(fnameWithSpecialChars); | ||
|
||
// Assert | ||
assertEquals("my_functional_name123", result); | ||
} | ||
} |
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
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