diff --git a/README.md b/README.md index 1b2bf83e8f671eb84522d2a1b6b6344865a4772a..f5bf592bce4d02224bf642c64d4dc6df156ebc6b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ Jede Brücke benötigt mindestens zwei Informationen: | `BRIDGE_x_IRI` | pro Brücke | Präfix, mit dem die IRI der Datensätze gebildet werden | | `BRIDGE_x_CONTRIBUTOR` | pro Brücke | [DCAT-AP.de contributorId](https://www.dcat-ap.de/def/dcatde/2.0/spec/#datensatz-datenbereitsteller-id), die für die Datensätze gesetzt wird | | `BRIDGE_x_DISTRIBUTED` | pro Brücke | ist hier eine 1 gesetzt, wird eine [verteilte CSW-Suche (DistributedSearch)](https://docs.opengeospatial.org/is/12-176r7/12-176r7.html#85) durchgeführt | -| `BRIDGE_x_EXCLUDE_TILES` | pro Brücke | gibt an, ob die Suche auf Einträge vom Typ `dataset`, `datasetCollection` und `series` eingeschränkt werden soll | +| `BRIDGE_x_TYPE_EXCLUDE` | pro Brücke | schließe Einträge vom hier angegeben Typ aus, mehrere Einträge können mit Komma getrennt werden, ein Beispiel: `appplication,tile` | +| `BRIDGE_x_TYPE_INCLUDE` | pro Brücke | beschränke die Suche auf die hier angegebenen Typen, mehrere Einträge können mit Komma getrennt werden, ein Beispiel: `dataset,datasetCollection,series` | | `BRIDGE_x_REMOVE_KEYWORDS` | pro Brücke | optionale Komma-getrennte Liste von Schlüsselwörtern, die entfernt werden sollen | | `BRIDGE_x_FIND_WMS_IN_INFO` | pro Brücke | gibt an, ob in den `transferOptions` from Typ `information` nach WMS gesucht werden soll. Mehr dazu bei den [Details der Konfigurationsoptionen](konfigurationsdetails.md#BRIDGE_FIND_WMS_IN_INFO) | | `BRIDGE_x_FIX_MISSING_TEMPORAL` | pro Brücke | ist hier eine 1 gesetzt, wird bei fehlender zeitlicher Coverage das Veröffentlichungsdatum als Startdatum verwendet | diff --git a/src/main/java/de/landsh/opendata/csw2dcat/BridgeSettings.java b/src/main/java/de/landsh/opendata/csw2dcat/BridgeSettings.java index 72e5fd49aab93749399b509ee32c89f181222733..6b0e0843b2944f7d4608d40b6e033b475efff82e 100644 --- a/src/main/java/de/landsh/opendata/csw2dcat/BridgeSettings.java +++ b/src/main/java/de/landsh/opendata/csw2dcat/BridgeSettings.java @@ -17,7 +17,16 @@ public class BridgeSettings { String contributorId = "https://www.gdi-sh.de"; boolean distributedSearch = false; - boolean excludeTiles = true; + /** + * List of item types (i.e. dataset, datasetCollection, series, application, tile, service) that should <b>not</b> be searched. + */ + String[] typeExclude; + + /** + * List of item types (i.e. dataset, datasetCollection, series, application, tile, service) that should be searched. + * If not set all item types will be searched. + */ + String[] typeInclude; boolean findWMSinInfo = false; diff --git a/src/main/java/de/landsh/opendata/csw2dcat/CswInterface.java b/src/main/java/de/landsh/opendata/csw2dcat/CswInterface.java index cad6bce61546f51aeda76f6174b70185b4ebb13b..7fa17dc88b08350e2fed9ee100b1a429d906b296 100644 --- a/src/main/java/de/landsh/opendata/csw2dcat/CswInterface.java +++ b/src/main/java/de/landsh/opendata/csw2dcat/CswInterface.java @@ -30,22 +30,24 @@ public class CswInterface { private static final Logger log = LoggerFactory.getLogger(CswInterface.class); private final SAXReader saxReader = new SAXReader(); private final String url; + /** + * List of item types (i.e. dataset, datasetCollection, series, application, tile, service) that should <b>not</b> be searched. + */ + private String[] typeExclude; + /** + * List of item types (i.e. dataset, datasetCollection, series, application, tile, service) that should be searched. + * If not set all item types will be searched. + */ + private String[] typeInclude; private CloseableHttpClient httpClient = HttpClients.createMinimal(); private String dumpCswResponse = null; private boolean distributedSearch = false; private boolean filterOpendata = false; - /** - * If <code>true</code> limit the results to datasets, dataset collections and series. - */ - private boolean excludeTiles = false; - /** * Ask the CSW server in the GetRecords operation to sort the results by Identifier */ private boolean sortResults = true; - private String authorization = null; - public CswInterface(String url) { this.url = url; } @@ -53,10 +55,35 @@ public class CswInterface { public CswInterface(BridgeSettings settings) { this.url = settings.cswURL; setDistributedSearch(settings.distributedSearch); - setExcludeTiles(settings.excludeTiles); filterOpendata = settings.filterOpenData; authorization = settings.authorization; sortResults = settings.sortResults; + typeExclude = settings.typeExclude; + typeInclude = settings.typeInclude; + } + + public void setTypeExclude(String[] typeExclude) { + this.typeExclude = typeExclude; + } + + public void setTypeInclude(String[] typeInclude) { + this.typeInclude = typeInclude; + } + + public void setSortResults(boolean sortResults) { + this.sortResults = sortResults; + } + + boolean hasTypeInclude() { + return typeInclude != null && typeInclude.length > 0; + } + + boolean hasTypeExclude() { + return typeExclude != null && typeExclude.length > 0; + } + + boolean hasMultipleTypeExclude() { + return typeExclude != null && typeExclude.length > 1; } void setHttpClient(CloseableHttpClient httpClient) { @@ -83,10 +110,6 @@ public class CswInterface { this.dumpCswResponse = s; } - public void setExcludeTiles(boolean excludeTiles) { - this.excludeTiles = excludeTiles; - } - /** * @param startPosition number of the first requested record. Used for paging. Will be sent to the WFS server as * <code>startPosition</code> First record is 1. @@ -138,6 +161,10 @@ public class CswInterface { } request.setEntity(new StringEntity(xmlRequest.toString(), StandardCharsets.UTF_8)); + { FileWriter fw = new FileWriter("/tmp/request.xml"); + fw.write(xmlRequest.toString()); + fw.close();} + final long start = System.currentTimeMillis(); try (CloseableHttpResponse response = httpClient.execute(request)) { if (response.getCode() == 200) { @@ -186,12 +213,15 @@ public class CswInterface { } } - if (!filters.isEmpty()) { - xmlRequest.append("<ogc:And xmlns:ogc=\"http://www.opengis.net/ogc\">"); + // Do we have multiple CQL filter queries and therefore need a surrounding And element? + final boolean needsAndElement = !filters.isEmpty() || hasMultipleTypeExclude() || hasTypeInclude(); + + if (needsAndElement) { + xmlRequest.append("<ogc:And>"); for (String propertyName : filters.keySet()) { Set<String> values = filters.get(propertyName); for (String value : values) { - xmlRequest.append("<ogc:PropertyIsEqualTo><ogc:PropertyName xmlns:apiso=\"http://www.opengis.net/cat/apiso/1.0\">apiso:") + xmlRequest.append("<ogc:PropertyIsEqualTo><ogc:PropertyName>apiso:") .append(propertyName) .append("</ogc:PropertyName>") .append("<ogc:Literal>") @@ -202,25 +232,32 @@ public class CswInterface { } } - if (excludeTiles) { - // limit the results to datasets, dataset collections and series. - xmlRequest.append("<ogc:Or>\n" + - " <ogc:PropertyIsEqualTo>\n" + - " <ogc:PropertyName xmlns:apiso=\"http://www.opengis.net/cat/apiso/1.0\">apiso:Type</ogc:PropertyName>\n" + - " <ogc:Literal>dataset</ogc:Literal>\n" + - " </ogc:PropertyIsEqualTo>\n" + - " <ogc:PropertyIsEqualTo>\n" + - " <ogc:PropertyName xmlns:apiso=\"http://www.opengis.net/cat/apiso/1.0\">apiso:Type</ogc:PropertyName>\n" + - " <ogc:Literal>datasetCollection</ogc:Literal>\n" + - " </ogc:PropertyIsEqualTo>\n" + - " <ogc:PropertyIsEqualTo>\n" + - " <ogc:PropertyName xmlns:apiso=\"http://www.opengis.net/cat/apiso/1.0\">apiso:Type</ogc:PropertyName>\n" + - " <ogc:Literal>series</ogc:Literal>\n" + - " </ogc:PropertyIsEqualTo>\n" + - " </ogc:Or>"); + if (hasTypeInclude()) { + xmlRequest.append("<ogc:Or>"); + + for (String type : typeInclude) { + xmlRequest.append("<ogc:PropertyIsEqualTo>" + + "<ogc:PropertyName>apiso:Type</ogc:PropertyName>" + + "<ogc:Literal>") + .append(type) + .append("</ogc:Literal></ogc:PropertyIsEqualTo>"); + } + + xmlRequest.append("</ogc:Or>"); + } + + if (hasTypeExclude()) { + for (String type : typeExclude) { + xmlRequest.append("<ogc:Not><ogc:PropertyIsEqualTo>" + + "<ogc:PropertyName>apiso:Type</ogc:PropertyName>" + + "<ogc:Literal>") + .append(type) + .append("</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Not>"); + } } - if (!filters.isEmpty()) { + + if (needsAndElement) { xmlRequest.append("</ogc:And>"); } @@ -252,6 +289,7 @@ public class CswInterface { final String xmlRequest = "<csw:GetRecords xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:ogc=\"http://www.opengis.net/ogc\"\n" + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ows=\"http://www.opengis.net/ows\"\n" + + "xmlns:apiso=\"http://www.opengis.net/cat/apiso/1.0\" "+ "outputSchema=\"http://www.isotc211.org/2005/gmd\" outputFormat=\"application/xml\" version=\"2.0.2\" service=\"CSW\" resultType=\"results\"\n" + "maxRecords=\"999\" xsi:schemaLocation=\"http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd\">\n" + " <csw:Query typeNames=\"csw:Record\">\n" + diff --git a/src/main/java/de/landsh/opendata/csw2dcat/Server.java b/src/main/java/de/landsh/opendata/csw2dcat/Server.java index caa33ae8dc9e60588075e74767b38cc3b93984e9..fe58560dce1280c89b5835eb8186f7f3c8756774 100644 --- a/src/main/java/de/landsh/opendata/csw2dcat/Server.java +++ b/src/main/java/de/landsh/opendata/csw2dcat/Server.java @@ -7,11 +7,15 @@ import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; import io.undertow.util.HttpString; import io.undertow.util.Methods; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.hc.core5.http.HttpStatus; -import org.apache.jena.rdf.model.*; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.vocabulary.DCAT; import org.apache.jena.vocabulary.RDF; import org.dom4j.Element; @@ -19,9 +23,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.io.InputStream; import java.io.StringWriter; -import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.*; @@ -60,7 +62,21 @@ public class Server implements HttpHandler { settings.contributorId = StringUtils.defaultString(bridgeContributor, "https://example.org/contributor"); settings.distributedSearch = BooleanUtils.toBoolean(System.getenv("BRIDGE" + prefix + "_DISTRIBUTED")); - settings.excludeTiles = BooleanUtils.toBoolean(System.getenv("BRIDGE" + prefix + "_EXCLUDE_TILES")); + if (System.getenv("BRIDGE" + prefix + "_TYPE_EXCLUDE") != null) { + String value = System.getenv("BRIDGE" + prefix + "_TYPE_EXCLUDE").replaceAll(" ", StringUtils.EMPTY); + settings.typeExclude = value.split(","); + } + if (BooleanUtils.toBoolean(System.getenv("BRIDGE" + prefix + "_EXCLUDE_TILES"))) { + if (settings.typeExclude == null) { + settings.typeExclude = new String[]{"tile"}; + } else { + settings.typeExclude = ArrayUtils.add(settings.typeExclude, "tile"); + } + } + if (System.getenv("BRIDGE" + prefix + "_TYPE_INCLUDE") != null) { + String value = System.getenv("BRIDGE" + prefix + "_TYPE_INCLUDE").replaceAll(" ", StringUtils.EMPTY); + settings.typeInclude = value.split(","); + } settings.findWMSinInfo = BooleanUtils.toBoolean(System.getenv("BRIDGE" + prefix + "_FIND_WMS_IN_INFO")); settings.addMissingTemporalStart = BooleanUtils.toBoolean(System.getenv("BRIDGE" + prefix + "_FIX_MISSING_TEMPORAL")); settings.filterOpenData = BooleanUtils.toBoolean(System.getenv("BRIDGE" + prefix + "_FILTER_OPENDATA")); @@ -127,8 +143,8 @@ public class Server implements HttpHandler { public static void main(String[] args) throws IOException { readEnvironmentVariables(); - if( enabledDcat2IsoBridge) { - dcat2iso = new Dcat2iso("ckan", baseURL,dcatDatasetBaseURL, ckanApiURL); + if (enabledDcat2IsoBridge) { + dcat2iso = new Dcat2iso("ckan", baseURL, dcatDatasetBaseURL, ckanApiURL); } final Undertow server = Undertow.builder() @@ -177,7 +193,7 @@ public class Server implements HttpHandler { } else if (requestURI.matches("^/[0-9]+/catalog.xml$")) { int bridgeNumber = NumberUtils.toInt(StringUtils.substringBetween(requestURI, "/")) - 1; this.csw2dcat(exchange, bridgeNumber); - } else if (enabledDcat2IsoBridge && "/iso/list.json".equals(requestURI )) { + } else if (enabledDcat2IsoBridge && "/iso/list.json".equals(requestURI)) { dcat2iso.list(exchange, "GDI-SH"); } else if (enabledDcat2IsoBridge && StringUtils.startsWith(requestURI, "/iso/")) { dcat2iso.handleDcat2isoRequest(exchange); @@ -193,8 +209,6 @@ public class Server implements HttpHandler { } - - /** * Handle CSW -> DCAT request */ diff --git a/src/test/java/de/landsh/opendata/csw2dcat/CswInterfaceTest.java b/src/test/java/de/landsh/opendata/csw2dcat/CswInterfaceTest.java index 6c0060fc71e4d79e45a18d4e0fde0a9b32d3c200..e4ca3e0e03a756248788262c14843307de2bbe3d 100644 --- a/src/test/java/de/landsh/opendata/csw2dcat/CswInterfaceTest.java +++ b/src/test/java/de/landsh/opendata/csw2dcat/CswInterfaceTest.java @@ -52,6 +52,12 @@ class CswInterfaceTest { } } + private static String wrapXML(String result) { + return "<xml" + + " xmlns:ogc=\"http://www.opengis.net/ogc\"" + + " xmlns:apiso=\"http://www.opengis.net/cat/apiso/1.0\">" + result + "</xml>"; + } + @BeforeEach public void setUp() { @@ -98,8 +104,7 @@ class CswInterfaceTest { String result = cswInterface.buildFilterQuery(filters); - Element filter = saxReader.read(new StringReader(result)).getRootElement(); - assertEquals("And", filter.getName()); + Element filter = saxReader.read(new StringReader(wrapXML(result))).getRootElement().element("And"); List<Element> properties = filter.elements("PropertyIsEqualTo"); assertEquals(3, properties.size()); @@ -123,8 +128,7 @@ class CswInterfaceTest { cswInterface.setFilterOpendata(true); String result = cswInterface.buildFilterQuery(filters); - Element filter = saxReader.read(new StringReader(result)).getRootElement(); - assertEquals("And", filter.getName()); + Element filter = saxReader.read(new StringReader(wrapXML(result))).getRootElement().element("And"); List<Element> properties = filter.elements("PropertyIsEqualTo"); assertEquals(4, properties.size()); @@ -144,8 +148,7 @@ class CswInterfaceTest { cswInterface.setFilterOpendata(true); String result = cswInterface.buildFilterQuery(new HashMap<>()); - Element filter = saxReader.read(new StringReader(result)).getRootElement(); - assertEquals("And", filter.getName()); + Element filter = saxReader.read(new StringReader(wrapXML(result))).getRootElement().element("And"); Element property = filter.element("PropertyIsEqualTo"); assertNotNull(property); assertEquals("apiso:Subject", property.elementText("PropertyName")); @@ -178,10 +181,10 @@ class CswInterfaceTest { assertEquals("GetRecords", xml.getName()); assertNotNull(xml.element("Query")); assertEquals("full", xml.element("Query").elementText("ElementSetName")); - assertNotNull( xml.element("Query").element("Constraint")); + assertNotNull(xml.element("Query").element("Constraint")); Element filter = xml.element("Query").element("Constraint").element("Filter"); - assertNotNull(filter ); - assertNotNull( filter.element("PropertyIsLike")); + assertNotNull(filter); + assertNotNull(filter.element("PropertyIsLike")); assertEquals("operatesOn", filter.element("PropertyIsLike").elementText("PropertyName")); assertEquals("%5bf8d8c6-01bf-465b-98de-a0f32f3d739e", filter.element("PropertyIsLike").elementText("Literal")); } @@ -212,18 +215,47 @@ class CswInterfaceTest { assertEquals("GetRecords", xml.getName()); assertNotNull(xml.element("Query")); assertEquals("full", xml.element("Query").elementText("ElementSetName")); - assertNotNull( xml.element("Query").element("Constraint")); + assertNotNull(xml.element("Query").element("Constraint")); Element filter = xml.element("Query").element("Constraint").element("Filter"); - assertNotNull(filter ); + assertNotNull(filter); - Element elementAnd = filter.element("And"); - assertNotNull( elementAnd); - assertNotNull( elementAnd.element("PropertyIsLike")); + Element elementAnd = filter.element("And"); + assertNotNull(elementAnd); + assertNotNull(elementAnd.element("PropertyIsLike")); assertEquals("operatesOn", elementAnd.element("PropertyIsLike").elementText("PropertyName")); assertEquals("%d8fee8c2-4385-46df-ab5e-8a372ac5a04d", elementAnd.element("PropertyIsLike").elementText("Literal")); - assertNotNull( elementAnd.element("PropertyIsEqualTo")); + assertNotNull(elementAnd.element("PropertyIsEqualTo")); assertEquals("apiso:Subject", elementAnd.element("PropertyIsEqualTo").elementText("PropertyName")); assertEquals("opendata", elementAnd.element("PropertyIsEqualTo").elementText("Literal")); } + + @Test + void buildFilterQuery_TypeExclude_One() throws DocumentException { + cswInterface.setTypeExclude(new String[]{"tile"}); + String result = cswInterface.buildFilterQuery(new HashMap<>()); + Element xml = saxReader.read(new StringReader(wrapXML(result))).getRootElement(); + + Element elementNot = xml.element("Not"); + assertNotNull(elementNot); + assertEquals("apiso:Type", elementNot.element("PropertyIsEqualTo").elementText("PropertyName")); + assertEquals("tile", elementNot.element("PropertyIsEqualTo").elementText("Literal")); + } + + @Test + void buildFilterQuery_TypeExclude_Multiple() throws DocumentException { + cswInterface.setTypeExclude(new String[]{"tile", "application"}); + String result = cswInterface.buildFilterQuery(new HashMap<>()); + Element xml = saxReader.read(new StringReader(wrapXML(result))).getRootElement(); + + Element andElement = xml.element("And"); + assertNotNull(andElement); + + List<Element> notElements = andElement.elements("Not"); + assertEquals("apiso:Type", notElements.get(0).element("PropertyIsEqualTo").elementText("PropertyName")); + assertEquals("tile", notElements.get(0).element("PropertyIsEqualTo").elementText("Literal")); + + assertEquals("apiso:Type", notElements.get(1).element("PropertyIsEqualTo").elementText("PropertyName")); + assertEquals("application", notElements.get(1).element("PropertyIsEqualTo").elementText("Literal")); + } } diff --git a/src/test/java/de/landsh/opendata/csw2dcat/ServerTests.java b/src/test/java/de/landsh/opendata/csw2dcat/ServerTests.java index d21a4fabfe41b6dcf6ce82438924f9f2bcd99af1..8c107685ba98730342c77929cdf6d49f72f09b07 100644 --- a/src/test/java/de/landsh/opendata/csw2dcat/ServerTests.java +++ b/src/test/java/de/landsh/opendata/csw2dcat/ServerTests.java @@ -10,8 +10,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.MockingDetails; import org.mockito.Mockito; import org.mockserver.client.MockServerClient; import org.mockserver.integration.ClientAndServer; @@ -23,7 +21,7 @@ import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Map; +import java.util.Arrays; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -60,11 +58,14 @@ public class ServerTests { public void readEnvironmentVariables_single() { environmentVariables.set("BRIDGE_URL", "http://localhost:8081/csw"); environmentVariables.set("BRIDGE_FIND_WMS_IN_INFO", "true"); + environmentVariables.set("BRIDGE_TYPE_EXCLUDE", "application,tile"); + Server.readEnvironmentVariables(); assertEquals(1, Server.bridgeSettings.size()); assertEquals("http://localhost:8081/csw", Server.bridgeSettings.get(0).cswURL); assertTrue(Server.bridgeSettings.get(0).findWMSinInfo); + assertEquals("[application, tile]", Arrays.toString(Server.bridgeSettings.get(0).typeExclude)); } @Test @@ -99,27 +100,43 @@ public class ServerTests { environmentVariables.set("BRIDGE_1_FIND_WMS_IN_INFO", "true"); environmentVariables.set("BRIDGE_1_REMOVE_KEYWORDS", "opendata"); environmentVariables.set("BRIDGE_1_FIX_MISSING_TEMPORAL", "1"); + environmentVariables.set("BRIDGE_1_TYPE_EXCLUDE", "application, tile,service"); + environmentVariables.set("BRIDGE_2_URL", "http://localhost:8082/csw"); environmentVariables.set("BRIDGE_2_FIND_WMS_IN_INFO", "false"); environmentVariables.set("BRIDGE_2_FILTER_OPENDATA", "true"); environmentVariables.set("BRIDGE_2_SORT_RESULTS", "false"); + environmentVariables.set("BRIDGE_2_TYPE_INCLUDE", "dataset,series"); + environmentVariables.set("BRIDGE_3_URL", "http://localhost:8083/csw"); - environmentVariables.set("BRIDGE_2_SORT_RESULTS", "1"); + environmentVariables.set("BRIDGE_3_SORT_RESULTS", "1"); Server.readEnvironmentVariables(); + BridgeSettings settings1 = Server.bridgeSettings.get(0); + BridgeSettings settings2 = Server.bridgeSettings.get(1); + BridgeSettings settings3 = Server.bridgeSettings.get(2); + assertEquals(3, Server.bridgeSettings.size()); - assertEquals("http://localhost:8081/csw", Server.bridgeSettings.get(0).cswURL); - assertEquals("http://localhost:8082/csw", Server.bridgeSettings.get(1).cswURL); - assertEquals("http://localhost:8083/csw", Server.bridgeSettings.get(2).cswURL); - assertTrue(Server.bridgeSettings.get(0).findWMSinInfo); - assertFalse(Server.bridgeSettings.get(1).findWMSinInfo); - assertTrue(Server.bridgeSettings.get(0).keywordRemove.contains("opendata")); - assertTrue(Server.bridgeSettings.get(0).addMissingTemporalStart); - assertFalse(Server.bridgeSettings.get(1).addMissingTemporalStart); - assertTrue(Server.bridgeSettings.get(1).filterOpenData); - assertTrue(Server.bridgeSettings.get(0).sortResults); - assertTrue(Server.bridgeSettings.get(1).sortResults); - assertTrue(Server.bridgeSettings.get(2).sortResults); + assertEquals("http://localhost:8081/csw", settings1.cswURL); + assertEquals("http://localhost:8082/csw", settings2.cswURL); + assertEquals("http://localhost:8083/csw", settings3.cswURL); + assertTrue(settings1.findWMSinInfo); + assertFalse(settings2.findWMSinInfo); + assertTrue(settings1.keywordRemove.contains("opendata")); + assertTrue(settings1.addMissingTemporalStart); + assertFalse(settings2.addMissingTemporalStart); + assertTrue(settings2.filterOpenData); + assertTrue(settings1.sortResults); + assertFalse(settings2.sortResults); + assertTrue(settings3.sortResults); + + assertNotNull(settings1.typeExclude); + assertEquals(3, settings1.typeExclude.length); + assertEquals("[application, tile, service]", Arrays.toString(settings1.typeExclude)); + + assertNotNull(settings2.typeInclude); + assertEquals(2, settings2.typeInclude.length); + assertEquals("[dataset, series]", Arrays.toString(settings2.typeInclude)); } @Test @@ -128,7 +145,7 @@ public class ServerTests { .when( request() .withMethod("POST") - .withHeader("X-CSW2DCATBridge","getRecords") + .withHeader("X-CSW2DCATBridge", "getRecords") .withPath("/csw"), exactly(1)) .respond( @@ -143,7 +160,7 @@ public class ServerTests { .when( request() .withMethod("POST") - .withHeader("X-CSW2DCATBridge","operatesOn") + .withHeader("X-CSW2DCATBridge", "operatesOn") .withPath("/csw"), exactly(1)) .respond( @@ -167,7 +184,7 @@ public class ServerTests { final BridgeSettings bridgeSettings = new BridgeSettings(); bridgeSettings.cswURL = "http://localhost:" + mockServer.getPort() + "/csw"; - Server.bridgeSettings.put(0,bridgeSettings) ; + Server.bridgeSettings.put(0, bridgeSettings); final Server server = new Server();