Skip to content

Commit

Permalink
Test coverage increase (#68)
Browse files Browse the repository at this point in the history
* 666-UpdateCQL3.x
Updated pom.xml with latest version of CQL engine, evaluator, picocli and hapi.

* 666-UpdateCQL3.x
Updated version to 2.1.1

* 666-UpdateCQL3.x
Updated version to 3.0.0

* 666-UpdateCQL3.x
Reverted to proper version

* 666-UpdateCQL3.x
Current state

* 666-UpdateCQL3.x
Working build with update
Todo: Remove evaluator JABX

* 666-UpdateCQL3.x
Updated to version 3.0.0
Need to remove Jabx

* 666-UpdateCQL3.x
Updated to version 3.0.0
Fixed startup issue with LsService! Updated cql to elm pom version
Need to remove Jabx

* 666-UpdateCQL3.x
Updated latest version of jaxb

* 666-UpdateCQL3.x
Removed unused libraries from pom.xml
Working version of cql-language-server!

* 666-UpdateCQL3.x
Cleanup

* Test Coverage Increase
Added complete test class for ViewElmCommandContribution

* Remove Java 9 profile since we're now baselined at 11

---------

Co-authored-by: Jonathan Percival <[email protected]>
  • Loading branch information
ddieppois and JPercival authored Nov 8, 2023
1 parent 47250b2 commit 2e5357d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private CompletableFuture<Object> viewElm(ExecuteCommandParams params) {
}
}

public static String convertToXml(Library library) throws IOException {
private static String convertToXml(Library library) throws IOException {
StringWriter writer = new StringWriter();
ElmLibraryWriterFactory.getWriter(LibraryContentType.XML.mimeType()).write(library, writer);
return writer.getBuffer().toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.opencds.cqf.cql.ls.server.command;

import com.google.gson.JsonParser;
import org.eclipse.lsp4j.ExecuteCommandParams;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.opencds.cqf.cql.ls.core.ContentService;
import org.opencds.cqf.cql.ls.server.manager.CompilerOptionsManager;
import org.opencds.cqf.cql.ls.server.manager.CqlCompilationManager;
import org.opencds.cqf.cql.ls.server.manager.IgContextManager;
import org.opencds.cqf.cql.ls.server.service.TestContentService;
import org.springframework.boot.test.context.SpringBootTest;

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

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

class ViewElmCommandContributionTest {

private static ViewElmCommandContribution viewElmCommandContribution;
@BeforeAll
static void beforeAll() {
ContentService cs = new TestContentService();
CqlCompilationManager cqlCompilationManager =
new CqlCompilationManager(cs, new CompilerOptionsManager(cs), new IgContextManager(cs));
viewElmCommandContribution = new ViewElmCommandContribution(cqlCompilationManager);
}

@Test
void getCommands() {
assertEquals(1, viewElmCommandContribution.getCommands().size());
assertEquals("org.opencds.cqf.cql.ls.viewElm", viewElmCommandContribution.getCommands().toArray()[0]);
}

@Test
void executeCommand() {
ExecuteCommandParams params = new ExecuteCommandParams();
params.setCommand("org.opencds.cqf.cql.ls.viewElm");
params.setArguments(Collections.singletonList(JsonParser.parseString("\"\\/org\\/opencds\\/cqf\\/cql\\/ls\\/server\\/One.cql\"")));
viewElmCommandContribution.executeCommand(params).thenAccept(result -> {
try {
String expectedXml = new String(Files.readAllBytes(Paths.get("src/test/resources/One.xml"))).trim().replaceAll("\\s+", "");
assertEquals(expectedXml, result.toString().trim().replaceAll("\\s+", ""));
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
}
25 changes: 25 additions & 0 deletions ls/server/src/test/resources/org/opencds/cqf/cql/ls/server/One.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<library xmlns="urn:hl7-org:elm:r1" xmlns:t="urn:hl7-org:elm-types:r1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fhir="http://hl7.org/fhir" xmlns:qdm43="urn:healthit-gov:qdm:v4_3" xmlns:qdm53="urn:healthit-gov:qdm:v5_3" xmlns:a="urn:hl7-org:cql-annotations:r1">
<annotation translatorVersion="3.3.2" translatorOptions="EnableAnnotations,EnableLocators,DisableListDemotion,DisableListPromotion" signatureLevel="None" xsi:type="a:CqlToElmInfo"/>
<annotation xsi:type="a:Annotation">
<a:s r="2">
<a:s>library One</a:s>
</a:s>
</annotation>
<identifier id="One"/>
<schemaIdentifier id="urn:hl7-org:elm" version="r1"/>
<usings>
<def localIdentifier="System" uri="urn:hl7-org:elm-types:r1"/>
</usings>
<statements>
<def localId="2" locator="3:1-4:5" name="One" context="Unfiltered" accessLevel="Public">
<annotation xsi:type="a:Annotation">
<a:s r="2">
<a:s r="1">define &quot;One&quot;:
1</a:s>
</a:s>
</annotation>
<expression localId="1" locator="4:5" valueType="t:Integer" value="1" xsi:type="Literal"/>
</def>
</statements>
</library>

0 comments on commit 2e5357d

Please sign in to comment.