@Test public void testNoId() throws CatalogTransformerException, IOException, XpathException, SAXException { // given XmlResponseQueueTransformer transformer = new XmlResponseQueueTransformer(); SourceResponse response = givenSourceResponse(DEFAULT_SOURCE_ID, null); // when BinaryContent binaryContent = transformer.transform(response, null); // then assertThat(binaryContent.getMimeType(), is(XmlResponseQueueTransformer.MIME_TYPE)); byte[] bytes = binaryContent.getByteArray(); String output = new String(bytes); print(output, verboseDebug); assertXpathEvaluatesTo(DEFAULT_SOURCE_ID, "/mc:metacards/mc:metacard/mc:source", output); assertXpathNotExists("/mc:metacards/mc:metacard/@gml:id", output); verifyDefaults("1", output); }
@Test public void testMultiple() throws CatalogTransformerException, IOException, XpathException, SAXException { // given XmlResponseQueueTransformer transformer = new XmlResponseQueueTransformer(); SourceResponse response = givenSourceResponse(new MetacardStub("source1", "id1"), new MetacardStub("source2", "id2")); // when BinaryContent binaryContent = transformer.transform(response, null); // then assertThat(binaryContent.getMimeType(), is(XmlResponseQueueTransformer.MIME_TYPE)); byte[] bytes = binaryContent.getByteArray(); String output = new String(bytes); print(output, verboseDebug); assertXpathEvaluatesTo("source1", "/mc:metacards/mc:metacard[1]/mc:source", output); assertXpathEvaluatesTo("id1", "/mc:metacards/mc:metacard[1]/@gml:id", output); assertXpathEvaluatesTo("source2", "/mc:metacards/mc:metacard[2]/mc:source", output); assertXpathEvaluatesTo("id2", "/mc:metacards/mc:metacard[2]/@gml:id", output); verifyDefaults("1", output); verifyDefaults("2", output); }
/** * No {@link MetacardType} name should use the default name. * * @throws CatalogTransformerException * @throws IOException * @throws SAXException * @throws XpathException */ @Test public void testMetacardTypeName_Empty() throws CatalogTransformerException, IOException, XpathException, SAXException { // given XmlResponseQueueTransformer transformer = new XmlResponseQueueTransformer(); SourceResponse response = givenMetacardTypeName(""); // when BinaryContent binaryContent = transformer.transform(response, null); // then assertThat(binaryContent.getMimeType(), is(XmlResponseQueueTransformer.MIME_TYPE)); byte[] bytes = binaryContent.getByteArray(); String output = new String(bytes); print(output, verboseDebug); assertXpathEvaluatesTo(DEFAULT_TYPE_NAME, "/mc:metacards/mc:metacard/mc:type", output); }