Skip to content

Commit eb227c7

Browse files
authored
Merge pull request #119 from imsweb/java-21
Switch to Java 21
2 parents 4dd8ea5 + 2129312 commit eb227c7

File tree

27 files changed

+187
-226
lines changed

27 files changed

+187
-226
lines changed

algorithm-cs/src/main/java/com/imsweb/staging/cs/CsSchemaLookup.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
*/
44
package com.imsweb.staging.cs;
55

6-
import java.util.Arrays;
7-
import java.util.Collections;
8-
import java.util.HashSet;
96
import java.util.Set;
107

118
import com.imsweb.staging.entities.SchemaLookup;
@@ -15,7 +12,7 @@
1512

1613
public class CsSchemaLookup extends SchemaLookup {
1714

18-
private static final Set<String> _ALLOWED_KEYS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(PRIMARY_SITE_KEY, HISTOLOGY_KEY, CsStagingData.SSF25_KEY)));
15+
private static final Set<String> _ALLOWED_KEYS = Set.of(PRIMARY_SITE_KEY, HISTOLOGY_KEY, CsStagingData.SSF25_KEY);
1916

2017
/**
2118
* Constructor

algorithm-cs/src/main/java/com/imsweb/staging/cs/CsStagingData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public enum CsOutput {
115115
STOR_SS1977_STAGE("stor_ss77"),
116116
STOR_SS2000_STAGE("stor_ss2000");
117117

118-
private String _name;
118+
private final String _name;
119119

120120
CsOutput(String name) {
121121
_name = name;
@@ -211,7 +211,7 @@ public void setSsf(Integer id, String ssf) {
211211
*/
212212
public static class CsStagingInputBuilder {
213213

214-
private CsStagingData _data;
214+
private final CsStagingData _data;
215215

216216
public CsStagingInputBuilder() {
217217
_data = new CsStagingData();

algorithm-cs/src/test/java/com/imsweb/staging/cs/CsIntegrationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.util.Locale;
1414
import java.util.Objects;
1515
import java.util.concurrent.TimeUnit;
16-
import java.util.stream.Collectors;
1716
import java.util.zip.GZIPInputStream;
1817

1918
import org.slf4j.Logger;
@@ -55,7 +54,7 @@ private static void execute() throws IOException, InterruptedException {
5554
List<String> schemaFiles;
5655
try (BufferedReader buffer = new BufferedReader(
5756
new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("cs/integration/schemas/index.txt")), StandardCharsets.UTF_8))) {
58-
schemaFiles = buffer.lines().collect(Collectors.toList());
57+
schemaFiles = buffer.lines().toList();
5958
}
6059

6160
long totalFiles = 0;

algorithm-cs/src/test/java/com/imsweb/staging/cs/CsStagingTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
public class CsStagingTest extends StagingTest {
5353

54-
private static final Logger _LOG = LoggerFactory.getLogger(StagingTest.class);
54+
private static final Logger _LOG = LoggerFactory.getLogger(CsStagingTest.class);
5555

5656
@BeforeAll
5757
public static void init() {
@@ -76,7 +76,7 @@ public StagingFileDataProvider getProvider() {
7676
@Test
7777
void testBasicInitialization() {
7878
assertEquals(153, _STAGING.getSchemaIds().size());
79-
assertTrue(_STAGING.getTableIds().size() > 0);
79+
assertFalse(_STAGING.getTableIds().isEmpty());
8080

8181
assertNotNull(_STAGING.getSchema("urethra"));
8282
assertNotNull(_STAGING.getTable("extension_bdi"));
@@ -109,12 +109,12 @@ void testSchemaSelection() {
109109
// test valid combinations that do not require a discriminator
110110
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9231", ""));
111111
assertEquals(1, lookup.size());
112-
assertEquals("testis", lookup.get(0).getId());
113-
assertEquals(Integer.valueOf(122), lookup.get(0).getSchemaNum());
112+
assertEquals("testis", lookup.getFirst().getId());
113+
assertEquals(Integer.valueOf(122), lookup.getFirst().getSchemaNum());
114114
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9231", null));
115115
assertEquals(1, lookup.size());
116-
assertEquals("testis", lookup.get(0).getId());
117-
assertEquals(Integer.valueOf(122), lookup.get(0).getSchemaNum());
116+
assertEquals("testis", lookup.getFirst().getId());
117+
assertEquals(Integer.valueOf(122), lookup.getFirst().getSchemaNum());
118118

119119
// now test one that does do AJCC7
120120
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9100", ""));
@@ -123,7 +123,7 @@ void testSchemaSelection() {
123123
// test value combinations that do not require a discriminator and are supplied 988
124124
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9231", "988"));
125125
assertEquals(1, lookup.size());
126-
assertEquals("testis", lookup.get(0).getId());
126+
assertEquals("testis", lookup.getFirst().getId());
127127

128128
// test valid combination that requires a discriminator but is not supplied one
129129
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C111", "8200"));
@@ -136,8 +136,8 @@ void testSchemaSelection() {
136136
assertEquals(1, lookup.size());
137137
for (Schema schema : lookup)
138138
assertEquals(new HashSet<>(Collections.singletonList("ssf25")), schema.getSchemaDiscriminators());
139-
assertEquals("nasopharynx", lookup.get(0).getId());
140-
assertEquals(Integer.valueOf(34), lookup.get(0).getSchemaNum());
139+
assertEquals("nasopharynx", lookup.getFirst().getId());
140+
assertEquals(Integer.valueOf(34), lookup.getFirst().getSchemaNum());
141141

142142
// test valid combination that requires a discriminator but is supplied a bad disciminator value
143143
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C111", "8200", "999"));
@@ -146,8 +146,8 @@ void testSchemaSelection() {
146146
// test specific failure case: Line #1995826 [C695,9701,100,lacrimal_gland] --> The schema selection should have found a schema, lacrimal_gland, but did not.
147147
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C695", "9701", "100"));
148148
assertEquals(1, lookup.size());
149-
assertEquals("lacrimal_gland", lookup.get(0).getId());
150-
assertEquals(Integer.valueOf(138), lookup.get(0).getSchemaNum());
149+
assertEquals("lacrimal_gland", lookup.getFirst().getId());
150+
assertEquals(Integer.valueOf(138), lookup.getFirst().getSchemaNum());
151151

152152
// test searching on only site
153153
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C401", null));
@@ -171,19 +171,19 @@ void testLookupCache() {
171171
// do the same lookup twice
172172
List<Schema> lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9231", ""));
173173
assertEquals(1, lookup.size());
174-
assertEquals("testis", lookup.get(0).getId());
174+
assertEquals("testis", lookup.getFirst().getId());
175175

176176
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9231", ""));
177177
assertEquals(1, lookup.size());
178-
assertEquals("testis", lookup.get(0).getId());
178+
assertEquals("testis", lookup.getFirst().getId());
179179

180180
// now invalidate the cache
181181
getProvider().invalidateCache();
182182

183183
// try the lookup again
184184
lookup = _STAGING.lookupSchema(new CsSchemaLookup("C629", "9231", ""));
185185
assertEquals(1, lookup.size());
186-
assertEquals("testis", lookup.get(0).getId());
186+
assertEquals("testis", lookup.getFirst().getId());
187187
}
188188

189189
@Test
@@ -369,7 +369,7 @@ void testErrors() {
369369

370370
assertEquals(Result.STAGED, data.getResult());
371371
assertEquals(4, data.getErrors().size());
372-
com.imsweb.staging.entities.Error error = data.getErrors().get(0);
372+
com.imsweb.staging.entities.Error error = data.getErrors().getFirst();
373373
assertEquals("lymph_nodes_clinical_eval_v0205_ajcc7_xch", error.getTable());
374374
assertEquals(Collections.singletonList("ajcc7_n"), error.getColumns());
375375
assertEquals("Matching resulted in an error in table 'lymph_nodes_clinical_eval_v0205_ajcc7_xch' for column 'ajcc7_n' (000)", error.getMessage());
@@ -468,7 +468,7 @@ void testStageUrethra() {
468468
assertEquals(Result.STAGED, data.getResult());
469469
assertEquals("urethra", data.getSchemaId());
470470
assertEquals(1, data.getErrors().size());
471-
assertEquals(Type.INVALID_REQUIRED_INPUT, data.getErrors().get(0).getType());
471+
assertEquals(Type.INVALID_REQUIRED_INPUT, data.getErrors().getFirst().getType());
472472

473473
// test case with missing year_dx and valid version original
474474
data.setInput(CsStagingData.CsInput.DX_YEAR, "");
@@ -642,7 +642,7 @@ void testGetInputs() {
642642
context.put(StagingData.HISTOLOGY_KEY, "8120");
643643
context.put(StagingData.YEAR_DX_KEY, "2004");
644644

645-
// for that context, neither AJCC6 or 7 should be calculated so "grade" and "ssf1" should not be list of inputs
645+
// for that context, neither AJCC6 nor 7 should be calculated so "grade" and "ssf1" should not be list of inputs
646646
assertEquals(new HashSet<>(Arrays.asList("site", "nodes_eval", "mets_eval", "ssf10", "cs_input_version_original", "ssf8", "extension", "extension_eval",
647647
"ssf3", "hist", "nodes", "year_dx", "mets")), _STAGING.getInputs(_STAGING.getSchema("prostate"), context));
648648

@@ -727,15 +727,15 @@ void testIsContextValid() {
727727
void testGetSchemaIds() {
728728
Set<String> algorithms = _STAGING.getSchemaIds();
729729

730-
assertTrue(algorithms.size() > 0);
730+
assertFalse(algorithms.isEmpty());
731731
assertTrue(algorithms.contains("testis"));
732732
}
733733

734734
@Test
735735
void testGetTableIds() {
736736
Set<String> tables = _STAGING.getTableIds();
737737

738-
assertTrue(tables.size() > 0);
738+
assertFalse(tables.isEmpty());
739739
assertTrue(tables.contains("ajcc7_stage_uaz"));
740740
}
741741

algorithm-cs/src/test/java/com/imsweb/staging/cs/IntegrationUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public static IntegrationResult processSchemaSelection(final Staging staging, St
7878
lookup.setInput(CsStagingData.SSF25_KEY, parts[2]);
7979

8080
List<Schema> lookups = staging.lookupSchema(lookup);
81-
if (parts[3].length() == 0) {
81+
if (parts[3].isEmpty()) {
8282
if (lookups.size() == 1) {
83-
_LOG.info("Line #{} [{}] --> The schema selection should not have found any schema but did: {}", lineNum, fullLine, lookups.get(0).getId());
83+
_LOG.info("Line #{} [{}] --> The schema selection should not have found any schema but did: {}", lineNum, fullLine, lookups.getFirst().getId());
8484
failedCases.getAndIncrement();
8585
}
8686
}
@@ -89,8 +89,8 @@ public static IntegrationResult processSchemaSelection(final Staging staging, St
8989
_LOG.info("Line #{} [{}] --> The schema selection should have found a schema, {}, but did not.", lineNum, fullLine, parts[3]);
9090
failedCases.getAndIncrement();
9191
}
92-
else if (!Objects.equals(lookups.get(0).getId(), parts[3])) {
93-
_LOG.info("Line #{} [{}] --> The schema selection found schema {} but it should have found {}.", lineNum, fullLine, lookups.get(0).getId(), parts[3]);
92+
else if (!Objects.equals(lookups.getFirst().getId(), parts[3])) {
93+
_LOG.info("Line #{} [{}] --> The schema selection found schema {} but it should have found {}.", lineNum, fullLine, lookups.getFirst().getId(), parts[3]);
9494
failedCases.getAndIncrement();
9595
}
9696
}
@@ -304,7 +304,7 @@ public static IntegrationResult processSchema(final Staging staging, final Strin
304304
_LOG.error(mismatch);
305305
_LOG.error(" {} *** RESULT: {}", lineNum, data.getResult());
306306
_LOG.error(" {} --> {}", lineNum, convertInputMap(data.getInput()));
307-
if (data.getErrors().size() > 0) {
307+
if (!data.getErrors().isEmpty()) {
308308
_LOG.error(" {} --> ERRORS: ", lineNum);
309309
for (com.imsweb.staging.entities.Error e : data.getErrors())
310310
_LOG.error("({}: {}) ", e.getTable(), e.getMessage());

algorithm-eod/src/test/java/com/imsweb/staging/eod/EodStagingTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ void testSchemaSelection() {
9898
schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "");
9999
lookup = _STAGING.lookupSchema(schemaLookup);
100100
assertThat(lookup).hasSize(1);
101-
assertThat(lookup.get(0).getId()).isEqualTo("soft_tissue_rare");
101+
assertThat(lookup.getFirst().getId()).isEqualTo("soft_tissue_rare");
102102
schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), null);
103103
lookup = _STAGING.lookupSchema(schemaLookup);
104104
assertThat(lookup).hasSize(1);
105-
assertThat(lookup.get(0).getId()).isEqualTo("soft_tissue_rare");
105+
assertThat(lookup.getFirst().getId()).isEqualTo("soft_tissue_rare");
106106

107107
// test valid combination that requires a discriminator but is not supplied one
108108
lookup = _STAGING.lookupSchema(new EodSchemaLookup("C111", "8200"));
@@ -123,14 +123,14 @@ void testSchemaSelection() {
123123
lookup = _STAGING.lookupSchema(schemaLookup);
124124
assertThat(lookup).hasSize(1);
125125
assertThat(lookup.stream().flatMap(d -> d.getSchemaDiscriminators().stream()).collect(Collectors.toSet())).isEqualTo(new HashSet<>(Arrays.asList("discriminator_1", "year_dx")));
126-
assertThat(lookup.get(0).getId()).isEqualTo("nasopharynx");
126+
assertThat(lookup.getFirst().getId()).isEqualTo("nasopharynx");
127127

128128
schemaLookup.setInput(EodInput.DISCRIMINATOR_1.toString(), "2");
129129
schemaLookup.setInput(EodInput.DISCRIMINATOR_2.toString(), "1");
130130
lookup = _STAGING.lookupSchema(schemaLookup);
131131
assertThat(lookup).hasSize(1);
132132
assertThat(lookup.stream().flatMap(d -> d.getSchemaDiscriminators().stream()).collect(Collectors.toSet())).isEqualTo(new HashSet<>(Arrays.asList("discriminator_1", "discriminator_2")));
133-
assertThat(lookup.get(0).getId()).isEqualTo("oropharynx_p16_neg");
133+
assertThat(lookup.getFirst().getId()).isEqualTo("oropharynx_p16_neg");
134134

135135
// test valid combination that requires a discriminator but is supplied a bad disciminator value
136136
schemaLookup = new EodSchemaLookup("C111", "8200");
@@ -167,7 +167,7 @@ void testSchemaSelection() {
167167
schemaLookup.setInput(EodInput.SEX.toString(), "1");
168168
lookup = _STAGING.lookupSchema(schemaLookup);
169169
assertThat(lookup).hasSize(1);
170-
assertThat(lookup.get(0).getId()).isEqualTo("retroperitoneum");
170+
assertThat(lookup.getFirst().getId()).isEqualTo("retroperitoneum");
171171
}
172172

173173
@Test
@@ -187,19 +187,19 @@ void testLookupCache() {
187187
// do the same lookup twice
188188
List<Schema> lookup = _STAGING.lookupSchema(new EodSchemaLookup("C629", "9231"));
189189
assertThat(lookup).hasSize(1);
190-
assertThat(lookup.get(0).getId()).isEqualTo("soft_tissue_rare");
190+
assertThat(lookup.getFirst().getId()).isEqualTo("soft_tissue_rare");
191191

192192
lookup = _STAGING.lookupSchema(new EodSchemaLookup("C629", "9231"));
193193
assertThat(lookup).hasSize(1);
194-
assertThat(lookup.get(0).getId()).isEqualTo("soft_tissue_rare");
194+
assertThat(lookup.getFirst().getId()).isEqualTo("soft_tissue_rare");
195195

196196
// now invalidate the cache
197197
EodDataProvider.getInstance(EodVersion.V3_2).invalidateCache();
198198

199199
// try the lookup again
200200
lookup = _STAGING.lookupSchema(new EodSchemaLookup("C629", "9231"));
201201
assertThat(lookup).hasSize(1);
202-
assertThat(lookup.get(0).getId()).isEqualTo("soft_tissue_rare");
202+
assertThat(lookup.getFirst().getId()).isEqualTo("soft_tissue_rare");
203203
}
204204

205205
@Test
@@ -412,7 +412,7 @@ void testLookupOutputs() {
412412
List<Schema> lookups = _STAGING.lookupSchema(lookup);
413413
assertThat(lookups).hasSize(2);
414414

415-
Schema schema = _STAGING.getSchema(lookups.get(0).getId());
415+
Schema schema = _STAGING.getSchema(lookups.getFirst().getId());
416416
assertThat(schema.getId()).isEqualTo("urethra");
417417

418418
// build list of output keys

algorithm-pediatric/src/test/java/com/imsweb/staging/pediatric/PediatricStagingTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void testSchemaSelection() {
141141
PediatricSchemaLookup schemaLookup = new PediatricSchemaLookup("C220", "8970", "10", "3");
142142
lookup = _STAGING.lookupSchema(schemaLookup);
143143
assertThat(lookup).hasSize(1);
144-
assertThat(lookup.get(0).getId()).isEqualTo("hepatoblastoma");
144+
assertThat(lookup.getFirst().getId()).isEqualTo("hepatoblastoma");
145145

146146
// test valid combination that requires a discriminator but is not supplied one
147147
lookup = _STAGING.lookupSchema(new PediatricSchemaLookup("C723", "9384"));
@@ -156,7 +156,7 @@ void testSchemaSelection() {
156156
lookup = _STAGING.lookupSchema(schemaLookup);
157157
assertThat(lookup).hasSize(1);
158158
assertThat(lookup.stream().flatMap(d -> d.getSchemaDiscriminators().stream()).collect(Collectors.toSet())).isEqualTo(new HashSet<>(Collections.singletonList("age_dx")));
159-
assertThat(lookup.get(0).getId()).isEqualTo("astrocytoma");
159+
assertThat(lookup.getFirst().getId()).isEqualTo("astrocytoma");
160160

161161
// test valid combination that requires a discriminator but is supplied a bad disciminator value
162162
schemaLookup = new PediatricSchemaLookup("C723", "9384");
@@ -194,19 +194,19 @@ void testLookupCache() {
194194
// do the same lookup twice
195195
List<Schema> lookup = _STAGING.lookupSchema(new PediatricSchemaLookup(site, hist));
196196
assertThat(lookup).hasSize(1);
197-
assertThat(lookup.get(0).getId()).isEqualTo(schemaId);
197+
assertThat(lookup.getFirst().getId()).isEqualTo(schemaId);
198198

199199
lookup = _STAGING.lookupSchema(new PediatricSchemaLookup(site, hist));
200200
assertThat(lookup).hasSize(1);
201-
assertThat(lookup.get(0).getId()).isEqualTo(schemaId);
201+
assertThat(lookup.getFirst().getId()).isEqualTo(schemaId);
202202

203203
// now invalidate the cache
204204
PediatricDataProvider.getInstance(PediatricVersion.V1_2).invalidateCache();
205205

206206
// try the lookup again
207207
lookup = _STAGING.lookupSchema(new PediatricSchemaLookup(site, hist));
208208
assertThat(lookup).hasSize(1);
209-
assertThat(lookup.get(0).getId()).isEqualTo(schemaId);
209+
assertThat(lookup.getFirst().getId()).isEqualTo(schemaId);
210210
}
211211

212212
@Test

algorithm-tnm/src/main/java/com/imsweb/staging/tnm/TnmSchemaLookup.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
*/
44
package com.imsweb.staging.tnm;
55

6-
import java.util.Arrays;
7-
import java.util.Collections;
8-
import java.util.HashSet;
96
import java.util.Set;
107

118
import com.imsweb.staging.entities.SchemaLookup;
@@ -17,7 +14,7 @@
1714

1815
public class TnmSchemaLookup extends SchemaLookup {
1916

20-
private static final Set<String> _ALLOWED_KEYS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(PRIMARY_SITE_KEY, HISTOLOGY_KEY, SSF25_KEY, SEX_KEY)));
17+
private static final Set<String> _ALLOWED_KEYS = Set.of(PRIMARY_SITE_KEY, HISTOLOGY_KEY, SSF25_KEY, SEX_KEY);
2118

2219
/**
2320
* Constructor

0 commit comments

Comments
 (0)