### Question:
OtherNamesConverter { public List<OtherName> convert(OtherNames sifOtherNames) { if (sifOtherNames == null) { return null; } List<OtherName> sliNames = new ArrayList<OtherName>(); for (openadk.library.common.Name sifName : sifOtherNames) { OtherName sliName = new OtherName(); nameConverter.mapSifNameIntoSliName(sifName, sliName); sliName.setOtherNameType(NAME_TYPE_MAP.get(sifName.getType())); sliNames.add(sliName); } return sliNames; }  List<OtherName> convert(OtherNames sifOtherNames); void setNameConverter(NameConverter nameConverter);  }### Answer:
@Test public void testNullObject() { OtherNames sifOtherNames = null; List<OtherName> result = converter.convert(sifOtherNames); Assert.assertNull("OtherName list should be null", result); }
@Test public void testEmptyList() { OtherNames sifOtherNames = new OtherNames(); List<OtherName> result = converter.convert(sifOtherNames); Assert.assertEquals(0, result.size()); }
@Test public void testEmptyEmail() { OtherNames sifOtherNames = new OtherNames(); sifOtherNames.add(new Name()); List<OtherName> result = converter.convert(sifOtherNames); Assert.assertEquals(1, result.size()); OtherName sliOtherName = result.get(0); Assert.assertNull(sliOtherName.getOtherNameType()); Assert.assertNotNull(sliOtherName.getFirstName()); Assert.assertEquals(defaultName, sliOtherName.getFirstName()); Assert.assertNotNull(sliOtherName.getLastSurname()); Assert.assertEquals(defaultName, sliOtherName.getLastSurname()); Assert.assertNull(sliOtherName.getMiddleName()); Assert.assertNull(sliOtherName.getPersonalTitlePrefix()); Assert.assertNull(sliOtherName.getGenerationCodeSuffix()); }
@Test public void testMappings() { OtherNames otherNames = createOtherNames(); List<OtherName> result = converter.convert(otherNames); Assert.assertEquals("Should map 6 othernames", 6, result.size()); Iterator<OtherName> resIt = result.iterator(); for (String sliNameType : nameTypeMap.values()) { OtherName sliName = resIt.next(); Assert.assertNotNull(sliName); Assert.assertEquals(sliNameType, sliName.getOtherNameType()); Assert.assertEquals(firstName, sliName.getFirstName()); Assert.assertEquals(lastName, sliName.getLastSurname()); Assert.assertEquals(middleName, sliName.getMiddleName()); Assert.assertEquals(suffix, sliName.getGenerationCodeSuffix()); Assert.assertEquals(prefix, sliName.getPersonalTitlePrefix()); } }