33 */
44package com .imsweb .staging .cs ;
55
6+ import static com .imsweb .staging .StagingTest .getAlgorithmPath ;
7+
8+ import com .imsweb .staging .ExternalStagingFileDataProvider ;
9+ import com .imsweb .staging .Staging ;
10+ import com .imsweb .staging .cs .IntegrationUtils .IntegrationResult ;
11+ import com .imsweb .staging .util .Stopwatch ;
612import java .io .BufferedReader ;
713import java .io .IOException ;
814import java .io .InputStreamReader ;
1521import java .util .Objects ;
1622import java .util .concurrent .TimeUnit ;
1723import java .util .zip .GZIPInputStream ;
18-
1924import org .slf4j .Logger ;
2025import org .slf4j .LoggerFactory ;
2126
22- import com .imsweb .staging .ExternalStagingFileDataProvider ;
23- import com .imsweb .staging .Staging ;
24- import com .imsweb .staging .cs .IntegrationUtils .IntegrationResult ;
25- import com .imsweb .staging .util .Stopwatch ;
27+ public class CsComparisonRunner {
2628
27- import static com .imsweb .staging .StagingTest .getAlgorithmPath ;
28-
29- @ SuppressWarnings ("java:S2187" )
30- public class CsIntegrationTest {
31-
32- private static final Logger _LOG = LoggerFactory .getLogger (CsIntegrationTest .class );
29+ private static final Logger _LOG = LoggerFactory .getLogger (CsComparisonRunner .class );
3330
3431 // set this to null to process all, or a list of schema filename to process
3532 private static final List <String > _SCHEMA_FILES = Collections .emptyList ();
@@ -43,8 +40,17 @@ private static void execute() throws IOException, InterruptedException, URISynta
4340
4441 // only do schema selection test if running all schemas
4542 if (_SCHEMA_FILES .isEmpty ()) {
46- IntegrationUtils .processSchemaSelection (staging , "cs_schema_identification.txt.gz" ,
47- new GZIPInputStream (Objects .requireNonNull (Thread .currentThread ().getContextClassLoader ().getResourceAsStream ("cs/integration/schema_selection/cs_schema_identification.txt.gz" ))));
43+ IntegrationUtils .processSchemaSelection (
44+ staging ,
45+ "cs_schema_identification.txt.gz" ,
46+ new GZIPInputStream (
47+ Objects .requireNonNull (
48+ Thread .currentThread ()
49+ .getContextClassLoader ()
50+ .getResourceAsStream ("cs/integration/schema_selection/cs_schema_identification.txt.gz" )
51+ )
52+ )
53+ );
4854
4955 _LOG .info ("-----------------------------------------------" );
5056 }
@@ -55,8 +61,18 @@ private static void execute() throws IOException, InterruptedException, URISynta
5561 // 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
5662 // part of the repository and can be found at \\omni\btp\csb\Staging\CS
5763 List <String > schemaFiles ;
58- try (BufferedReader buffer = new BufferedReader (
59- new InputStreamReader (Objects .requireNonNull (Thread .currentThread ().getContextClassLoader ().getResourceAsStream ("cs/integration/schemas/index.txt" )), StandardCharsets .UTF_8 ))) {
64+ try (
65+ BufferedReader buffer = new BufferedReader (
66+ new InputStreamReader (
67+ Objects .requireNonNull (
68+ Thread .currentThread ()
69+ .getContextClassLoader ()
70+ .getResourceAsStream ("cs/integration/schemas/index.txt" )
71+ ),
72+ StandardCharsets .UTF_8
73+ )
74+ )
75+ ) {
6076 schemaFiles = buffer .lines ().toList ();
6177 }
6278
@@ -67,26 +83,45 @@ private static void execute() throws IOException, InterruptedException, URISynta
6783 for (String schemaFile : schemaFiles ) {
6884 if (_SCHEMA_FILES .isEmpty () || _SCHEMA_FILES .contains (schemaFile )) {
6985 totalFiles += 1 ;
70- IntegrationResult result = IntegrationUtils .processSchema (staging , schemaFile ,
71- new GZIPInputStream (Objects .requireNonNull (Thread .currentThread ().getContextClassLoader ().getResourceAsStream ("cs/integration/schemas/" + schemaFile ))));
86+ IntegrationResult result = IntegrationUtils .processSchema (
87+ staging ,
88+ schemaFile ,
89+ new GZIPInputStream (
90+ Objects .requireNonNull (
91+ Thread .currentThread ()
92+ .getContextClassLoader ()
93+ .getResourceAsStream ("cs/integration/schemas/" + schemaFile )
94+ )
95+ )
96+ );
7297 totalCases += result .getNumCases ();
7398 totalFailures += result .getNumFailures ();
7499 }
75100 }
76101
77102 stopwatch .stop ();
78103
79- String perMs = String .format ("%.3f" , (( float )stopwatch .elapsed (TimeUnit .MILLISECONDS ) / totalCases ) );
104+ String perMs = String .format ("%.3f" , (float ) stopwatch .elapsed (TimeUnit .MILLISECONDS ) / totalCases );
80105 _LOG .info ("" );
81- _LOG .info ("Completed {} cases ({} files) in {} ({}ms/case)." , NumberFormat .getNumberInstance (Locale .US ).format (totalCases ), totalFiles , stopwatch , perMs );
82- if (totalFailures > 0 )
83- _LOG .error ("There were {} failing cases." , NumberFormat .getNumberInstance (Locale .US ).format (totalFailures ));
106+ _LOG .info (
107+ "Completed {} cases ({} files) in {} ({}ms/case)." ,
108+ NumberFormat .getNumberInstance (Locale .US ).format (totalCases ),
109+ totalFiles ,
110+ stopwatch ,
111+ perMs
112+ );
113+ if (totalFailures > 0 ) _LOG .error (
114+ "There were {} failing cases." ,
115+ NumberFormat .getNumberInstance (Locale .US ).format (totalFailures )
116+ );
84117 failIfNecessary (totalFailures );
85118 }
86119
87120 static void failIfNecessary (long totalFailures ) {
88- if (totalFailures > 0 )
89- throw new IllegalStateException ("CS comparison failed with " + NumberFormat .getNumberInstance (Locale .US ).format (totalFailures ) + " failing cases." );
121+ if (totalFailures > 0 ) throw new IllegalStateException (
122+ "CS comparison failed with " +
123+ NumberFormat .getNumberInstance (Locale .US ).format (totalFailures ) +
124+ " failing cases."
125+ );
90126 }
91-
92127}
0 commit comments