Skip to content

Commit

Permalink
Update config and tests for RPPD CI build
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Jan 31, 2024
1 parent cfafbe8 commit a5830ba
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 78 deletions.
10 changes: 5 additions & 5 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ play {
data {
entityfacts: "test/data/entityfacts/authorities_entityfacts_test.jsonld"
rdfxml: "test/data/input"
jsonlines: "../rpb/conf/output/bulk/rppd"
jsonlines: "test/data/index" # "../rpb/conf/output/bulk/rppd"
backup: "test/data/backup"
updates.url: "http://gnd-proxy.lobid.org/oai/repository"
updates.rdf: "GND-updates.rdf"
Expand All @@ -32,13 +32,13 @@ entityfacts {

index {
boot: {
hosts: ["weywot3.hbz-nrw.de", "weywot4.hbz-nrw.de", "weywot5.hbz-nrw.de"]
cluster: "weywot"
hosts: ["localhost"] # ["weywot3.hbz-nrw.de", "weywot4.hbz-nrw.de", "weywot5.hbz-nrw.de"]
cluster: "elasticsearch" # "weywot"
name: "gnd-boot" # "gnd"
}
prod: {
hosts: ["weywot3.hbz-nrw.de", "weywot4.hbz-nrw.de", "weywot5.hbz-nrw.de"]
cluster: "weywot"
hosts: ["localhost"] # ["weywot3.hbz-nrw.de", "weywot4.hbz-nrw.de", "weywot5.hbz-nrw.de"]
cluster: "elasticsearch" # cluster: "weywot"
name: "gnd-rppd-test" # e.g. "gnd-rppd-20231103-1000" for new index
}
type: "authority"
Expand Down
2 changes: 1 addition & 1 deletion test/apps/ConvertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void testPlaceOfDeathObjects() throws FileNotFoundException {
public void testRemoveNewlinesInLabels() throws FileNotFoundException {
String jsonLd = jsonLdFor("118512676");
JsonNode categories = Json.parse(jsonLd).get("gndSubjectCategory");
assertTrue(categories.toString().contains("Personen zu Literaturgeschichte (Schriftsteller)"));
assertTrue(categories.toString().contains("Literaturgeschichte (Schriftsteller)"));
}

@Test
Expand Down
88 changes: 44 additions & 44 deletions test/controllers/AcceptIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,58 +38,58 @@ public static Collection<Object[]> data() {
// @formatter:off
return Arrays.asList(new Object[][] {
// service meta data: context and dataset description
{ fakeRequest(GET, "/gnd/context.jsonld"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/gnd/dataset.jsonld"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/gnd/dataset"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/gnd/dataset").header("Accept", "text/html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/gnd/dataset").header("Accept", "application/ld+json"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/gnd/dataset").header("Accept", "application/json"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/context.jsonld"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/dataset.jsonld"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/dataset"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/dataset").header("Accept", "text/html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/dataset").header("Accept", "application/ld+json"), /*->*/ "application/ld+json" },
{ fakeRequest(GET, "/dataset").header("Accept", "application/json"), /*->*/ "application/ld+json" },
// search, default format: JSON
{ fakeRequest(GET, "/gnd/search?q=*"), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/search?q=*").header("Accept", "*/*"), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/search?q=*&format="), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/search?q=*&format=json"), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/search?q=*&format=whatever"), /*->*/ "text/html" },
{ fakeRequest(GET, "/gnd/search?q=*").header("Accept", "text/plain"), /*->*/ "text/html" },
{ fakeRequest(GET, "/search?q=*"), /*->*/ "application/json" },
{ fakeRequest(GET, "/search?q=*").header("Accept", "*/*"), /*->*/ "application/json" },
{ fakeRequest(GET, "/search?q=*&format="), /*->*/ "application/json" },
{ fakeRequest(GET, "/search?q=*&format=json"), /*->*/ "application/json" },
{ fakeRequest(GET, "/search?q=*&format=whatever"), /*->*/ "text/html" },
{ fakeRequest(GET, "/search?q=*").header("Accept", "text/plain"), /*->*/ "text/html" },
// search, bulk format: JSON lines
{ fakeRequest(GET, "/gnd/search?q=*").header("Accept", "application/x-jsonlines"), /*->*/ "application/x-jsonlines" },
{ fakeRequest(GET, "/gnd/search?format=jsonl"), /*->*/ "application/x-jsonlines" },
{ fakeRequest(GET, "/gnd/search?q=*&format=jsonl"), /*->*/ "application/x-jsonlines" },
{ fakeRequest(GET, "/gnd/search?q=vwxyz&format=jsonl"), /*->*/ "application/x-jsonlines" },
{ fakeRequest(GET, "/search?q=*").header("Accept", "application/x-jsonlines"), /*->*/ "application/x-jsonlines" },
{ fakeRequest(GET, "/search?format=jsonl"), /*->*/ "application/x-jsonlines" },
{ fakeRequest(GET, "/search?q=*&format=jsonl"), /*->*/ "application/x-jsonlines" },
{ fakeRequest(GET, "/search?q=vwxyz&format=jsonl"), /*->*/ "application/x-jsonlines" },
// search, other formats as query param:
{ fakeRequest(GET, "/gnd/search?q=*&format=html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/search?q=*&format=html"), /*->*/ "text/html" },
// search, other formats via header:
{ fakeRequest(GET, "/gnd/search?q=*").header("Accept", "application/json"), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/search?q=*").header("Accept", "text/html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/search?q=*").header("Accept", "application/json"), /*->*/ "application/json" },
{ fakeRequest(GET, "/search?q=*").header("Accept", "text/html"), /*->*/ "text/html" },
// get, default format: JSON
{ fakeRequest(GET, "/gnd/118820591"), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/118820591?format="), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/118820591?format=json"), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/118820591?format=whatever"), /*->*/ "text/html" },
{ fakeRequest(GET, "/gnd/118820591?format=whatever").header("Accept", "text/html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "text/plain"), /*->*/ "application/n-triples" },
{ fakeRequest(GET, "/118820591"), /*->*/ "application/json" },
{ fakeRequest(GET, "/118820591?format="), /*->*/ "application/json" },
{ fakeRequest(GET, "/118820591?format=json"), /*->*/ "application/json" },
{ fakeRequest(GET, "/118820591?format=whatever"), /*->*/ "text/html" },
{ fakeRequest(GET, "/118820591?format=whatever").header("Accept", "text/html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/118820591").header("Accept", "text/plain"), /*->*/ "application/n-triples" },
// get, other formats as query param:
{ fakeRequest(GET, "/gnd/118820591?format=html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/gnd/118820591?format=rdf"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/gnd/118820591?format=ttl"), /*->*/ "text/turtle" },
{ fakeRequest(GET, "/gnd/118820591?format=nt"), /*->*/ "application/n-triples" },
{ fakeRequest(GET, "/gnd/118820591?format=preview"), /*->*/ "text/html" },
{ fakeRequest(GET, "/118820591?format=html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/118820591?format=rdf"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/118820591?format=ttl"), /*->*/ "text/turtle" },
{ fakeRequest(GET, "/118820591?format=nt"), /*->*/ "application/n-triples" },
{ fakeRequest(GET, "/118820591?format=preview"), /*->*/ "text/html" },
// get, other formats as path elem:
{ fakeRequest(GET, "/gnd/118820591.html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/gnd/118820591.rdf"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/gnd/118820591.ttl"), /*->*/ "text/turtle" },
{ fakeRequest(GET, "/gnd/118820591.nt"), /*->*/ "application/n-triples" },
{ fakeRequest(GET, "/gnd/118820591.preview"), /*->*/ "text/html" },
{ fakeRequest(GET, "/118820591.html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/118820591.rdf"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/118820591.ttl"), /*->*/ "text/turtle" },
{ fakeRequest(GET, "/118820591.nt"), /*->*/ "application/n-triples" },
{ fakeRequest(GET, "/118820591.preview"), /*->*/ "text/html" },
// get, others formats via header:
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "application/json"), /*->*/ "application/json" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "text/html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "text/xml"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "application/xml"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "application/rdf+xml"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "text/turtle"), /*->*/ "text/turtle" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "application/x-turtle"), /*->*/ "text/turtle" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "text/plain"), /*->*/ "application/n-triples" },
{ fakeRequest(GET, "/gnd/118820591").header("Accept", "application/n-triples"), /*->*/ "application/n-triples" }});
{ fakeRequest(GET, "/118820591").header("Accept", "application/json"), /*->*/ "application/json" },
{ fakeRequest(GET, "/118820591").header("Accept", "text/html"), /*->*/ "text/html" },
{ fakeRequest(GET, "/118820591").header("Accept", "text/xml"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/118820591").header("Accept", "application/xml"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/118820591").header("Accept", "application/rdf+xml"), /*->*/ "application/rdf+xml" },
{ fakeRequest(GET, "/118820591").header("Accept", "text/turtle"), /*->*/ "text/turtle" },
{ fakeRequest(GET, "/118820591").header("Accept", "application/x-turtle"), /*->*/ "text/turtle" },
{ fakeRequest(GET, "/118820591").header("Accept", "text/plain"), /*->*/ "application/n-triples" },
{ fakeRequest(GET, "/118820591").header("Accept", "application/n-triples"), /*->*/ "application/n-triples" }});
} // @formatter:on

private RequestBuilder fakeRequest;
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/JsonResponseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class JsonResponseTest extends IndexTest {

@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] { { "/gnd/search?format=json" }, { "/gnd/2136169-1" } });
return Arrays.asList(new Object[][] { { "/search?format=json" }, { "/2136169-1" } });
}

private String path;
Expand Down
50 changes: 26 additions & 24 deletions test/controllers/ReconcileIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public class ReconcileIntegrationTest extends IndexTest {

@Test
public void reconcileMetadataRequestNoCallback() {
metadataRequest("/gnd/reconcile");
metadataRequest("/reconcile");
}

@Test
public void reconcileMetadataRequestNoCallbackTrailingSlash() {
metadataRequest("/gnd/reconcile/");
metadataRequest("/reconcile/");
}

private void metadataRequest(String uri) {
Expand All @@ -72,7 +72,7 @@ private void metadataRequest(String uri) {
public void reconcilePropertiesRequest() {
Application application = fakeApplication();
running(application, () -> {
Result result = route(application, fakeRequest(GET, "/gnd/reconcile/properties"));
Result result = route(application, fakeRequest(GET, "/reconcile/properties"));
assertNotNull(result);
assertThat(result.contentType().get(), is(equalTo("application/json")));
assertThat(result.header("Access-Control-Allow-Origin").get(), is(equalTo("*")));
Expand All @@ -83,7 +83,7 @@ public void reconcilePropertiesRequest() {
public void reconcileSuggestTypeRequest() {
Application application = fakeApplication();
running(application, () -> {
Result result = route(application, fakeRequest(GET, "/gnd/reconcile/suggest/type?prefix=werk"));
Result result = route(application, fakeRequest(GET, "/reconcile/suggest/type?prefix=werk"));
assertNotNull(result);
assertThat(result.contentType().get(), is(equalTo("application/json")));
assertThat(result.header("Access-Control-Allow-Origin").get(), is(equalTo("*")));
Expand All @@ -93,12 +93,12 @@ public void reconcileSuggestTypeRequest() {

@Test
public void reconcileMetadataRequestWithCallback() {
metadataRequestWithCallback("/gnd/reconcile?callback=jsonp");
metadataRequestWithCallback("/reconcile?callback=jsonp");
}

@Test
public void reconcileMetadataRequestWithCallbackTrailingSlash() {
metadataRequestWithCallback("/gnd/reconcile/?callback=jsonp");
metadataRequestWithCallback("/reconcile/?callback=jsonp");
}

private void metadataRequestWithCallback(String uri) {
Expand All @@ -112,40 +112,40 @@ private void metadataRequestWithCallback(String uri) {
}

@Test
// curl --data 'queries={"q99":{"query":"*"}}' localhost:9000/gnd/reconcile
// curl --data 'queries={"q99":{"query":"*"}}' localhost:9000/reconcile
public void reconcileRequest() {
reconcileRequest("/gnd/reconcile", "Twain, Mark", /* -> */ "118624822");
reconcileRequest("/reconcile", "Twain, Mark", /* -> */ "118624822");
}

@Test
// curl --data 'queries={"q99":{"query":"*"}}' localhost:9000/gnd/reconcile/
// curl --data 'queries={"q99":{"query":"*"}}' localhost:9000/reconcile/
public void reconcileRequestTrailingSlash() {
reconcileRequest("/gnd/reconcile/", "Twain, Mark", /* -> */ "118624822");
reconcileRequest("/reconcile/", "Twain, Mark", /* -> */ "118624822");
}

@Test
public void reconcileRequestWithGndId() {
reconcileRequest("/gnd/reconcile/", "118624822", /* -> */ "118624822");
reconcileRequest("/reconcile/", "118624822", /* -> */ "118624822");
}

@Test
public void reconcileRequestWithGndUri() {
reconcileRequest("/gnd/reconcile/", "https://d-nb.info/gnd/118624822", /* -> */ "118624822");
reconcileRequest("/reconcile/", "https://d-nb.info/gnd/118624822", /* -> */ "118624822");
}

@Test
public void reconcileRequestWithGndIdDash() {
reconcileRequest("/gnd/reconcile/", "2136169-1", /* -> */ "2136169-1");
reconcileRequest("/reconcile/", "2136169-1", /* -> */ "2136169-1");
}

@Test
public void reconcileRequestWithGndUriDash() {
reconcileRequest("/gnd/reconcile/", "https://d-nb.info/gnd/2136169-1", /* -> */ "2136169-1");
reconcileRequest("/reconcile/", "https://d-nb.info/gnd/2136169-1", /* -> */ "2136169-1");
}

@Test
public void reconcileRequestWithViafUri() {
reconcileRequest("/gnd/reconcile/", "http://viaf.org/viaf/50566653", /* -> */ "118624822");
reconcileRequest("/reconcile/", "http://viaf.org/viaf/50566653", /* -> */ "118624822");
}

private void reconcileRequest(String uri, String query, String gndId) {
Expand All @@ -166,15 +166,15 @@ private void reconcileRequest(String uri, String query, String gndId) {
}

@Test
// curl -g 'localhost:9000/gnd/reconcile?queries={"q99":{"query":"*"}}'
// curl -g 'localhost:9000/reconcile?queries={"q99":{"query":"*"}}'
public void reconcileRequestGetWithReservedChars() {
Application application = fakeApplication();
running(application, () -> {
Result result = null;
try {
result = route(application,
fakeRequest(GET,
"/gnd/reconcile?queries=" + URLEncoder.encode(
"/reconcile?queries=" + URLEncoder.encode(
"{\"q99\":{\"query\":\"Conference +=<>(){}[]^ (1997 : Kyoto / Japan)\"}}",
StandardCharsets.UTF_8.name())));
} catch (UnsupportedEncodingException e) {
Expand All @@ -189,11 +189,11 @@ public void reconcileRequestGetWithReservedChars() {
}

@Test
// curl --data 'queries={"q99":{"query":"*"}}' localhost:9000/gnd/reconcile
// curl --data 'queries={"q99":{"query":"*"}}' localhost:9000/reconcile
public void reconcileRequestPostWithReservedChars() {
Application application = fakeApplication();
running(application, () -> {
Result result = route(application, fakeRequest(POST, "/gnd/reconcile")//
Result result = route(application, fakeRequest(POST, "/reconcile")//
.bodyForm(ImmutableMap.of("queries",
"{\"q99\":{\"query\":\"Conference +=<>(){}[]^ (1997 : Kyoto / Japan)\"}}")));
assertThat(result.status(), is(equalTo(Http.Status.OK)));
Expand All @@ -204,12 +204,14 @@ public void reconcileRequestPostWithReservedChars() {
}

@Test
// curl --data 'queries={"q99":{"query":"*","properties":[{"pid":"dateOfBirth","v":"1889-04-26"}]}}' localhost:9000/gnd/reconcile
// curl --data
// 'queries={"q99":{"query":"*","properties":[{"pid":"dateOfBirth","v":"1889-04-26"}]}}'
// localhost:9000/reconcile
public void reconcileRequestWithProperties() {
Application application = fakeApplication();
running(application, () -> {
Result result = route(application,
fakeRequest(POST, "/gnd/reconcile")//
fakeRequest(POST, "/reconcile")//
.bodyForm(ImmutableMap.of("queries",
"{\"q99\":{\"query\":\"*\",\"properties\":[{\"pid\":\"dateOfBirth\",\"v\":\"[1889* TO 1890*]\"}]}}")));
assertThat(result.status(), is(equalTo(Http.Status.OK)));
Expand All @@ -223,7 +225,7 @@ public void reconcileRequestWithProperties() {
public void reconcileRequestWithType() {
Application application = fakeApplication();
running(application, () -> {
Result result = route(application, fakeRequest(POST, "/gnd/reconcile").bodyForm(
Result result = route(application, fakeRequest(POST, "/reconcile").bodyForm(
ImmutableMap.of("queries", "{\"q99\":{\"query\":\"Twain, Mark\", \"type\":\"CorporateBody\"}}")));
String content = contentAsString(result);
Logger.debug(Json.prettyPrint(Json.parse(content)));
Expand All @@ -234,7 +236,7 @@ public void reconcileRequestWithType() {

@Test
// curl -g
// 'localhost:9000/gnd/reconcile?extend=
// 'localhost:9000/reconcile?extend=
// {"ids":[],"properties":[{"id":"geographicAreaCode"},{"id":"professionOrOccupation"}]}'
// See https://github.com/hbz/lobid-gnd/issues/241
public void extendRequestMeta() {
Expand All @@ -246,7 +248,7 @@ public void extendRequestMeta() {
"{\"id\":\"geographicAreaCode\"}," + //
"{\"id\":\"professionOrOccupation\"}]}";
result = route(application, fakeRequest(GET,
"/gnd/reconcile?extend=" + URLEncoder.encode(extensionQuery, StandardCharsets.UTF_8.name())));
"/reconcile?extend=" + URLEncoder.encode(extensionQuery, StandardCharsets.UTF_8.name())));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Expand Down
6 changes: 3 additions & 3 deletions test/controllers/SuggestionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void suggestionsWithoutCallback() {
Application application = fakeApplication();
running(application, () -> {
Result result = route(application, fakeRequest(GET,
"/gnd/search?q=*&filter=type:Person&format=json:preferredName,professionOrOccupation"));
"/search?q=*&filter=type:Person&format=json:preferredName,professionOrOccupation"));
assertNotNull("We have a result", result);
assertThat(result.contentType().get(), is(equalTo("application/json")));
String content = contentAsString(result);
Expand All @@ -50,7 +50,7 @@ public void suggestionsWithCallback() {
Application application = fakeApplication();
running(application, () -> {
Result result = route(application,
fakeRequest(GET, "/gnd/search?q=*&filter=type:Person&format=json:preferredName&callback=test"));
fakeRequest(GET, "/search?q=*&filter=type:Person&format=json:preferredName&callback=test"));
assertNotNull("We have a result", result);
assertThat(result.contentType().get(), is(equalTo("application/javascript")));
assertThat(contentAsString(result), allOf(containsString("test("), // callback
Expand All @@ -62,7 +62,7 @@ public void suggestionsWithCallback() {
public void suggestionsCorsHeader() {
Application application = fakeApplication();
running(application, () -> {
Result result = route(application, fakeRequest(GET, "/gnd/search?q=*&format=json:preferredName"));
Result result = route(application, fakeRequest(GET, "/search?q=*&format=json:preferredName"));
assertNotNull("We have a result", result);
assertThat(result.header("Access-Control-Allow-Origin").get(), is(equalTo("*")));
});
Expand Down

0 comments on commit a5830ba

Please sign in to comment.