|
16 | 16 | import org.junit.jupiter.api.Test;
|
17 | 17 |
|
18 | 18 | import com.imsweb.seerapi.client.SeerApi;
|
| 19 | +import com.imsweb.seerapi.client.disease.Disease; |
| 20 | +import com.imsweb.seerapi.client.disease.DiseaseSearchResults; |
| 21 | +import com.imsweb.seerapi.client.disease.DiseaseService; |
19 | 22 | import com.imsweb.seerapi.client.glossary.Glossary;
|
20 | 23 | import com.imsweb.seerapi.client.glossary.GlossarySearchResults;
|
21 | 24 | import com.imsweb.seerapi.client.glossary.GlossaryService;
|
22 | 25 | import com.imsweb.seerapi.client.hcpcs.Hcpcs;
|
23 | 26 | import com.imsweb.seerapi.client.hcpcs.HcpcsService;
|
24 | 27 | import com.imsweb.seerapi.client.ndc.NdcProduct;
|
25 | 28 | import com.imsweb.seerapi.client.ndc.NdcService;
|
| 29 | +import com.imsweb.seerapi.client.rx.Rx; |
| 30 | +import com.imsweb.seerapi.client.rx.RxSearchResults; |
| 31 | +import com.imsweb.seerapi.client.rx.RxService; |
26 | 32 | import com.imsweb.seerapi.client.staging.StagingSchema;
|
27 | 33 | import com.imsweb.seerapi.client.staging.StagingSchemaInfo;
|
28 | 34 | import com.imsweb.seerapi.client.staging.StagingService;
|
@@ -251,4 +257,101 @@ void testGlossary() throws IOException {
|
251 | 257 | }
|
252 | 258 | }
|
253 | 259 |
|
| 260 | + @Test |
| 261 | + void testRx() throws IOException { |
| 262 | + RxService prodService = new SeerApi.Builder().url(PROD_URL).apiKey(getApiKey()).connect().rx(); |
| 263 | + RxService localService = new SeerApi.Builder().url(LOCAL_URL).apiKey(getApiKey()).connect().rx(); |
| 264 | + |
| 265 | + Map<String, String> params = new HashMap<>(); |
| 266 | + |
| 267 | + long offset = 0; |
| 268 | + long perPage = 100; |
| 269 | + params.put("offset", String.valueOf(offset)); |
| 270 | + params.put("count", String.valueOf(perPage)); |
| 271 | + |
| 272 | + // get a list of ids |
| 273 | + List<String> ids = new ArrayList<>(); |
| 274 | + |
| 275 | + System.out.println("Collecting identifiers for rx 'latest' version"); |
| 276 | + |
| 277 | + RxSearchResults prod = prodService.search("latest", params).execute().body(); |
| 278 | + |
| 279 | + while (Objects.requireNonNull(prod).getResults() != null && !prod.getResults().isEmpty()) { |
| 280 | + for (Rx rx : prod.getResults()) |
| 281 | + ids.add(rx.getId()); |
| 282 | + |
| 283 | + offset += perPage; |
| 284 | + params.put("offset", String.valueOf(offset)); |
| 285 | + |
| 286 | + prod = prodService.search("latest", params).execute().body(); |
| 287 | + } |
| 288 | + |
| 289 | + System.out.println("Found " + ids.size() + " identifiers for rx 'latest' version"); |
| 290 | + |
| 291 | + for (String id : ids) { |
| 292 | + System.out.println("Comparing " + id); |
| 293 | + Rx prodRx = prodService.getById("latest", id).execute().body(); |
| 294 | + Rx localRx = localService.getById("latest", id).execute().body(); |
| 295 | + |
| 296 | + assertThat(localRx) |
| 297 | + .usingRecursiveComparison() |
| 298 | + .isEqualTo(prodRx); |
| 299 | + } |
| 300 | + } |
| 301 | + |
| 302 | + @Test |
| 303 | + void testDisease() throws IOException { |
| 304 | + DiseaseService prodService = new SeerApi.Builder().url(PROD_URL).apiKey(getApiKey()).connect().disease(); |
| 305 | + DiseaseService localService = new SeerApi.Builder().url(LOCAL_URL).apiKey(getApiKey()).connect().disease(); |
| 306 | + |
| 307 | + Map<String, String> params = new HashMap<>(); |
| 308 | + |
| 309 | + long offset = 0; |
| 310 | + long perPage = 100; |
| 311 | + params.put("offset", String.valueOf(offset)); |
| 312 | + params.put("count", String.valueOf(perPage)); |
| 313 | + |
| 314 | + // get a list of ids |
| 315 | + List<String> ids = new ArrayList<>(); |
| 316 | + |
| 317 | + System.out.println("Collecting identifiers for disease 'latest' version"); |
| 318 | + |
| 319 | + DiseaseSearchResults prod = prodService.search("latest", params).execute().body(); |
| 320 | + |
| 321 | + while (Objects.requireNonNull(prod).getResults() != null && !prod.getResults().isEmpty()) { |
| 322 | + for (Disease disease : prod.getResults()) |
| 323 | + ids.add(disease.getId()); |
| 324 | + |
| 325 | + offset += perPage; |
| 326 | + params.put("offset", String.valueOf(offset)); |
| 327 | + |
| 328 | + prod = prodService.search("latest", params).execute().body(); |
| 329 | + } |
| 330 | + |
| 331 | + System.out.println("Found " + ids.size() + " identifiers for disease 'latest' version"); |
| 332 | + |
| 333 | + for (String id : ids) { |
| 334 | + System.out.println("Comparing " + id); |
| 335 | + Disease prodDisease = prodService.getById("latest", id).execute().body(); |
| 336 | + Disease localDisease = localService.getById("latest", id).execute().body(); |
| 337 | + |
| 338 | + assertThat(localDisease) |
| 339 | + .usingRecursiveComparison() |
| 340 | + .withComparatorForType( |
| 341 | + (value1, value2) -> { |
| 342 | + // Treat null and empty string as equal |
| 343 | + if (value1 == null && "".equals(value2) || "".equals(value1) && value2 == null) { |
| 344 | + return 0; // Consider them equal |
| 345 | + } |
| 346 | + if (value1 == null) |
| 347 | + return -1; |
| 348 | + if (value2 == null) |
| 349 | + return 1; |
| 350 | + return value1.compareTo(value2); |
| 351 | + }, |
| 352 | + String.class // Apply to all String fields, including in lists |
| 353 | + ) |
| 354 | + .isEqualTo(prodDisease); |
| 355 | + } |
| 356 | + } |
254 | 357 | }
|
0 commit comments