Test: Add null name case to PetTypeFormatterTests

Adds a unit test to verify that PetTypeFormatter returns '<null>'
when the PetType name is null, ensuring better coverage and robustness.

Signed-off-by: ronanpjr <ronanpjr@proton.me>
This commit is contained in:
ronanpjr 2025-12-05 10:37:18 -03:00
parent 3e1ce239f4
commit 670e0a2bbe

View file

@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -60,6 +60,13 @@ class PetTypeFormatterTests {
assertThat(petTypeName).isEqualTo("Hamster");
}
@Test
void testPrintWithNullName() {
PetType petType = new PetType();
String petTypeName = this.petTypeFormatter.print(petType, Locale.ENGLISH);
assertThat(petTypeName).isEqualTo("<null>");
}
@Test
void shouldParse() throws ParseException {
given(types.findPetTypes()).willReturn(makePetTypes());