forked from cqframework/clinical_quality_language
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Debug logging for expressions (cqframework#1341)
* Initial logging fix * Add an initial test for DebugMap * push some gated logic down
- Loading branch information
Showing
4 changed files
with
62 additions
and
8 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
38 changes: 38 additions & 0 deletions
38
Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTest.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,38 @@ | ||
package org.opencds.cqf.cql.engine.execution; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.opencds.cqf.cql.engine.debug.DebugMap; | ||
import org.testng.annotations.Test; | ||
|
||
class CqlEngineTest extends CqlTestBase { | ||
|
||
@Test | ||
void testDebugMap() { | ||
|
||
// The specific library isn't important, just that it has a debug map | ||
var debugMap = new DebugMap(); | ||
debugMap.setIsLoggingEnabled(true); | ||
var results = engine.evaluate(toElmIdentifier("CqlEngineTest"), null, null, null, debugMap); | ||
|
||
var libraryDebug = results.getDebugResult() | ||
.getLibraryResults() | ||
.get("CqlEngineTest") | ||
.getResults(); | ||
|
||
assertNotNull(libraryDebug); | ||
|
||
// Find the debug result for the AnInteger expression | ||
// It's indexed by location | ||
var result = libraryDebug.keySet().stream() | ||
.filter(e -> e.getLocator().equals("6:1-6:21")) | ||
.findFirst(); | ||
|
||
assertTrue(result.isPresent()); | ||
|
||
var debugResult = libraryDebug.get(result.get()); | ||
assertEquals(1, debugResult.size()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlEngineTest.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,7 @@ | ||
library CqlEngineTest | ||
|
||
// This is mostly a dummy library to doing some testing on top-level CQL engine Java APIS. | ||
// It's not meant to test innner execution of the engine | ||
define "AnInteger": 1 | ||