CermineToMetadataAffConverter { Affiliation convert(CermineAffiliation cAff) { Preconditions.checkNotNull(cAff); return Affiliation.newBuilder() .setRawText(cAff.getRawText()) .setOrganization(cAff.getInstitution()) .setAddress(cAff.getAddress()) .setCountryName(cAff.getCountryName()) .setCountryCode(cAff.getCountryCode()) .build(); }    }
@Test(expected = NullPointerException.class) public void convert_NULL() { cermineToMetadataAffConverter.convert(null); }
@Test public void convert() { CermineAffiliation cAff = mock(CermineAffiliation.class); when(cAff.getAddress()).thenReturn("some address"); when(cAff.getCountryCode()).thenReturn("PL"); when(cAff.getCountryName()).thenReturn("Poland"); when(cAff.getInstitution()).thenReturn("ICM, UW"); when(cAff.getRawText()).thenReturn("ICM, UW, Poland, some address"); Affiliation aff = cermineToMetadataAffConverter.convert(cAff); assertEquals("some address", aff.getAddress()); assertEquals("PL", aff.getCountryCode()); assertEquals("Poland", aff.getCountryName()); assertEquals("ICM, UW", aff.getOrganization()); assertEquals("ICM, UW, Poland, some address", aff.getRawText()); }