Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for translator 3.15.0 #43

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -53,7 +60,7 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>3.1.0-M1</version>
<version>4.0.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand All @@ -62,11 +69,10 @@
<version>3.15.6.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
cmoesel marked this conversation as resolved.
Show resolved Hide resolved
<dependency>
<groupId>info.cqframework</groupId>
<artifactId>cql</artifactId>
Expand Down Expand Up @@ -194,8 +200,8 @@
</build>

<properties>
<cql.version>3.7.1</cql.version>
<jersey.version>3.0.12</jersey.version>
<cql.version>3.15.0</cql.version>
<jersey.version>3.1.8</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.mitre.bonnie.cqlTranslationServer;

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

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
Expand All @@ -14,9 +14,9 @@
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class FormatterResourceTest {

Expand All @@ -26,7 +26,7 @@ public class FormatterResourceTest {
// The CQL formatter is hard-coded to use \r\n for line breaks
private final String newLine = "\r\n";

@Before
@BeforeEach
public void setUp() throws Exception {
// start the server
server = Main.startServer();
Expand All @@ -36,13 +36,13 @@ public void setUp() throws Exception {
target = c.target(Main.BASE_URI.replace("0.0.0.0", "localhost"));
}

@After
@AfterEach
public void tearDown() throws Exception {
server.shutdownNow();
}

@Test
public void testUnformattedLibrary() {
void testUnformattedLibrary() {
String input = "library HelloWorld using QDM define Hello: 'World'";
Response resp = target.path("formatter").request(FormatterResource.CQL_TEXT_TYPE).post(Entity.entity(input, FormatterResource.CQL_TEXT_TYPE));
assertEquals(Status.OK.getStatusCode(), resp.getStatus());
Expand All @@ -62,7 +62,7 @@ public void testUnformattedLibrary() {
}

@Test
public void testInvalidCql() {
void testInvalidCql() {
String input = "lib HelloWorld using QDM define Hello: 'World'";
Response resp = target.path("formatter").request(FormatterResource.CQL_TEXT_TYPE).post(Entity.entity(input, FormatterResource.CQL_TEXT_TYPE));
assertEquals(Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
Expand All @@ -73,7 +73,7 @@ public void testInvalidCql() {
}

@Test
public void testSingleUnformattedLibraryAsMultipart() {
void testSingleUnformattedLibraryAsMultipart() {
String input = "library HelloWorld2 using QDM define Hello: 'World2'";
FormDataMultiPart pkg = new FormDataMultiPart();
pkg.field("foo", input, new MediaType("application", "cql"));
Expand All @@ -99,7 +99,7 @@ public void testSingleUnformattedLibraryAsMultipart() {
}

@Test
public void testTwoUnformattedLibrariesAsMultipart() {
void testTwoUnformattedLibrariesAsMultipart() {
String input = "library HelloWorld3 using FHIR define Hello: 'World3'";
String input2 = "library FHIRHelpers version '4.0.1' using FHIR version '4.0.1'\n" +
"context Patient define \"IsFakeFHIRHelpers\": true";
Expand Down Expand Up @@ -142,7 +142,7 @@ public void testTwoUnformattedLibrariesAsMultipart() {
}

@Test
public void testInvalidCqlInMultipart() {
void testInvalidCqlInMultipart() {
String input = "library HelloWorld3 using FHIR define Hello: 'World3'";
String input2 = "library FHIRHelpers version '4.0.1' using FHIR version '4.0.1'\n" +
"ctx Patient define \"IsFakeFHIRHelpers\": true";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.mitre.bonnie.cqlTranslationServer;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -39,9 +39,9 @@
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
Expand All @@ -51,7 +51,7 @@ public class TranslationResourceTest {
private HttpServer server;
private WebTarget target;

@Before
@BeforeEach
public void setUp() throws Exception {
// start the server
server = Main.startServer();
Expand All @@ -67,7 +67,7 @@ public void setUp() throws Exception {
target = c.target(Main.BASE_URI.replace("0.0.0.0", "localhost"));
}

@After
@AfterEach
public void tearDown() throws Exception {
server.shutdownNow();
}
Expand Down Expand Up @@ -139,7 +139,7 @@ private void validateListPromotionEnabled(String cqlTitle) {
}

@Test
public void testInvalidCqlAsXml() {
void testInvalidCqlAsXml() {
File file = new File(TranslationResourceTest.class.getResource("invalid.cql").getFile());
Response resp = target.path("translator").request(TranslationResource.ELM_XML_TYPE).post(Entity.entity(file, TranslationResource.CQL_TEXT_TYPE));
assertEquals(Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
Expand All @@ -159,7 +159,7 @@ public void testInvalidCqlAsXml() {
}

@Test
public void testInvalidCqlAsJson() {
void testInvalidCqlAsJson() {
File file = new File(TranslationResourceTest.class.getResource("invalid.cql").getFile());
Response resp = target.path("translator").request(TranslationResource.ELM_JSON_TYPE).post(Entity.entity(file, TranslationResource.CQL_TEXT_TYPE));
assertEquals(Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
Expand All @@ -178,7 +178,7 @@ public void testInvalidCqlAsJson() {
}

@Test
public void testMissingLibraryAsJson() {
void testMissingLibraryAsJson() {
File file = new File(TranslationResourceTest.class.getResource("missingLibrary.cql").getFile());
Response resp = target.path("translator").request(TranslationResource.ELM_JSON_TYPE).post(Entity.entity(file, TranslationResource.CQL_TEXT_TYPE));
assertEquals(Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
Expand All @@ -198,7 +198,7 @@ public void testMissingLibraryAsJson() {
}

@Test
public void testValidLibraryAsJson() {
void testValidLibraryAsJson() {
File file = new File(TranslationResourceTest.class.getResource("valid.cql").getFile());
Response resp = target.path("translator").request(TranslationResource.ELM_JSON_TYPE).post(Entity.entity(file, TranslationResource.CQL_TEXT_TYPE));
assertEquals(Status.OK.getStatusCode(), resp.getStatus());
Expand All @@ -224,7 +224,7 @@ public void testValidLibraryAsJson() {
}

@Test
public void testValidLibraryAsJsonWithAnnotationsAndResultTypes() {
void testValidLibraryAsJsonWithAnnotationsAndResultTypes() {
File file = new File(TranslationResourceTest.class.getResource("valid.cql").getFile());
Response resp = target.path("translator").queryParam("annotations", "true").queryParam("result-types", "true").request(TranslationResource.ELM_JSON_TYPE).post(Entity.entity(file, TranslationResource.CQL_TEXT_TYPE));
assertEquals(Status.OK.getStatusCode(), resp.getStatus());
Expand All @@ -249,27 +249,27 @@ public void testValidLibraryAsJsonWithAnnotationsAndResultTypes() {
}

@Test
public void testInvalidListPromotionExistsAsJson() {
void testInvalidListPromotionExistsAsJson() {
validateListPromotionDisabled("ListPromotionExists.cql", 8, 13, "Could not resolve call to operator Exists with signature (System.Integer).");
}

@Test
public void testInvalidListPromotionInAsJson() {
void testInvalidListPromotionInAsJson() {
validateListPromotionDisabled("ListPromotionIn.cql", 7, 16, "Could not resolve call to operator In with signature (System.Integer,System.Integer).");
}

@Test
public void testValidListPromotionInAsJson() {
void testValidListPromotionInAsJson() {
validateListPromotionEnabled("ListPromotionIn.cql");
}

@Test
public void testValidListPromotionExistsAsJson() {
void testValidListPromotionExistsAsJson() {
validateListPromotionEnabled("ListPromotionExists.cql");
}

@Test
public void testSingleLibraryAsMultipart() {
void testSingleLibraryAsMultipart() {
File file = new File(TranslationResourceTest.class.getResource("valid.cql").getFile());
FormDataMultiPart pkg = new FormDataMultiPart();
pkg.field("foo", file, new MediaType("application", "cql"));
Expand All @@ -285,7 +285,7 @@ public void testSingleLibraryAsMultipart() {
}

@Test
public void testCrossLibraryResolution() {
void testCrossLibraryResolution() {
String filenames[] = {"ProvidesDependency.cql", "HasDependency.cql"};
FormDataMultiPart pkg = new FormDataMultiPart();
for (String filename: filenames) {
Expand Down Expand Up @@ -313,7 +313,7 @@ public void testCrossLibraryResolution() {
}

@Test
public void testMultipartRequestAsXml() throws Exception {
void testMultipartRequestAsXml() throws Exception {
String filenames[] = {"valid.cql"};
FormDataMultiPart pkg = new FormDataMultiPart();
for (String filename: filenames) {
Expand All @@ -337,7 +337,7 @@ public void testMultipartRequestAsXml() throws Exception {
}

@Test
public void testMultipartRequestAsJsonAndXml() throws Exception {
void testMultipartRequestAsJsonAndXml() throws Exception {
String filenames[] = {"valid.cql"};
FormDataMultiPart pkg = new FormDataMultiPart();
for (String filename: filenames) {
Expand Down Expand Up @@ -370,7 +370,7 @@ public void testMultipartRequestAsJsonAndXml() throws Exception {
}

@Test
public void testLibraryThatNeedsUCUM() {
void testLibraryThatNeedsUCUM() {
File file = new File(TranslationResourceTest.class.getResource("NeedsUCUM.cql").getFile());
Response resp = target.path("translator").queryParam("signatures", "All").request(TranslationResource.ELM_JSON_TYPE).post(Entity.entity(file, TranslationResource.CQL_TEXT_TYPE));
assertEquals(Status.OK.getStatusCode(), resp.getStatus());
Expand Down
Loading