-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CCMSPUI-529 Added BooleanStringConverterTest
Signed-off-by: Jamie Briggs <jamie.briggs@digital.justice.gov.uk>
- Loading branch information
Jamie Briggs
committed
Feb 3, 2025
1 parent
6a328c9
commit c4ef4fb
Showing
3 changed files
with
108 additions
and
8 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
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
78 changes: 78 additions & 0 deletions
78
data-service/src/test/java/uk/gov/laa/ccms/data/entity/BooleanStringConverterTest.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,78 @@ | ||
package uk.gov.laa.ccms.data.entity; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class BooleanStringConverterTest { | ||
|
||
@InjectMocks | ||
BooleanStringConverter booleanStringConverter; | ||
|
||
@Nested | ||
@DisplayName("Test ConvertToDb") | ||
class ConvertToDbTest { | ||
|
||
@Test | ||
@DisplayName("Should return true") | ||
void shouldReturnTrue(){ | ||
assertTrue(booleanStringConverter.convertToEntityAttribute("True")); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should return true lowercase") | ||
void shouldReturnTrueLowercase(){ | ||
assertTrue(booleanStringConverter.convertToEntityAttribute("true")); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should return true uppercase") | ||
void shouldReturnTrueUppercase(){ | ||
assertTrue(booleanStringConverter.convertToEntityAttribute("TRUE")); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should return false") | ||
void shouldReturnFalse(){ | ||
assertFalse(booleanStringConverter.convertToEntityAttribute("False")); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should return false lowercase") | ||
void shouldReturnFalseLowercase(){ | ||
assertFalse(booleanStringConverter.convertToEntityAttribute("false")); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should return false uppercase") | ||
void shouldReturnFalseUppercase(){ | ||
assertFalse(booleanStringConverter.convertToEntityAttribute("FALSE")); | ||
} | ||
|
||
} | ||
|
||
@Nested | ||
@DisplayName("Test ConvertToDatabaseColumn") | ||
class ConvertToDatabaseColumnTest { | ||
|
||
@Test | ||
@DisplayName("Should return true") | ||
void shouldReturnTrue(){ | ||
assertEquals("true", booleanStringConverter.convertToDatabaseColumn(true)); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should return false") | ||
void shouldReturnFalse(){ | ||
assertEquals("false", booleanStringConverter.convertToDatabaseColumn(false)); | ||
} | ||
} | ||
} |