Trimming profile names to fit byte budget and remove leading/trailing spaces.

This commit is contained in:
Alan Evans
2020-01-24 10:42:58 -05:00
committed by Greyson Parrelli
parent 7d15c602a6
commit e7f568e162
6 changed files with 84 additions and 52 deletions

View File

@@ -10,7 +10,7 @@ import static org.junit.Assert.assertTrue;
public final class ProfileNameTest {
@Test
@Test
public void givenEmpty_thenIExpectSaneDefaults() {
// GIVEN
ProfileName profileName = ProfileName.EMPTY;
@@ -23,7 +23,7 @@ public final class ProfileNameTest {
}
@Test
public void givenNullProfileName_whenIFromDataString_thenIExpectSaneDefaults() {
public void givenNullProfileName_whenIFromSerialized_thenIExpectExactlyEmpty() {
// GIVEN
ProfileName profileName = ProfileName.fromSerialized(null);
@@ -128,6 +128,7 @@ public final class ProfileNameTest {
// THEN
assertEquals("Blank String should be returned (For back compat)", "", data);
assertEquals("Family", name.getFamilyName());
}
@Test
@@ -161,4 +162,18 @@ public final class ProfileNameTest {
assertEquals("GivenSomeVeryLongNameSomeV", name.getGivenName());
assertEquals("FamilySomeVeryLongNameSome", name.getFamilyName());
}
@Test
public void givenProfileNameWithGivenNameAndFamilyNameWithSpaces_whenIToDataString_thenIExpectTrimmedProfileName() {
// GIVEN
ProfileName name = ProfileName.fromParts(" Given ", " Family");
// WHEN
String data = name.serialize();
// THEN
assertEquals(data, "Given\0Family");
assertEquals(name.getGivenName(), "Given");
assertEquals(name.getFamilyName(), "Family");
}
}