Skip to content

Commit

Permalink
Finish test code and add CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
meier-rene committed Jan 8, 2025
1 parent f930050 commit 767455a
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 51 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: maven

- name: Build and run tests with Maven
run: mvn clean compile test
76 changes: 27 additions & 49 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,18 @@
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>2025-01-02T12:10:36+01:00</timestamp>
<mockito.version>5.15.2</mockito.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-validation</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
Expand All @@ -46,11 +41,11 @@
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.google.code.gson</groupId>-->
<!-- <artifactId>gson</artifactId>-->
<!-- <version>2.11.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.openscience.cdk</groupId>
<artifactId>cdk-bundle</artifactId>
Expand All @@ -63,11 +58,11 @@
<!-- <version>2.4.2</version>-->
<version>main-6a6cddc02c-1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.11.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.commons</groupId>-->
<!-- <artifactId>commons-configuration2</artifactId>-->
<!-- <version>2.11.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>edu.ucdavis.fiehnlab.splash</groupId>
<artifactId>core</artifactId>
Expand Down Expand Up @@ -116,6 +111,12 @@
<artifactId>protobuf-java</artifactId>
<version>4.28.2</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -161,35 +162,12 @@
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/openapi/src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/openapi/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<argLine>-javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar</argLine>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
68 changes: 66 additions & 2 deletions src/test/java/ExportServiceControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,78 @@ public void testGetVersion() throws Exception {
.andExpect(jsonPath("$").value(startsWith("export service ")));
}

String nist_msp = """
Name: Rutin
Synon: 2-(3,4-dihydroxyphenyl)-5,7-dihydroxy-3-[(2S,3R,4S,5S,6R)-3,4,5-trihydroxy-6-[[(2R,3R,4R,5R,6S)-3,4,5-trihydroxy-6-methyloxan-2-yl]oxymethyl]oxan-2-yl]oxychromen-4-one
DB#: MSBNK-IPB_Halle-PB001341
InChIKey: IKGXIBQEEMLURG-NVPNHPEKSA-N
InChI: InChI=1S/C27H30O16/c1-8-17(32)20(35)22(37)26(40-8)39-7-15-18(33)21(36)23(38)27(42-15)43-25-19(34)16-13(31)5-10(28)6-14(16)41-24(25)9-2-3-11(29)12(30)4-9/h2-6,8,15,17-18,20-23,26-33,35-38H,7H2,1H3/t8-,15+,17-,18+,20+,21-,22+,23+,26+,27-/m0/s1
SMILES: C[C@H]1[C@@H]([C@H]([C@H]([C@@H](O1)OC[C@@H]2[C@H]([C@@H]([C@H]([C@@H](O2)OC3=C(OC4=CC(=CC(=C4C3=O)O)O)C5=CC(=C(C=C5)O)O)O)O)O)O)O)O
Precursor_type: [M+H]+
Spectrum_type: MS2
Instrument_type: LC-ESI-QTOF
Instrument: API QSTAR Pulsar i
Ion_mode: POSITIVE
Collision_energy: 10 eV
Formula: C27H30O16
MW: 610
ExactMass: 610.15338
Comments: Parent=-1
Splash: splash10-0wmi-0009506000-98ca7f7c8f3072af4481
Num Peaks: 5
147.063 11
303.050 999
449.108 64
465.102 587
611.161 669
""";

@Test
public void testCreateConversionTask() throws Exception {
public void testCreateConversionTaskNistMSP() throws Exception {
String requestBody = "{ \"record_list\": [\"MSBNK-IPB_Halle-PB001341\"], \"format\": \"nist_msp\" }";

mockMvc.perform(post("/convert")
.contentType("application/json")
.content(requestBody))
.andExpect(status().isOk())
.andExpect(content().contentType("application/octet-stream"));
.andExpect(content().contentType("application/octet-stream"))
.andExpect(content().string(nist_msp));
}

String riken_msp = """
NAME : Rutin
PRECURSORMZ:\s
PRECURSORTYPE: [M+H]+
FORMULA: C27H30O16
INCHIKEY: IKGXIBQEEMLURG-NVPNHPEKSA-N
INCHI: InChI=1S/C27H30O16/c1-8-17(32)20(35)22(37)26(40-8)39-7-15-18(33)21(36)23(38)27(42-15)43-25-19(34)16-13(31)5-10(28)6-14(16)41-24(25)9-2-3-11(29)12(30)4-9/h2-6,8,15,17-18,20-23,26-33,35-38H,7H2,1H3/t8-,15+,17-,18+,20+,21-,22+,23+,26+,27-/m0/s1
SMILES: C[C@H]1[C@@H]([C@H]([C@H]([C@@H](O1)OC[C@@H]2[C@H]([C@@H]([C@H]([C@@H](O2)OC3=C(OC4=CC(=CC(=C4C3=O)O)O)C5=CC(=C(C=C5)O)O)O)O)O)O)O)O
RETENTIONTIME: 0
INSTRUMENTTYPE: LC-ESI-QTOF
INSTRUMENT: API QSTAR Pulsar i
IONMODE: Positive
LINKS: INCHIKEY:IKGXIBQEEMLURG-NVPNHPEKSA-N; KEGG:C05625; PUBCHEM:CID:5280805; COMPTOX:DTXSID3022326
Comment: DB#=MSBNK-IPB_Halle-PB001341; origin=MassBank; IPB_RECORD: 541; Annotation confident structure
Splash: splash10-0wmi-0009506000-98ca7f7c8f3072af4481
Num Peaks: 5
147.063 121.684
303.050 10000.000
449.108 657.368
465.102 5884.210
611.161 6700.000
""";

@Test
public void testCreateConversionTaskRikenMSP() throws Exception {
String requestBody = "{ \"record_list\": [\"MSBNK-IPB_Halle-PB001341\"], \"format\": \"riken_msp\" }";

mockMvc.perform(post("/convert")
.contentType("application/json")
.content(requestBody))
.andExpect(status().isOk())
.andExpect(content().contentType("application/octet-stream"))
.andExpect(content().string(riken_msp));
}
}

0 comments on commit 767455a

Please sign in to comment.