-
Notifications
You must be signed in to change notification settings - Fork 5
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
(Re-)add support for remote repositories #77
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
96e6b88
Support remote repositories
d3jawu 2aa8726
Add DebugCql contribution test
d3jawu c615fc7
Normalize path for Windows; fix assertion not running due to unawaite…
d3jawu 0b06e2b
More tests, hopefully more coverage
d3jawu fcec590
Remove remote test
d3jawu 48fe0d1
Run spotless
d3jawu 5e8cafd
CQL Command Expression Evaluation (#78)
jreyno77 9b14fb0
Replace backslashes with forward slashes in Windows paths
d3jawu befe92c
Forgot a return path
d3jawu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
.../src/test/java/org/opencds/cqf/cql/ls/server/command/DebugCqlCommandContributionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
package org.opencds.cqf.cql.ls.server.command; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import com.google.gson.JsonParser; | ||
import java.io.File; | ||
import java.net.URI; | ||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
import org.apache.commons.lang3.SystemUtils; | ||
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.IgContextManager; | ||
import org.opencds.cqf.cql.ls.server.service.TestContentService; | ||
|
||
class DebugCqlCommandContributionTest { | ||
|
||
private static final String FILE_UNC_PREFIX = "file:///"; | ||
|
||
private static DebugCqlCommandContribution contribution; | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
ContentService cs = new TestContentService(); | ||
contribution = new DebugCqlCommandContribution(new IgContextManager((cs))); | ||
} | ||
|
||
@Test | ||
void getCommands() { | ||
assertEquals(1, contribution.getCommands().size()); | ||
assertEquals( | ||
"org.opencds.cqf.cql.ls.plugin.debug.startDebugSession", | ||
contribution.getCommands().toArray()[0]); | ||
} | ||
|
||
@Test | ||
void withOnlyLibrary() { | ||
ExecuteCommandParams params = new ExecuteCommandParams(); | ||
|
||
String libraryPath = normalizePath( | ||
"file://" + System.getProperty("user.dir") + "/src/test/resources/org/opencds/cqf/cql/ls/server/"); | ||
|
||
params.setCommand("org.opencds.cqf.cql.ls.plugin.debug.startDebugSession"); | ||
params.setArguments(Arrays.asList("cql", "-fv=R4", "-m=FHIR", "-ln=One", "-lu=" + libraryPath).stream() | ||
.map(str -> "\"" + str + "\"") | ||
.map(JsonParser::parseString) | ||
.collect(Collectors.toList())); | ||
Object result = contribution.executeCommand(params).join(); | ||
assertInstanceOf(String.class, result); | ||
assertTrue(((String) result).trim().endsWith("One=1")); | ||
} | ||
|
||
@Test | ||
void withTerminology() { | ||
ExecuteCommandParams params = new ExecuteCommandParams(); | ||
|
||
String libraryPath = normalizePath( | ||
"file://" + System.getProperty("user.dir") + "/src/test/resources/org/opencds/cqf/cql/ls/server/"); | ||
|
||
params.setCommand("org.opencds.cqf.cql.ls.plugin.debug.startDebugSession"); | ||
params.setArguments( | ||
Arrays.asList("cql", "-fv=R4", "-m=FHIR", "-ln=One", "-lu=" + libraryPath, "-t=" + libraryPath).stream() | ||
.map(str -> "\"" + str + "\"") | ||
.map(JsonParser::parseString) | ||
.collect(Collectors.toList())); | ||
Object result = contribution.executeCommand(params).join(); | ||
assertInstanceOf(String.class, result); | ||
assertTrue(((String) result).trim().endsWith("One=1")); | ||
} | ||
|
||
@Test | ||
void withFileModel() { | ||
ExecuteCommandParams params = new ExecuteCommandParams(); | ||
|
||
String modelPath = normalizePath( | ||
"file://" + System.getProperty("user.dir") + "/src/test/resources/org/opencds/cqf/cql/ls/server/"); | ||
String libraryPath = normalizePath( | ||
"file://" + System.getProperty("user.dir") + "/src/test/resources/org/opencds/cqf/cql/ls/server/"); | ||
|
||
params.setCommand("org.opencds.cqf.cql.ls.plugin.debug.startDebugSession"); | ||
params.setArguments(Arrays.asList( | ||
"cql", | ||
"-fv=R4", | ||
"-m=FHIR", | ||
"-mu=" + modelPath, | ||
"-ln=One", | ||
"-lu=" + libraryPath, | ||
"-t=" + libraryPath) | ||
.stream() | ||
.map(str -> "\"" + str + "\"") | ||
.map(JsonParser::parseString) | ||
.collect(Collectors.toList())); | ||
Object result = contribution.executeCommand(params).join(); | ||
assertInstanceOf(String.class, result); | ||
assertTrue(((String) result).trim().endsWith("One=1")); | ||
} | ||
|
||
// @Test | ||
// void withRemoteModel() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This requires us to stand up a dummy HTTP server which is a rabbit hole I'm not gonna go down now, but this test does work locally with a FHIR server running, so it still has some value. |
||
// ExecuteCommandParams params = new ExecuteCommandParams(); | ||
// | ||
// String modelPath = "http://localhost:8000"; | ||
// String libraryPath = normalizePath("file://" + System.getProperty("user.dir") + | ||
// "/src/test/resources/org/opencds/cqf/cql/ls/server/"); | ||
// | ||
// params.setCommand("org.opencds.cqf.cql.ls.plugin.debug.startDebugSession"); | ||
// params.setArguments(Arrays.asList( | ||
// "cql", | ||
// "-fv=R4", | ||
// "-m=FHIR", | ||
// "-mu=" + modelPath, | ||
// "-ln=One", | ||
// "-lu=" + libraryPath, | ||
// "-t=" + libraryPath | ||
// ).stream().map(str -> "\"" + str + "\"").map(JsonParser::parseString).collect(Collectors.toList())); | ||
// Object result = contribution.executeCommand(params).join(); | ||
// assertInstanceOf(String.class, result); | ||
// assertTrue(((String) result).trim().endsWith("One=1")); | ||
// } | ||
|
||
@Test | ||
void withRootDir() { | ||
ExecuteCommandParams params = new ExecuteCommandParams(); | ||
|
||
String libraryPath = normalizePath( | ||
"file://" + System.getProperty("user.dir") + "/src/test/resources/org/opencds/cqf/cql/ls/server/"); | ||
|
||
params.setCommand("org.opencds.cqf.cql.ls.plugin.debug.startDebugSession"); | ||
params.setArguments( | ||
Arrays.asList("cql", "-fv=R4", "-m=FHIR", "--root-dir=" + libraryPath, "-ln=One", "-lu=" + libraryPath) | ||
.stream() | ||
.map(str -> "\"" + str + "\"") | ||
.map(JsonParser::parseString) | ||
.collect(Collectors.toList())); | ||
Object result = contribution.executeCommand(params).join(); | ||
assertInstanceOf(String.class, result); | ||
assertTrue(((String) result).trim().endsWith("One=1")); | ||
} | ||
|
||
private static String normalizePath(String path) { | ||
if (SystemUtils.IS_OS_WINDOWS && path.startsWith(FILE_UNC_PREFIX)) { | ||
String wPath = path; | ||
try { | ||
URI uri = new URI(path); | ||
wPath = new File(uri.getSchemeSpecificPart()).toURI().getRawPath(); | ||
} catch (Exception e) { | ||
} | ||
|
||
return wPath.replace('\\', '/'); | ||
} | ||
|
||
return path.replace('\\', '/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though behavior around the terminology path is not affected by this change, I've made it a
String
as well for consistency.createRepository
is now responsible for turning the given URLs, if present, into the appropriate form for a repository.