Search in sources :

Example 1 with CoverageDelta

use of gov.cms.ab2d.coverage.model.CoverageDelta in project ab2d by CMSgov.

the class CoverageServiceImplTest method diffCoverageWhenFirstSearch.

@DisplayName("Get differences between first search and empty")
@Test
void diffCoverageWhenFirstSearch() {
    Set<Identifiers> results1 = Set.of(createIdentifier(1231L), createIdentifier(4561L), createIdentifier(7891L));
    coverageService.submitSearch(period1Jan.getId(), "testing");
    CoverageSearchEvent inProgress1 = startSearchAndPullEvent();
    CoverageSearchEvent savedTo1 = coverageService.insertCoverage(inProgress1.getId(), results1);
    assertEquals(inProgress1, savedTo1);
    CoverageSearchDiff searchDiff = coverageService.searchDiff(period1Jan.getId());
    List<CoverageDelta> deltas = coverageDeltaTestRepository.findAll();
    assertTrue(deltas.isEmpty());
    assertEquals(3, searchDiff.getCurrentCount());
    assertEquals(0, searchDiff.getPreviousCount());
    assertEquals(0, searchDiff.getUnchanged());
    assertEquals(0, searchDiff.getDeletions());
    assertEquals(3, searchDiff.getAdditions());
}
Also used : CoverageSearchDiff(gov.cms.ab2d.coverage.model.CoverageSearchDiff) CoverageDelta(gov.cms.ab2d.coverage.model.CoverageDelta) Identifiers(gov.cms.ab2d.coverage.model.Identifiers) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with CoverageDelta

use of gov.cms.ab2d.coverage.model.CoverageDelta in project ab2d by CMSgov.

the class CoverageServiceImplTest method diffCoverageBetweenTwoSearches.

@DisplayName("Get differences between two searches")
@Test
void diffCoverageBetweenTwoSearches() {
    Set<Identifiers> results1 = Set.of(createIdentifier(1231L), createIdentifier(4561L), createIdentifier(7891L));
    Set<Identifiers> results2 = Set.of(createIdentifier(1231L), createIdentifier(4562L), createIdentifier(7892L), createIdentifier(8900L));
    coverageService.submitSearch(period1Jan.getId(), "testing");
    CoverageSearchEvent inProgress1 = startSearchAndPullEvent();
    CoverageSearchEvent savedTo1 = coverageService.insertCoverage(inProgress1.getId(), results1);
    coverageService.completeSearch(period1Jan.getId(), "testing");
    assertEquals(inProgress1, savedTo1);
    coverageService.submitSearch(period1Jan.getId(), "testing");
    // Search must currently be in progress or exception is thrown
    assertThrows(InvalidJobStateTransition.class, () -> coverageService.searchDiff(period1Jan.getId()));
    CoverageSearchEvent inProgress2 = startSearchAndPullEvent();
    CoverageSearchEvent savedTo2 = coverageService.insertCoverage(inProgress2.getId(), results2);
    assertEquals(inProgress2, savedTo2);
    CoverageSearchDiff searchDiff = coverageService.searchDiff(period1Jan.getId());
    List<CoverageDelta> deltas = coverageDeltaTestRepository.findAll();
    assertFalse(deltas.isEmpty());
    Map<String, Long> deltaTypeCount = deltas.stream().collect(Collectors.groupingBy(CoverageDelta::getType, Collectors.counting()));
    assertEquals(4, searchDiff.getCurrentCount());
    assertEquals(3, searchDiff.getPreviousCount());
    assertEquals(1, searchDiff.getUnchanged());
    assertEquals(2, searchDiff.getDeletions());
    assertEquals(2, deltaTypeCount.get(COVERAGE_DELETED));
    assertEquals(3, searchDiff.getAdditions());
    assertEquals(3, deltaTypeCount.get(COVERAGE_ADDED));
}
Also used : CoverageSearchDiff(gov.cms.ab2d.coverage.model.CoverageSearchDiff) CoverageDelta(gov.cms.ab2d.coverage.model.CoverageDelta) Identifiers(gov.cms.ab2d.coverage.model.Identifiers) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CoverageDelta (gov.cms.ab2d.coverage.model.CoverageDelta)2 CoverageSearchDiff (gov.cms.ab2d.coverage.model.CoverageSearchDiff)2 CoverageSearchEvent (gov.cms.ab2d.coverage.model.CoverageSearchEvent)2 Identifiers (gov.cms.ab2d.coverage.model.Identifiers)2 DisplayName (org.junit.jupiter.api.DisplayName)2 Test (org.junit.jupiter.api.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2