Skip to content

Commit

Permalink
Merge pull request #124 from HHS/develop
Browse files Browse the repository at this point in the history
Bump version to 1.0.7
  • Loading branch information
danizen authored Feb 27, 2019
2 parents 26be3a7 + da322f9 commit c06c290
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 1,547 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>gov.nih.nlm.lode</groupId>
<artifactId>meshrdf</artifactId>
<packaging>pom</packaging>
<version>1.0.6</version>
<version>1.0.7</version>
<name>NLM MeSH RDF parent project</name>
<scm>
<url>https://github.com/HHS/meshrdf</url>
Expand Down
16 changes: 14 additions & 2 deletions webui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>gov.nih.nlm.lode</groupId>
<artifactId>meshrdf</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
</parent>

<properties>
Expand Down Expand Up @@ -50,10 +50,22 @@
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
<resource>
<directory>../meta</directory>
<includes>
<include>*.ttl</include>
<include>*.owl</include>
</includes>
</resource>
</webResources>
<overlays>
<overlay>
<groupId>ebi-lode</groupId>
<artifactId>web-ui</artifactId>
<artifactId>web-ui</artifactId>
<excludes>
<exclude>index.html</exclude>
<exclude>query.html</exclude>
Expand Down
2 changes: 1 addition & 1 deletion webui/src/main/resources/lode.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ lode.explorer.max.objects=50
# Specifies if the query engine should use any inference when answering queries. This should be
# false when querying over http and is only relevant when using the virtuoso JDBC configuration
# at the moment
lode.explorer.useInference=true
lode.explorer.useInference=false

# Specify the baseURI to be used when the API uri is relative
lode.explorer.service.baseuri=http://id.nlm.nih.gov/mesh/
Expand Down
6 changes: 6 additions & 0 deletions webui/src/main/webapp/WEB-INF/urlrewrite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@
<to type="redirect">vocabulary.owl</to>
</rule>

<rule>
<name>void-to-ttl-file</name>
<from casesensitive="true">^/void(#.*)?$</from>
<to type="redirect">void.ttl</to>
</rule>

<!--
<rule>
<name>commented-1</name>
Expand Down
2 changes: 1 addition & 1 deletion webui/src/main/webapp/scripts/lode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,6 @@ function createTableHeader (names) {
return htmlString;
}


function renderResourceTypes(element) {
var identifier = getIdentifier(document.location.href);

Expand Down Expand Up @@ -1070,6 +1069,7 @@ function renderResourceTypes(element) {
}
}


function renderAllResourceTypes(element, exclude) {
var match = document.location.href.match(/\?(.*)/);
var queryString = match ? match[1] : '';
Expand Down
487 changes: 0 additions & 487 deletions webui/src/main/webapp/vocabulary.owl

This file was deleted.

960 changes: 0 additions & 960 deletions webui/src/main/webapp/vocabulary.ttl

This file was deleted.

65 changes: 0 additions & 65 deletions webui/src/main/webapp/void.ttl

This file was deleted.

36 changes: 18 additions & 18 deletions webui/src/test/java/gov/nih/nlm/lode/tests/BasicsTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package gov.nih.nlm.lode.tests;

import java.util.List;
import java.util.ArrayList;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.testng.annotations.Test;

import static org.testng.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;

@Test(groups = "basics")
public class BasicsTest extends LodeBaseTest {
Expand All @@ -35,17 +30,7 @@ public void testQueryPage() {

@Test
public void testExplorerPage() {
openExplorerPage(false);
titleShouldBe("MeSH RDF Explorer");
elementShouldContain(By.cssSelector(".meshrdf-heading > h1"), "Medical Subject Headings");
WebElement navi = navigationShouldBeValid();
shouldBeValidLinks(navi.findElements(By.tagName("a")));
noPageErrors();
}

@Test
public void testExplorerYearPage() {
openExplorerPage(true);
openExplorerPage();
titleShouldBe("MeSH RDF Explorer");
elementShouldContain(By.cssSelector(".meshrdf-heading > h1"), "Medical Subject Headings");
WebElement navi = navigationShouldBeValid();
Expand All @@ -61,6 +46,14 @@ public void testVocabularyTurtle() {
vocablink.shouldBeValid();
}

@Test
public void testVoidTurtle() {
LinkChecker vocablink = new LinkChecker();
vocablink.add(getLodeBaseUrl()+"/void.ttl");
vocablink.shouldMatchContentType("^text/turtle");
vocablink.shouldBeValid();
}

@Test
public void testVocabularyOwl() {
LinkChecker vocablink = new LinkChecker();
Expand All @@ -73,9 +66,16 @@ public void testVocabularyOwl() {
public void testVocabularyRedirect() {
LinkChecker vocablink = new LinkChecker();
vocablink.add(getLodeBaseUrl()+"/vocab#CheckTag");
// NOTE: link points to production, always, so don't check Content-Type
// vocablink.shouldMatchContentType("^text/turtle");
vocablink.shouldMatchContentType("^application/rdf\\+xml");
vocablink.shouldBeValid();
}

@Test
public void testVoidRedirect() {
LinkChecker voidlink = new LinkChecker();
voidlink.add(getLodeBaseUrl()+"/void#MeSHRDF");
voidlink.add(getLodeBaseUrl()+"/void");
voidlink.shouldMatchContentType("^text/turtle");
voidlink.shouldBeValid();
}
}
82 changes: 82 additions & 0 deletions webui/src/test/java/gov/nih/nlm/lode/tests/ExplorerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package gov.nih.nlm.lode.tests;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.testng.annotations.Test;

public class ExplorerTest extends LodeBaseTest {

@Test
public void testTopicalDescriptor() {
openExplorerPage("D000420");
shouldBeExplorerPage();
shouldBeAbout("Albuterol");
shouldBeResourceType("MeSH TopicalDescriptor");

/* First test - test navigation */
WebElement navi = navigationShouldBeValid();
shouldBeValidLinks(navi.findElements(By.tagName("a")));
noPageErrors();
}

@Test
public void testExplorerYearPage() {
openExplorerPage(true);
shouldBeExplorerPage();
shouldBeAbout("Ofloxacin");
shouldBeResourceType("MeSH TopicalDescriptor");

/* Test again as this is a URI with a deeper URI */
WebElement navi = navigationShouldBeValid();
shouldBeValidLinks(navi.findElements(By.tagName("a")));
noPageErrors();
}

@Test
public void testPublicationType() {
openExplorerPage("D000077825");
shouldBeExplorerPage();
shouldBeAbout("Dictionary, Pharmaceutic");
shouldBeResourceType("MeSH PublicationType");
}

@Test
public void testGeographicalDescriptor() {
openExplorerPage("D008922");
shouldBeExplorerPage();
shouldBeAbout("Mississippi");
shouldBeResourceType("MeSH GeographicalDescriptor");
}

@Test
public void testCheckTag() {
openExplorerPage("D005260");
shouldBeExplorerPage();
shouldBeAbout("Female");
shouldBeResourceType("MeSH CheckTag");
}

@Test
public void testSCRChemical() {
openExplorerPage("C000621506");
shouldBeExplorerPage();
shouldBeAbout("CXXC5 protein, zebrafish");
shouldBeResourceType("MeSH SCR Chemical");
}

@Test
public void testSCRDisease() {
openExplorerPage("C000598941");
shouldBeExplorerPage();
shouldBeAbout("Keratoactinomycosis");
shouldBeResourceType("MeSH SCR Disease");
}

@Test
public void testSCROrganism() {
openExplorerPage("C000623735");
shouldBeExplorerPage();
shouldBeAbout("Rhinovirus B");
shouldBeResourceType("MeSH SCR Organism");
}
}
13 changes: 5 additions & 8 deletions webui/src/test/java/gov/nih/nlm/lode/tests/LinkChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.message.BasicHeader;

import org.apache.commons.lang3.tuple.Pair;

import org.testng.Reporter;

import static org.testng.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;


public class LinkChecker {

Expand Down Expand Up @@ -134,6 +129,7 @@ public void addRequestHeader(String name, String value) {

public void addRequestHeader(final Header header) {
addRequestCallback(new LinkChecker.RequestCallback() {
@Override
public void withRequest(HttpRequest request) {
request.setHeader(header);
}
Expand All @@ -148,6 +144,7 @@ public void shouldMatchResponseHeader(final String name, final String valueExpr)
try {
final Pattern pattern = Pattern.compile(valueExpr);
addResponseCallback(new LinkChecker.ResponseCallback() {
@Override
public void withResponse(HttpResponse response) {
Header header = response.getFirstHeader(name);
assertNotNull(header);
Expand Down Expand Up @@ -201,9 +198,9 @@ public void shouldBeValid() {
URI lastbadlink = null;
RequestConfig.Builder config = RequestConfig.custom();
if (connectTimeout != null)
config.setConnectTimeout((int)connectTimeout * 1000);
config.setConnectTimeout(connectTimeout * 1000);
if (socketTimeout != null)
config.setSocketTimeout((int)socketTimeout * 1000);
config.setSocketTimeout(socketTimeout * 1000);
HttpClientBuilder builder = HttpClients.custom();
builder.setDefaultRequestConfig(config.build());
if (!followRedirects)
Expand Down
42 changes: 38 additions & 4 deletions webui/src/test/java/gov/nih/nlm/lode/tests/LodeBaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ public void shouldBeValidLinks(List<WebElement> links) {
linkcheck.shouldBeValid();
}

public void shouldBeExplorerPage() {
titleShouldBe("MeSH RDF Explorer");
elementShouldContain(By.cssSelector(".meshrdf-heading > h1"), "Medical Subject Headings");
}

public void shouldBeResourceType(String expectedTypeLabel) {
WebElement typeElement = findElement(By.cssSelector("#lodestar-contents_lode_explore_resourceType a.graph-link"));
assertThat(typeElement, not(nullValue()));
String actualTypeLabel = typeElement.getText().trim();
assertThat(actualTypeLabel, equalTo(expectedTypeLabel));
}

public void shouldBeAbout(String expectedAboutLabel) {
WebElement aboutElement = findElement(By.cssSelector("#lodestar-contents_lode_explore_resourceTopObject a.graph-link"));
assertThat(aboutElement, not(nullValue()));
String actualAboutLabel = aboutElement.getText().trim();
assertThat(actualAboutLabel, equalTo(expectedAboutLabel));
}

public void openHomePage() {
driver.get(getLodeBaseUrl());
}
Expand All @@ -105,10 +124,25 @@ public void openQueryPage() {
driver.get(getLodeBaseUrl() + "/query");
}

public void openExplorerPage(Boolean useprefix) {
String prefix = (useprefix ? YEAR_PREFIX : "");
String uri = getLodeBaseUrl() + prefix + OFLAXIN_RELURI;
driver.get(uri);
public void openExplorerPage(String relativeUri, boolean usePrefix) {
if (relativeUri == null || relativeUri.length() == 0) {
relativeUri = OFLAXIN_RELURI;
}
if (relativeUri.charAt(0) != '/') {
relativeUri = '/'+relativeUri;
}
String prefix = (usePrefix ? YEAR_PREFIX : "");
String uri = getLodeBaseUrl() + prefix + relativeUri;
driver.get(uri);
}
public void openExplorerPage(String relativeUri) {
openExplorerPage(relativeUri, false);
}
public void openExplorerPage(Boolean usePrefix) {
openExplorerPage(null, usePrefix);
}
public void openExplorerPage() {
openExplorerPage(null, false);
}

public void noPageErrors() {
Expand Down

0 comments on commit c06c290

Please sign in to comment.