Skip to content

Commit

Permalink
Refs #32:
Browse files Browse the repository at this point in the history
- removed .travis;
- fixed gradle build (jdk-17, but java8 compatible;
- updated github workflow;
- there's no need to build the server using jdk-8 or jdk-11 anymore;
- using Spring Boot 2.5.0 (later versions conflicts with old Swagger2 lib)
  • Loading branch information
IgorRodchenkov committed Oct 6, 2022
1 parent 30073d8 commit 0bc6a8f
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 105 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@ on:
jobs:
build:
runs-on: ubuntu-latest

name: Java ${{ matrix.config.java }}

# env:
# _JAVA_OPTIONS: "--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED"

name: Build with Gradle

strategy:
fail-fast: false
matrix:
config:
- {java: 8}
- {java: 11}

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.config.java }}
distribution: 'adopt'
java-version: 17
distribution: 'temurin'
cache: gradle
- name: Build with Gradle
run: |
Expand Down
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

21 changes: 10 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
springBootVersion = '2.2.6.RELEASE'
springBootVersion = '2.5.0'
}
repositories {
maven {
Expand All @@ -23,7 +23,7 @@ repositories {
url "https://oss.sonatype.org/content/groups/public/"
}
maven {
url "https://www.biopax.org/m2repo/releases/"
url "https://jitpack.io"
}
}

Expand All @@ -32,19 +32,18 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.biopax.paxtools:sbgn-converter:5.2.1-SNAPSHOT'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'org.apache.commons:commons-collections4:4.1'
implementation 'org.biopax.paxtools:sbgn-converter:5.3.0-SNAPSHOT'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'io.springfox:springfox-swagger2:2.7.0'
implementation 'io.springfox:springfox-swagger-ui:2.7.0'

//java 9+ does not have Jax B Dependents
implementation 'javax.xml.bind:jaxb-api:2.3.0'
implementation 'com.sun.xml.bind:jaxb-core:2.3.0'
implementation 'com.sun.xml.bind:jaxb-impl:2.3.0'
implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'com.sun.xml.bind:jaxb-core:2.3.0.1'
implementation 'com.sun.xml.bind:jaxb-impl:2.3.6'
implementation 'javax.activation:activation:1.1.1'
}

sourceCompatibility = 1.8
sourceCompatibility = 8
group = 'pathwaycommons'
version = '0.4.0'
version = '0.2.2'
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 2 additions & 5 deletions src/main/java/factoid/web/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ public class Controller {
produces = "application/vnd.biopax.rdf+xml"
)
public String jsonToBiopax(
@ApiParam("Factoid document content (JSON string)") @RequestBody String body
//TODO: add url/path options as needed
// , @ApiParam("test") @RequestParam(required = false) String test
) {
@ApiParam("Factoid document content (JSON string)") @RequestBody String body) {
// Add templates to converter by the reader
FactoidToBiopax converter = new FactoidToBiopax();
try {
Expand Down Expand Up @@ -107,7 +104,7 @@ public String biopaxToFactoid(
BiopaxToFactoid converter = new BiopaxToFactoid();
try {
InputStream is = new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8));
Model model = new SimpleIOHandler().convertFromOWL(is);
Model model = new SimpleIOHandler().convertFromOWL(is);
return converter.convert(model).toString();
} catch (IllegalStateException | JsonSyntaxException | JsonIOException e) {
throw new ConverterException(HttpStatus.BAD_REQUEST, e.getMessage());
Expand Down
10 changes: 4 additions & 6 deletions src/test/java/factoid/converter/BiopaxToFactoidTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package factoid.converter;


import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.*;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand All @@ -16,12 +12,14 @@
import org.biopax.paxtools.io.BioPAXIOHandler;
import org.biopax.paxtools.io.SimpleIOHandler;
import org.biopax.paxtools.model.Model;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class BiopaxToFactoidTest {

@Test
Expand Down Expand Up @@ -49,7 +47,7 @@ public void testToJson() throws IOException {
}
}

assertThat(entityIds1, is(entityIds2));
assertEquals(entityIds1, entityIds2);
}


Expand Down
2 changes: 1 addition & 1 deletion src/test/java/factoid/converter/FactoidToBiopaxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.biopax.paxtools.model.*;
import org.biopax.paxtools.model.level3.*;
import org.biopax.paxtools.model.level3.Process;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayInputStream;
import java.io.FileReader;
Expand Down
4 changes: 0 additions & 4 deletions src/test/java/factoid/converter/Simplify.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
import org.biopax.paxtools.model.level3.ProteinReference;
import org.biopax.paxtools.model.level3.SimplePhysicalEntity;
import org.biopax.paxtools.model.level3.TemplateReactionRegulation;
import org.biopax.paxtools.model.level3.Xref;

import com.google.common.io.Resources;
import com.sun.xml.bind.v2.model.core.Element;

public class Simplify {
public static void main(String[] args) throws FileNotFoundException {
Expand Down
74 changes: 26 additions & 48 deletions src/test/java/factoid/model/BioPAXModelTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package factoid.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -15,7 +15,7 @@
import org.biopax.paxtools.model.level3.Protein;
import org.biopax.paxtools.model.level3.ProteinReference;
import org.biopax.paxtools.model.level3.SmallMoleculeReference;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class BioPAXModelTest {

Expand All @@ -40,21 +40,21 @@ public void addPhysicalEntityTest() throws NoSuchFieldException, SecurityExcepti

Protein prot1 = model.getOrCreatePhysicalEntity(Protein.class, protName, protRef, modificationTypes, null);

assertTrue("Protein is added to the model", innerModel.contains(prot1));
assertEquals("Protein name is set", prot1.getDisplayName(), protName);
assertEquals("Protein reference is set", protRef, prot1.getEntityReference());
assertEquals("Protein modification types are set", modificationTypes.size(), prot1.getFeature().size());
assertEquals("Protein reference has a new modification", 1, protRef.getEntityFeature().size());
assertTrue(innerModel.contains(prot1), "Protein is added to the model");
assertEquals(prot1.getDisplayName(), protName, "Protein name is set");
assertEquals(protRef, prot1.getEntityReference(), "Protein reference is set");
assertEquals(modificationTypes.size(), prot1.getFeature().size(), "Protein modification types are set");
assertEquals(1, protRef.getEntityFeature().size(), "Protein reference has a new modification");

Protein prot2 = model.getOrCreatePhysicalEntity(Protein.class, protName, protRef, modificationTypes, null);
assertEquals("No duplication in adding the second Protein with same features", prot1, prot2);
assertEquals(prot1, prot2, "No duplication in adding the second Protein with same features");

Protein prot3 = model.getOrCreatePhysicalEntity(Protein.class, protName, protRef);
assertNotEquals("A new protein is added with no modification", prot1, prot3);
assertNotEquals(prot1, prot3, "A new protein is added with no modification");

Protein prot4 = model.getOrCreatePhysicalEntity(Protein.class, protName, protRef, modificationTypes2, null);
assertNotEquals("A new protein is added with with different modifications", prot1, prot4);
assertEquals("Protein reference has a new modification", 2, protRef.getEntityFeature().size());
assertNotEquals(prot1, prot4, "A new protein is added with with different modifications");
assertEquals(2, protRef.getEntityFeature().size(), "Protein reference has a new modification");
}

@Test
Expand All @@ -72,41 +72,19 @@ public void addEntityReferenceTest() {
XrefModel commonXref = new XrefModel("common-xref", "uniprot");

ProteinReference protRef1 = model.getOrCreateEntityReference(ProteinReference.class, commonName, commonXref);
assertTrue("Protein reference is added to the model", innerModel.contains(protRef1));
assertEquals("Protein reference name is set", commonName, protRef1.getDisplayName());
assertTrue(innerModel.contains(protRef1), "Protein reference is added to the model");
assertEquals(commonName, protRef1.getDisplayName(), "Protein reference name is set");

ProteinReference protRef2 = model.getOrCreateEntityReference(ProteinReference.class, commonName, commonXref);
assertEquals("No duplication in adding second protein modification with same name", protRef1, protRef2);
assertEquals(protRef1, protRef2, "No duplication in adding second protein modification with same name");

SmallMoleculeReference smRef = model.getOrCreateEntityReference(SmallMoleculeReference.class, commonName, commonXref);
assertNotEquals("A new small molecule reference is added that has an existing protein reference name", protRef2, smRef);
assertNotEquals(protRef2, smRef, "A new small molecule reference is added that has an existing protein reference name");

ProteinReference protRef3 = model.getOrCreateEntityReference(ProteinReference.class, uniqueName, commonXref);
assertNotEquals("A new protein is added with a new name", protRef1, protRef3);
assertNotEquals(protRef1, protRef3, "A new protein is added with a new name");
}

// @Test
// public void addCellularLocationVocabularyTest() {
//
// BioPAXModel model = new BioPAXModel();
//
// // Underlying PAXTools model
// Model innerModel = model.getPaxtoolsModel();
//
// String commonLocationName = "location1";
// String uniqueLocationName = "location2";
//
// CellularLocationVocabulary clv1 = model.getOrCreateCellularLocationVocabulary(commonLocationName);
// assertTrue("Cellular location vocabulary is added to the model", innerModel.contains(clv1));
// assertEquals("Cellular location vocabulary has the name", 1, clv1.getTerm().size());
//
// CellularLocationVocabulary clv2 = model.getOrCreateCellularLocationVocabulary(commonLocationName);
// assertEquals("No duplication in adding the second cellular location with the same name", clv1, clv2);
//
// CellularLocationVocabulary clv3 = model.getOrCreateCellularLocationVocabulary(uniqueLocationName);
// assertNotEquals("A new cellular location is added with a new name", clv1, clv3);
// }

@Test
public void addConversionTest() {

Expand All @@ -120,10 +98,10 @@ public void addConversionTest() {
Protein right = model.addNew(Protein.class);

Conversion conversion = model.addNewConversion(Conversion.class, left, right, dir);
assertTrue("Conversion is added to the model", innerModel.contains(conversion));
assertTrue("Coversions left side is set", conversion.getLeft().contains(left));
assertTrue("Coversions right side is set", conversion.getRight().contains(right));
assertEquals("Conversion direction is set", dir, conversion.getConversionDirection());
assertTrue(innerModel.contains(conversion), "Conversion is added to the model");
assertTrue(conversion.getLeft().contains(left), "Coversions left side is set");
assertTrue(conversion.getRight().contains(right), "Coversions right side is set");
assertEquals(dir, conversion.getConversionDirection(), "Conversion direction is set");
}

@Test
Expand All @@ -142,10 +120,10 @@ public void addControlTest() {

Control control = model.addNewControl(Control.class, controller, controlled, controlType);

assertTrue("Control is added to the model", innerModel.contains(control));
assertTrue("Controller is set", control.getController().contains(controller));
assertTrue("Controlled is set", control.getControlled().contains(controlled));
assertEquals("Control type is set", controlType, control.getControlType());
assertTrue(innerModel.contains(control), "Control is added to the model");
assertTrue(control.getController().contains(controller), "Controller is set");
assertTrue(control.getControlled().contains(controlled), "Controlled is set");
assertEquals(controlType, control.getControlType(), "Control type is set");
}

}
27 changes: 13 additions & 14 deletions src/test/java/factoid/web/ControllerT.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
package factoid.web;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.*;


@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@Import(Application.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ControllerT {
Expand All @@ -36,7 +34,7 @@ public void testJsonToBiopax() throws IOException {
HttpEntity<String> request = new HttpEntity<>(data, headers);
String res = template.postForObject("/v2/json-to-biopax", request, String.class);
assertNotNull(res);
assertThat(res, containsString("biopax-level3.owl#"));
assertTrue(res.contains("biopax-level3.owl#"));
}

@Test
Expand All @@ -47,7 +45,7 @@ public void testJsonToSbgn() throws IOException {
HttpEntity<String> request = new HttpEntity<>(data, headers);
String res = template.postForObject("/v2/json-to-sbgn", request, String.class);
assertNotNull(res);
assertThat(res, containsString("http://sbgn.org/libsbgn/"));
assertTrue(res.contains("http://sbgn.org/libsbgn/"));
}

@Test
Expand All @@ -58,7 +56,7 @@ public void testBiopaxToSbgn() throws IOException {
HttpEntity<String> request = new HttpEntity<>(data, headers);
String res = template.postForObject("/v2/biopax-to-sbgn", request, String.class);
assertNotNull(res);
assertThat(res, containsString("http://sbgn.org/libsbgn/"));
assertTrue(res.contains("http://sbgn.org/libsbgn/"));
}

@Test
Expand All @@ -68,8 +66,10 @@ public void testBiopaxToFactoid() throws IOException {
headers.set("Content-Type", "application/vnd.biopax.rdf+xml");
HttpEntity<String> request = new HttpEntity<>(data, headers);
String res = template.postForObject("/v2/biopax-to-json", request, String.class);
assertNotNull(res);
assertThat(res, containsString("interaction"));
assertAll(
() -> assertNotNull(res),
() -> assertTrue(res.contains("interaction"))
);
}

@Test
Expand All @@ -80,7 +80,6 @@ public void testBiopaxUrlToFactoid() throws IOException {
HttpEntity<String> request = new HttpEntity<>(url, headers);
String res = template.postForObject("/v2/biopax-url-to-json", request, String.class);
assertNotNull(res);
// this line works fine with unit tests but weirdly blocking the build so commented it out for now.
// assertThat(res, containsString("interaction"));
assertTrue(res.contains("interaction"));
}
}

0 comments on commit 0bc6a8f

Please sign in to comment.