-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into release-v3.0.0
- Loading branch information
Showing
14 changed files
with
303 additions
and
109 deletions.
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
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
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
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
56 changes: 56 additions & 0 deletions
56
Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryManagerTests.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,56 @@ | ||
package org.cqframework.cql.cql2elm; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertThat; | ||
import static org.hamcrest.Matchers.greaterThan; | ||
import static org.hamcrest.Matchers.lessThanOrEqualTo; | ||
|
||
import org.hl7.elm.r1.VersionedIdentifier; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
public class LibraryManagerTests { | ||
|
||
ModelManager modelManager; | ||
LibraryManager libraryManager; | ||
|
||
@BeforeClass | ||
public void setup() { | ||
modelManager = new ModelManager(); | ||
libraryManager = new LibraryManager(modelManager); | ||
libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider("LibraryManagerTests")); | ||
} | ||
|
||
@AfterClass | ||
public void tearDown() { | ||
libraryManager.getLibrarySourceLoader().clearProviders(); | ||
} | ||
|
||
|
||
@Test | ||
public void testLibraryStatementsAreSorted() { | ||
// Some optimizations depend on the Library statements being sorted in lexicographic order by name | ||
// This test validates that they are ordered | ||
var lib = libraryManager.resolveLibrary(new VersionedIdentifier().withId("OutOfOrder")).getLibrary(); | ||
|
||
assertNotNull(lib); | ||
assertNotNull(lib.getStatements().getDef()); | ||
|
||
var defs = lib.getStatements().getDef(); | ||
assertThat( | ||
"The list should be larger than 3 elements to validate it actually sorted", | ||
defs.size(), | ||
greaterThan(3)); | ||
|
||
|
||
for (int i = 0; i < defs.size() - 1; i++) { | ||
var left = defs.get(i); | ||
var right = defs.get(i +1); | ||
|
||
// Ensure that the left element is always less than or equal to the right element | ||
// In other words, they are ordered. | ||
assertThat(left.getName().compareTo(right.getName()), lessThanOrEqualTo(0)); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...-to-elm/src/test/resources/org/cqframework/cql/cql2elm/LibraryManagerTests/OutOfOrder.cql
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,25 @@ | ||
library "OutOfOrder" | ||
|
||
|
||
define "Z": | ||
1 | ||
|
||
define "B": | ||
2 | ||
|
||
define "C": | ||
3 | ||
|
||
define "A": | ||
4 | ||
|
||
define "1": | ||
5 | ||
|
||
define "z": | ||
6 | ||
|
||
define "100": | ||
7 | ||
|
||
|
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
Oops, something went wrong.