Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 2 additions & 4 deletions .github/workflows/cs-comparison.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-

# Run the comparison using the test classpath
- name: Build and run CS Comparison
- name: Build and run CS comparison
run: |
chmod +x ./mvnw
./mvnw -B test-compile -DskipTests
./mvnw -B exec:java -DskipTests -Dexec.mainClass=com.imsweb.staging.cs.CsIntegrationTest -Dexec.classpathScope=test
./mvnw -B -Pcs-comparison verify
7 changes: 7 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ jobs:
chmod +x ./mvnw
./mvnw -B verify

- name: Upload JaCoCo report
if: always()
uses: actions/upload-artifact@v4
with:
name: jacoco-report
path: target/site/jacoco/

- name: SonarCloud Analysis
if: github.actor != 'dependabot[bot]'
env:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ HELP.md
target/
!**/src/main/**/target/
!**/src/test/**/target/
node_modules/

### STS ###
.apt_generated
Expand Down Expand Up @@ -30,4 +31,5 @@ build/

### VS Code ###
.vscode/

package-lock.json
package.json
86 changes: 85 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<version>0.8.15</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand All @@ -171,6 +171,32 @@
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.95</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.89</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down Expand Up @@ -241,6 +267,64 @@
</build>

<profiles>
<profile>
<id>cs-comparison</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>add-cs-comparison-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/cs-comparison/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-cs-comparison-test-resource</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/cs-comparison/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>run-cs-comparison</id>
<phase>integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.imsweb.staging.cs.CsComparisonRunner</mainClass>
<classpathScope>test</classpathScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
*/
package com.imsweb.staging.cs;

import static com.imsweb.staging.StagingTest.getAlgorithmPath;

import com.imsweb.staging.ExternalStagingFileDataProvider;
import com.imsweb.staging.Staging;
import com.imsweb.staging.cs.IntegrationUtils.IntegrationResult;
import com.imsweb.staging.util.Stopwatch;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand All @@ -15,21 +21,12 @@
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.imsweb.staging.ExternalStagingFileDataProvider;
import com.imsweb.staging.Staging;
import com.imsweb.staging.cs.IntegrationUtils.IntegrationResult;
import com.imsweb.staging.util.Stopwatch;
public class CsComparisonRunner {

import static com.imsweb.staging.StagingTest.getAlgorithmPath;

@SuppressWarnings("java:S2187")
public class CsIntegrationTest {

private static final Logger _LOG = LoggerFactory.getLogger(CsIntegrationTest.class);
private static final Logger _LOG = LoggerFactory.getLogger(CsComparisonRunner.class);

// set this to null to process all, or a list of schema filename to process
private static final List<String> _SCHEMA_FILES = Collections.emptyList();
Expand All @@ -43,8 +40,17 @@ private static void execute() throws IOException, InterruptedException, URISynta

// only do schema selection test if running all schemas
if (_SCHEMA_FILES.isEmpty()) {
IntegrationUtils.processSchemaSelection(staging, "cs_schema_identification.txt.gz",
new GZIPInputStream(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("cs/integration/schema_selection/cs_schema_identification.txt.gz"))));
IntegrationUtils.processSchemaSelection(
staging,
"cs_schema_identification.txt.gz",
new GZIPInputStream(
Objects.requireNonNull(
Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("cs/integration/schema_selection/cs_schema_identification.txt.gz")
)
)
);

_LOG.info("-----------------------------------------------");
}
Expand All @@ -55,8 +61,18 @@ private static void execute() throws IOException, InterruptedException, URISynta
// NOTE: some of these files are REALLY large; so they are not included in the project for now; all files larger than 2MB (40 of them) are not
// part of the repository and can be found at \\omni\btp\csb\Staging\CS
List<String> schemaFiles;
try (BufferedReader buffer = new BufferedReader(
new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("cs/integration/schemas/index.txt")), StandardCharsets.UTF_8))) {
try (
BufferedReader buffer = new BufferedReader(
new InputStreamReader(
Objects.requireNonNull(
Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("cs/integration/schemas/index.txt")
),
StandardCharsets.UTF_8
)
)
) {
schemaFiles = buffer.lines().toList();
}

Expand All @@ -67,20 +83,45 @@ private static void execute() throws IOException, InterruptedException, URISynta
for (String schemaFile : schemaFiles) {
if (_SCHEMA_FILES.isEmpty() || _SCHEMA_FILES.contains(schemaFile)) {
totalFiles += 1;
IntegrationResult result = IntegrationUtils.processSchema(staging, schemaFile,
new GZIPInputStream(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("cs/integration/schemas/" + schemaFile))));
IntegrationResult result = IntegrationUtils.processSchema(
staging,
schemaFile,
new GZIPInputStream(
Objects.requireNonNull(
Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("cs/integration/schemas/" + schemaFile)
)
)
);
totalCases += result.getNumCases();
totalFailures += result.getNumFailures();
}
}

stopwatch.stop();

String perMs = String.format("%.3f", ((float)stopwatch.elapsed(TimeUnit.MILLISECONDS) / totalCases));
String perMs = String.format("%.3f", (float) stopwatch.elapsed(TimeUnit.MILLISECONDS) / totalCases);
_LOG.info("");
_LOG.info("Completed {} cases ({} files) in {} ({}ms/case).", NumberFormat.getNumberInstance(Locale.US).format(totalCases), totalFiles, stopwatch, perMs);
if (totalFailures > 0)
_LOG.error("There were {} failing cases.", NumberFormat.getNumberInstance(Locale.US).format(totalFailures));
_LOG.info(
"Completed {} cases ({} files) in {} ({}ms/case).",
NumberFormat.getNumberInstance(Locale.US).format(totalCases),
totalFiles,
stopwatch,
perMs
);
if (totalFailures > 0) _LOG.error(
"There were {} failing cases.",
NumberFormat.getNumberInstance(Locale.US).format(totalFailures)
);
failIfNecessary(totalFailures);
}

static void failIfNecessary(long totalFailures) {
if (totalFailures > 0) throw new IllegalStateException(
"CS comparison failed with " +
NumberFormat.getNumberInstance(Locale.US).format(totalFailures) +
" failing cases."
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2026 Information Management Services, Inc.
*/
package com.imsweb.staging.cs;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

class CsComparisonRunnerTest {

@Test
void testNoFailures() {
assertDoesNotThrow(() -> CsComparisonRunner.failIfNecessary(0));
}

@Test
void testFailures() {
IllegalStateException exception = assertThrows(IllegalStateException.class, () ->
CsComparisonRunner.failIfNecessary(1234)
);
assertEquals("CS comparison failed with 1,234 failing cases.", exception.getMessage());
}
}
Loading
Loading