Skip to content

Commit 836e220

Browse files
authored
Merge pull request #44 from imsweb/recode-updates
Recode updates
2 parents 07c6700 + 4d18084 commit 836e220

File tree

12 files changed

+145
-96
lines changed

12 files changed

+145
-96
lines changed

.github/workflows/integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3535
run: |
3636
chmod +x gradlew
37-
./gradlew --continue build sonarqube
37+
./gradlew --continue build sonar

build.gradle

+16-19
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ plugins {
22
id 'java-library'
33
id 'checkstyle'
44
id 'jacoco'
5-
id "com.github.spotbugs" version "5.0.14"
5+
id "com.github.spotbugs" version "6.0.25"
66
id 'maven-publish'
77
id 'signing'
88
id "io.codearte.nexus-staging" version "0.30.0"
9-
id 'com.adarshr.test-logger' version '3.2.0'
10-
id "com.github.ben-manes.versions" version "0.47.0"
11-
id 'org.sonatype.gradle.plugins.scan' version '2.6.0'
12-
id "org.sonarqube" version "4.2.1.3168"
9+
id 'com.adarshr.test-logger' version '4.0.0'
10+
id "com.github.ben-manes.versions" version "0.51.0"
11+
id 'org.sonatype.gradle.plugins.scan' version '2.8.3'
12+
id "org.sonarqube" version "5.1.0.4882"
1313
}
1414

1515
group = 'com.imsweb'
1616
version = '5.6'
1717
description = 'Java client library for SEER*API'
1818

19-
tasks.withType(JavaCompile) {
19+
tasks.withType(JavaCompile).configureEach {
2020
options.encoding = 'UTF-8'
2121
options.compilerArgs << "-Werror"
2222
}
@@ -34,22 +34,19 @@ repositories {
3434
}
3535

3636
dependencies {
37-
spotbugs 'com.github.spotbugs:spotbugs:4.7.3'
37+
spotbugs 'com.github.spotbugs:spotbugs:4.8.6'
3838

39-
api 'com.squareup.retrofit2:retrofit:2.9.0'
40-
api 'com.squareup.retrofit2:converter-jackson:2.9.0'
39+
api 'com.squareup.retrofit2:retrofit:2.11.0'
40+
api 'com.squareup.retrofit2:converter-jackson:2.11.0'
4141

4242
// retrofit will not update these dependencies to fix vulnerabilities
43-
api 'com.squareup.okhttp3:okhttp:4.11.0'
44-
api 'com.squareup.okio:okio:3.4.0'
43+
api 'com.squareup.okhttp3:okhttp:4.12.0'
44+
api 'com.squareup.okio:okio:3.9.1'
4545

46-
// newer version of dependency to fix vulnerability until converter-jackson is updated
47-
api 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
48-
49-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3'
50-
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.3'
51-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
52-
testImplementation 'org.assertj:assertj-core:3.24.2'
46+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
47+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.3'
48+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
49+
testImplementation 'org.assertj:assertj-core:3.26.3'
5350
testImplementation 'com.google.code.bean-matchers:bean-matchers:0.14'
5451
}
5552

@@ -70,7 +67,7 @@ jar {
7067
}
7168
}
7269

73-
tasks.withType(Javadoc) {
70+
tasks.withType(Javadoc).configureEach {
7471
failOnError false
7572
options.addStringOption('Xdoclint:none', '-quiet')
7673
options.addStringOption('encoding', 'UTF-8')

config/spotbugs/spotbugs-exclude.xml

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
<Bug pattern="DM_DEFAULT_ENCODING" />
3737
</Match>
3838

39+
<Match>
40+
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
41+
</Match>
42+
3943
<Match>
4044
<Class name="com.imsweb.seerutils.SeerUtils" />
4145
<Bug pattern="OS_OPEN_STREAM" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2024 Information Management Services, Inc.
3+
*/
4+
package com.imsweb.seerapi.client.siterecode;
5+
6+
import java.util.List;
7+
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
public class SiteGroupAlgorithm {
11+
12+
private String id;
13+
private String name;
14+
private String version;
15+
@JsonProperty("required_input")
16+
private List<String> requiredInput;
17+
18+
public String getId() {
19+
return id;
20+
}
21+
22+
public void setId(String id) {
23+
this.id = id;
24+
}
25+
26+
public String getName() {
27+
return name;
28+
}
29+
30+
public void setName(String name) {
31+
this.name = name;
32+
}
33+
34+
public String getVersion() {
35+
return version;
36+
}
37+
38+
public void setVersion(String version) {
39+
this.version = version;
40+
}
41+
42+
public List<String> getRequiredInput() {
43+
return requiredInput;
44+
}
45+
46+
public void setRequiredInput(List<String> requiredInput) {
47+
this.requiredInput = requiredInput;
48+
}
49+
50+
}

src/main/java/com/imsweb/seerapi/client/siterecode/SiteRecode.java

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class SiteRecode {
1111
protected String _site;
1212
@JsonProperty("hist")
1313
protected String _hist;
14+
@JsonProperty("behavior")
15+
protected String _behavior;
1416
@JsonProperty("site_group")
1517
protected String _siteGroup;
1618

@@ -30,6 +32,14 @@ public void setHist(String hist) {
3032
_hist = hist;
3133
}
3234

35+
public String getBehavior() {
36+
return _behavior;
37+
}
38+
39+
public void setBehavior(String behavior) {
40+
_behavior = behavior;
41+
}
42+
3343
public String getSiteGroup() {
3444
return _siteGroup;
3545
}

src/main/java/com/imsweb/seerapi/client/siterecode/SiteRecodeService.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,31 @@
33
*/
44
package com.imsweb.seerapi.client.siterecode;
55

6+
import java.util.List;
7+
68
import retrofit2.Call;
79
import retrofit2.http.GET;
10+
import retrofit2.http.Path;
811
import retrofit2.http.Query;
912

10-
import com.imsweb.seerapi.client.shared.Version;
11-
1213
public interface SiteRecodeService {
1314

1415
/**
15-
* Return the version of the SEER Site Recode database.
16-
* @return a String representing the database version
16+
* Return the supported algorithms and versions
17+
* @return a list of information about the algorithms
1718
*/
18-
@GET("recode/version")
19-
Call<Version> version();
19+
@GET("recode/sitegroup/algorithms")
20+
Call<List<SiteGroupAlgorithm>> algorithms();
2021

2122
/**
22-
* Return the SEER Site Group for the site/histology combination, or 99999 if the combination is unknown.
23+
* Return the specified algorithm site group for the site/histology/behavior combination, or 99999 if the combination is unknown.
24+
* @param algorithm site group algorithm
2325
* @param site Primary Site O3
2426
* @param hist Histology O3
27+
* @param behavior Behavior O3
2528
* @return a SiteRecode object based on the site and histology
2629
*/
27-
@GET("recode/sitegroup")
28-
Call<SiteRecode> siteGroup(@Query("site") String site, @Query("hist") String hist);
30+
@GET("recode/sitegroup/{algorithm}")
31+
Call<SiteRecode> siteGroup(@Path("algorithm") String algorithm, @Query("site") String site, @Query("hist") String hist, @Query("behavior") String behavior);
2932

3033
}

src/test/java/com/imsweb/seerapi/client/SeerApiTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
*/
44
package com.imsweb.seerapi.client;
55

6-
import java.io.IOException;
6+
import java.util.List;
77

88
import org.junit.jupiter.api.Test;
99

1010
import retrofit2.Call;
1111

12-
import com.imsweb.seerapi.client.shared.Version;
12+
import com.imsweb.seerapi.client.siterecode.SiteGroupAlgorithm;
1313

1414
import static org.junit.jupiter.api.Assertions.assertThrows;
1515

1616
class SeerApiTest {
1717

1818
@Test
1919
void testBadApiKeyAndURL() {
20-
Call<Version> call = new SeerApi.Builder().url("https://api.seer.cancer.gov/rest/").apiKey("BAD KEY").connect().siteRecode().version();
20+
Call<List<SiteGroupAlgorithm>> call = new SeerApi.Builder().url("https://api.seer.cancer.gov/rest/").apiKey("BAD KEY").connect().siteRecode().algorithms();
2121
assertThrows(NotAuthorizedException.class, call::execute);
2222
}
2323

2424
@Test
25-
void testBadApiKey() throws IOException {
26-
Call<Version> call = new SeerApi.Builder().apiKey("BAD KEY").connect().siteRecode().version();
25+
void testBadApiKey() {
26+
Call<List<SiteGroupAlgorithm>> call = new SeerApi.Builder().apiKey("BAD KEY").connect().siteRecode().algorithms();
2727
assertThrows(NotAuthorizedException.class, call::execute);
2828
}
2929

src/test/java/com/imsweb/seerapi/client/disease/DiseaseTest.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
1919
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
2020
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertFalse;
2122
import static org.junit.jupiter.api.Assertions.assertNotNull;
2223
import static org.junit.jupiter.api.Assertions.assertNull;
2324
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -54,7 +55,7 @@ void testDiseasePrimarySites() throws IOException {
5455
List<PrimarySite> sites = _DISEASE.primarySites().execute().body();
5556

5657
assertNotNull(sites);
57-
assertTrue(sites.size() > 0);
58+
assertFalse(sites.isEmpty());
5859
assertEquals("C000", sites.get(0).getValue());
5960
assertEquals("External upper lip", sites.get(0).getLabel());
6061
}
@@ -64,7 +65,7 @@ void testDiseasePrimarySiteCode() throws IOException {
6465
List<PrimarySite> sites = _DISEASE.primarySiteCode("C021").execute().body();
6566

6667
assertNotNull(sites);
67-
assertTrue(sites.size() > 0);
68+
assertFalse(sites.isEmpty());
6869
assertEquals("C021", sites.get(0).getValue());
6970
assertEquals("Border of tongue", sites.get(0).getLabel());
7071
}
@@ -74,7 +75,7 @@ void testDiseaseSiteCateogires() throws IOException {
7475
List<SiteCategory> categories = _DISEASE.siteCategories().execute().body();
7576

7677
assertNotNull(categories);
77-
assertTrue(categories.size() > 0);
78+
assertFalse(categories.isEmpty());
7879
assertEquals("head-and-neck", categories.get(0).getId());
7980
assertEquals("Head and Neck", categories.get(0).getLabel());
8081
assertEquals(2, categories.get(0).getSites().size());
@@ -91,7 +92,7 @@ void testDiseaseById() throws IOException {
9192
assertEquals("Pure erythroid leukemia", disease.getName());
9293
assertEquals(Disease.Type.HEMATO, disease.getType());
9394
assertEquals("9840/3", disease.getIcdO3Morphology());
94-
assertTrue(disease.getSamePrimaries().size() > 0);
95+
assertFalse(disease.getSamePrimaries().isEmpty());
9596

9697
assertNotNull(disease.getId());
9798
assertEquals("latest", disease.getVersion());
@@ -115,7 +116,7 @@ void testDiseaseById() throws IOException {
115116
assertEquals(1, disease.getAbstractorNote().size());
116117
assertEquals(2, disease.getTreatment().size());
117118
assertNull(disease.getGenetics());
118-
assertTrue(disease.getAlternateName().size() > 0);
119+
assertFalse(disease.getAlternateName().isEmpty());
119120
assertEquals("Acute erythremia", disease.getAlternateName().get(0).getValue());
120121
assertTrue(disease.getIcdO2Morphology().contains("9840/3"));
121122
assertTrue(disease.getIcdO1Morphology().contains("9840/3"));
@@ -228,7 +229,7 @@ void testDiseaseSearchIterate() throws IOException {
228229
DiseaseSearchResults results = _DISEASE.search("latest", search.paramMap()).execute().body();
229230
assertNotNull(results);
230231
assertTrue(results.getTotal() > 0);
231-
assertTrue(results.getResults().size() > 0);
232+
assertFalse(results.getResults().isEmpty());
232233

233234
// the first time through, set the total
234235
if (total == null)
@@ -276,8 +277,8 @@ void testDiseaseChangelog() throws IOException {
276277
assertEquals("Initial migration", changelog.getDescription());
277278

278279
DiseaseChangelogEntry entry = changelog.getAdds().get(0);
279-
assertTrue(entry.getId().length() > 0);
280-
assertTrue(entry.getName().length() > 0);
280+
assertFalse(entry.getId().isEmpty());
281+
assertFalse(entry.getName().isEmpty());
281282
assertNull(entry.getOldVersion());
282283
assertNull(entry.getNewVersion());
283284
}

src/test/java/com/imsweb/seerapi/client/glossary/GlossaryTest.java

+4-34
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
2323
import static com.imsweb.seerapi.client.glossary.Glossary.Category.GENERAL;
2424
import static org.junit.jupiter.api.Assertions.assertEquals;
25+
import static org.junit.jupiter.api.Assertions.assertFalse;
2526
import static org.junit.jupiter.api.Assertions.assertNotNull;
2627
import static org.junit.jupiter.api.Assertions.assertNull;
2728
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -72,37 +73,6 @@ void testGlossaryById() throws IOException {
7273
assertNull(glossary.getHistory());
7374
}
7475

75-
@Test
76-
void testGlossaryChangelog() throws IOException {
77-
GlossaryChangelogResults results = _GLOSSARY.changelogs("latest", null, null, 1).execute().body();
78-
79-
assertNotNull(results);
80-
81-
// TODO since all the glossary items were removed from the production database, this needs to be commented out; it will return when they are published again
82-
83-
/*
84-
Assert.assertEquals(1, changes.size());
85-
86-
GlossaryChangelog changelog = changes.get(0);
87-
88-
Assert.assertNotNull(changelog.getUser());
89-
Assert.assertEquals("latest_dev", changelog.getVersion());
90-
Assert.assertTrue(changelog.getId().length() > 0);
91-
Assert.assertTrue(changelog.getAdds().size() > 0);
92-
93-
GlossaryChangelogEntry entry = changelog.getAdds().get(0);
94-
Assert.assertTrue(entry.getId().length() > 0);
95-
Assert.assertTrue(entry.getName().length() > 0);
96-
Assert.assertNull(entry.getOldVersion());
97-
Assert.assertNull(entry.getNewVersion());
98-
99-
Assert.assertNull(changelog.getMods());
100-
Assert.assertNull(changelog.getDeletes());
101-
Assert.assertNotNull(changelog.getDate());
102-
Assert.assertEquals("Initial migration", changelog.getDescription());
103-
*/
104-
}
105-
10676
@Test
10777
void testGlossarySearch() throws IOException {
10878
String term = "killer";
@@ -113,7 +83,7 @@ void testGlossarySearch() throws IOException {
11383
assertNotNull(results);
11484
assertEquals(25, results.getCount().longValue());
11585
assertTrue(results.getTotal().longValue() > 0);
116-
assertTrue(results.getResults().size() > 0);
86+
assertFalse(results.getResults().isEmpty());
11787
assertEquals(Collections.singletonList(term), results.getTerms());
11888

11989
// add the category and verify there are no results
@@ -130,7 +100,7 @@ void testGlossarySearch() throws IOException {
130100
assertNotNull(results);
131101
assertEquals(25, results.getCount().longValue());
132102
assertTrue(results.getTotal().longValue() > 0);
133-
assertTrue(results.getResults().size() > 0);
103+
assertFalse(results.getResults().isEmpty());
134104
assertEquals(Collections.singletonList(term), results.getTerms());
135105
}
136106

@@ -147,7 +117,7 @@ void testGlossarySearchIterate() throws IOException {
147117
GlossarySearchResults results = _GLOSSARY.search("latest", search.paramMap(), EnumSet.of(Glossary.Category.HEMATO)).execute().body();
148118
assertNotNull(results);
149119
assertTrue(results.getTotal() > 0);
150-
assertTrue(results.getResults().size() > 0);
120+
assertFalse(results.getResults().isEmpty());
151121

152122
// the first time through, set the total
153123
if (total == null)

src/test/java/com/imsweb/seerapi/client/hcpcs/HcpcsServiceTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ void testSearch() throws IOException {
9393
assertThat(results).hasSize(2);
9494
assertThat(results).extracting("hcpcsCode").contains("J9207", "C9240");
9595

96-
// TODO the scores should be coming back from the API but are not; waiting on API fix
97-
//assertThat(Objects.requireNonNull(results).get(0).getScore()).isGreaterThan(0);
96+
assertThat(Objects.requireNonNull(results).get(0).getScore()).isPositive();
9897

9998
// test categories
10099
params.put("category", Category.CHEMOTHERAPY.toString());

0 commit comments

Comments
 (0)