Skip to content

Commit 8691131

Browse files
committed
Improve coverage
1 parent d7fb521 commit 8691131

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

src/test/java/com/imsweb/seerapi/client/staging/StagingTest.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import java.io.IOException;
77
import java.util.EnumSet;
8+
import java.util.HashMap;
89
import java.util.List;
10+
import java.util.Map;
911
import java.util.Set;
1012

1113
import org.junit.BeforeClass;
@@ -18,15 +20,19 @@
1820
import com.imsweb.seerapi.client.staging.cs.CsStagingData;
1921
import com.imsweb.seerapi.client.staging.cs.CsStagingData.CsInput;
2022
import com.imsweb.seerapi.client.staging.cs.CsStagingData.CsStagingInputBuilder;
23+
import com.imsweb.seerapi.client.staging.eod.EodSchemaLookup;
2124
import com.imsweb.seerapi.client.staging.eod.EodStagingData;
2225
import com.imsweb.seerapi.client.staging.eod.EodStagingData.EodInput;
2326
import com.imsweb.seerapi.client.staging.eod.EodStagingData.EodOutput;
2427
import com.imsweb.seerapi.client.staging.eod.EodStagingData.EodStagingInputBuilder;
28+
import com.imsweb.seerapi.client.staging.tnm.TnmSchemaLookup;
2529
import com.imsweb.seerapi.client.staging.tnm.TnmStagingData;
2630
import com.imsweb.seerapi.client.staging.tnm.TnmStagingData.TnmInput;
2731
import com.imsweb.seerapi.client.staging.tnm.TnmStagingData.TnmOutput;
2832
import com.imsweb.seerapi.client.staging.tnm.TnmStagingData.TnmStagingInputBuilder;
2933

34+
import static com.imsweb.seerapi.client.staging.StagingData.HISTOLOGY_KEY;
35+
import static com.imsweb.seerapi.client.staging.StagingData.PRIMARY_SITE_KEY;
3036
import static com.imsweb.seerapi.client.staging.cs.CsStagingData.CsOutput.AJCC6_M;
3137
import static com.imsweb.seerapi.client.staging.cs.CsStagingData.CsOutput.AJCC6_MDESCRIPTOR;
3238
import static com.imsweb.seerapi.client.staging.cs.CsStagingData.CsOutput.AJCC6_N;
@@ -68,6 +74,7 @@
6874
import static com.imsweb.seerapi.client.staging.cs.CsStagingData.CsOutput.STOR_SS1977_STAGE;
6975
import static com.imsweb.seerapi.client.staging.cs.CsStagingData.CsOutput.STOR_SS2000_STAGE;
7076
import static org.assertj.core.api.Assertions.assertThat;
77+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
7178

7279
public class StagingTest {
7380

@@ -112,7 +119,7 @@ public void testSchemaLookup() throws IOException {
112119

113120
// now test just site
114121
SchemaLookup data = new SchemaLookup();
115-
data.setInput(StagingData.PRIMARY_SITE_KEY, "C111");
122+
data.setInput(PRIMARY_SITE_KEY, "C111");
116123
assertThat(_STAGING.schemaLookup(_ALGORITHM, _VERSION, data.getInputs()).execute().body()).hasSize(7);
117124

118125
// add histology
@@ -124,9 +131,42 @@ public void testSchemaLookup() throws IOException {
124131
schemas = _STAGING.schemaLookup(_ALGORITHM, _VERSION, data.getInputs()).execute().body();
125132
assertThat(schemas).hasSize(1).extracting("id").contains("nasopharynx");
126133

127-
// test with the CsStaging class
134+
// test with the CS
128135
schemas = _STAGING.schemaLookup(_ALGORITHM, _VERSION, new CsSchemaLookup("C111", "8000", "010").getInputs()).execute().body();
129136
assertThat(schemas).hasSize(1).extracting("id").contains("nasopharynx");
137+
138+
// test with the TNM
139+
schemas = _STAGING.schemaLookup(_ALGORITHM, _VERSION, new TnmSchemaLookup("C680", "8000").getInputs()).execute().body();
140+
assertThat(schemas).hasSize(1).extracting("id").contains("urethra");
141+
142+
// test with the EOD
143+
schemas = _STAGING.schemaLookup(_ALGORITHM, _VERSION, new EodSchemaLookup("C680", "8000").getInputs()).execute().body();
144+
assertThat(schemas).hasSize(1).extracting("id").contains("urethra");
145+
146+
Map<String, String> values = new HashMap<>();
147+
values.put(PRIMARY_SITE_KEY, "C680");
148+
values.put(HISTOLOGY_KEY, "8000");
149+
SchemaLookup schemaLookup = new SchemaLookup(values);
150+
assertThat(schemaLookup.getInput(PRIMARY_SITE_KEY)).isEqualTo("C680");
151+
assertThat(schemaLookup.getSite()).isEqualTo("C680");
152+
assertThat(schemaLookup.getHistology()).isEqualTo("8000");
153+
assertThat(schemaLookup.hasDiscriminator()).isFalse();
154+
155+
assertThat(schemaLookup).isEqualTo(new SchemaLookup("C680", "8000"));
156+
157+
// test invalid input
158+
CsSchemaLookup csLookup = new CsSchemaLookup();
159+
csLookup.setSite("C111");
160+
csLookup.setHistology("8000");
161+
csLookup.setInput(CsStagingData.SSF25_KEY, "010");
162+
assertThatExceptionOfType(IllegalStateException.class)
163+
.isThrownBy(() -> csLookup.setInput("bad_key", "1"))
164+
.withMessageContaining("is not allowed for lookups");
165+
assertThat(csLookup.hasDiscriminator()).isEqualTo(true);
166+
167+
// test clearning inpuyts
168+
schemaLookup.clearInputs();
169+
assertThat(schemaLookup.getInput(PRIMARY_SITE_KEY)).isNull();
130170
}
131171

132172
@Test

0 commit comments

Comments
 (0)