src/test/java/gov/usgs/cida/pubs/transform/CrossrefTransformerIT.java
@Test
	public void testOmitUnknownContributorType() throws IOException {
		//make a new contributor with an unknown type
		int unknownContributorTypeId = -999;
		ContributorType unknownContributorType = new ContributorType();
		unknownContributorType.setId(unknownContributorTypeId);

		PublicationContributor<?> strangePublicationContributor = new PublicationContributor<>();
		strangePublicationContributor.setContributorType(unknownContributorType);

		Publication<?> pub = CrossrefTestPubBuilder.buildNumberedSeriesPub(new Publication<>());

		//add the contributor of unknown type to the publication
		Collection<PublicationContributor<?>> contributors = pub.getContributors();
		contributors.add(strangePublicationContributor);
		pub.setContributors(contributors);

		instance.writeResult(pub);
		instance.end();

		String output = new String(target.toByteArray(), PubsConstantsHelper.DEFAULT_ENCODING);
		assertTrue(StringUtils.isNotBlank(output), "The XML was null or empty.");
		assertDoesNotThrow(() -> {
			docBuilder.parse(new InputSource(new StringReader(output)));
		}, "The XML is not well-formed.");

		String expected = harmonizeXml(updateWarehouseEndpoint(testOneNumberedSeriesXml));
		String actual = harmonizeXml(output);
		assertEquals(expected, actual);
	}
/**
	 * Test that contributors of unknown type are omitted
	 */
Test that contributors of unknown type are omitted
Test that contributors of unknown type are omitted
@Test
	public void testOmitUnknownContributorType() throws IOException {
		int unknownContributorTypeId = -999;
		ContributorType unknownContributorType = new ContributorType();
		unknownContributorType.setId(unknownContributorTypeId);
		PublicationContributor<?> strangePublicationContributor = new PublicationContributor<>();
		strangePublicationContributor.setContributorType(unknownContributorType);
		Publication<?> pub = CrossrefTestPubBuilder.buildNumberedSeriesPub(new Publication<>());
		Collection<PublicationContributor<?>> contributors = pub.getContributors();
		contributors.add(strangePublicationContributor);
		pub.setContributors(contributors);
		instance.writeResult(pub);
		instance.end();
		String output = new String(target.toByteArray(), PubsConstantsHelper.DEFAULT_ENCODING);
		assertTrue(StringUtils.isNotBlank(output), "The XML was null or empty.");
		assertDoesNotThrow(() -> {
			docBuilder.parse(new InputSource(new StringReader(output)));
		}, "The XML is not well-formed.");
		String expected = harmonizeXml(updateWarehouseEndpoint(testOneNumberedSeriesXml));
		String actual = harmonizeXml(output);
		assertEquals(expected, actual);
	}
@ Test public void testOmitUnknownContributorType ( ) throws IOException { int unknownContributorTypeId = - 999 ; ContributorType unknownContributorType = new ContributorType ( ) ; unknownContributorType . setId ( unknownContributorTypeId ) ; PublicationContributor < ? > strangePublicationContributor = new PublicationContributor < > ( ) ; strangePublicationContributor . setContributorType ( unknownContributorType ) ; Publication < ? > pub = CrossrefTestPubBuilder . buildNumberedSeriesPub ( new Publication < > ( ) ) ; Collection < PublicationContributor < ? > > contributors = pub . getContributors ( ) ; contributors . add ( strangePublicationContributor ) ; pub . setContributors ( contributors ) ; instance . writeResult ( pub ) ; instance . end ( ) ; String output = new String ( target . toByteArray ( ) , PubsConstantsHelper . DEFAULT_ENCODING ) ; assertTrue ( StringUtils . isNotBlank ( output ) , "The XML was null or empty." ) ; assertDoesNotThrow ( ( ) -> { docBuilder . parse ( new InputSource ( new StringReader ( output ) ) ) ; } , "The XML is not well-formed." ) ; String expected = harmonizeXml ( updateWarehouseEndpoint ( testOneNumberedSeriesXml ) ) ; String actual = harmonizeXml ( output ) ; assertEquals ( expected , actual ) ; }
Test that contributors of unknown type are omitted
Test that contributors of unknown type are omitted
//make a new contributor with an unknown type //add the contributor of unknown type to the publication