-
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.
* unit test implemented * fixed formattting issues --------- Co-authored-by: Snehit Roda <[email protected]>
- Loading branch information
Showing
3 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
package org.apereo.portal; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.apereo.portal.dao.usertype.FunctionalNameType; | ||
import org.junit.Test; | ||
|
||
/** @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