Search in sources :

Example 21 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class CoverageDriverImpl method discoverCoveragePeriods.

@Override
public void discoverCoveragePeriods() throws CoverageDriverException, InterruptedException {
    Lock lock = coverageLockWrapper.getCoverageLock();
    boolean locked = false;
    try {
        // We run this job once a day, so we really need to grab this lock
        locked = lock.tryLock(TEN_MINUTES, TimeUnit.MINUTES);
        if (locked) {
            log.info("discovering all coverage periods that should exist");
            // Iterate through all attested contracts and look for new
            // coverage periods for each contract
            List<Contract> enabledContracts = pdpClientService.getAllEnabledContracts();
            for (Contract contract : enabledContracts) {
                discoverCoveragePeriods(mapping.map(contract));
            }
            log.info("discovered all coverage periods now exiting");
        } else {
            throw new CoverageDriverException("could not retrieve lock to discover new coverage periods");
        }
    } catch (InterruptedException interruptedException) {
        log.error("locking interrupted so stale coverage periods could not be updated");
        throw interruptedException;
    } finally {
        if (locked) {
            lock.unlock();
        }
    }
}
Also used : Contract(gov.cms.ab2d.common.model.Contract) Lock(java.util.concurrent.locks.Lock)

Example 22 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class ContractToContractCoverageMapping method init.

@PostConstruct
public static void init() {
    modelMapper = new ModelMapper();
    modelMapper.getConfiguration().setSkipNullEnabled(true);
    Converter<ContractDTO, ContractForCoverageDTO> coverageContractDTOConverter = new AbstractConverter<>() {

        @Override
        protected ContractForCoverageDTO convert(ContractDTO source) {
            // NOSONAR
            return new ContractForCoverageDTO(source.getContractNumber(), source.getAttestedOn(), ContractForCoverageDTO.ContractType.valueOf(source.getContractType().toString()));
        }
    };
    Converter<Contract, ContractForCoverageDTO> contractToConverageDto = new AbstractConverter<>() {

        @Override
        protected ContractForCoverageDTO convert(Contract source) {
            // NOSONAR
            return new ContractForCoverageDTO(source.getContractNumber(), source.getAttestedOn(), ContractForCoverageDTO.ContractType.valueOf(source.getContractType().toString()));
        }
    };
    modelMapper.addConverter(coverageContractDTOConverter);
    modelMapper.addConverter(contractToConverageDto);
}
Also used : ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) ContractForCoverageDTO(gov.cms.ab2d.coverage.model.ContractForCoverageDTO) AbstractConverter(org.modelmapper.AbstractConverter) Contract(gov.cms.ab2d.common.model.Contract) ModelMapper(org.modelmapper.ModelMapper) PostConstruct(javax.annotation.PostConstruct)

Example 23 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class HPMSManualModeTest method clearedOut.

@Test
void clearedOut() {
    Contract contract = buildContract(Contract.UpdateMode.AUTOMATIC);
    Contract savedContract = contractRepository.save(contract);
    aus.pollOrganizations();
    Optional<Contract> contractOpt = contractRepository.findContractByContractNumber(TEST_CONTRACT_NUMBER);
    assertTrue(contractOpt.isPresent());
    Contract contractResult = contractOpt.get();
    assertNull(contractResult.getAttestedOn());
    contractRepository.delete(savedContract);
}
Also used : Contract(gov.cms.ab2d.common.model.Contract) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 24 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class HPMSManualModeTest method manualLeftAlone.

@Test
void manualLeftAlone() {
    Contract contract = buildContract(Contract.UpdateMode.MANUAL);
    Contract savedContract = contractRepository.save(contract);
    aus.pollOrganizations();
    Optional<Contract> contractOpt = contractRepository.findContractByContractNumber(TEST_CONTRACT_NUMBER);
    assertTrue(contractOpt.isPresent());
    Contract contractResult = contractOpt.get();
    assertNotNull(contractResult.getAttestedOn());
    contractRepository.delete(savedContract);
}
Also used : Contract(gov.cms.ab2d.common.model.Contract) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 25 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class HPMSManualModeTest method orgChanged.

@Test
void orgChanged() {
    final var existingMock = "S1234";
    final var bogusContractName = "bogus";
    // Initial building out of the contract table
    aus.pollOrganizations();
    Optional<Contract> contractOpt = contractRepository.findContractByContractNumber(existingMock);
    assertTrue(contractOpt.isPresent());
    Contract contractResult = contractOpt.get();
    contractResult.setContractName(bogusContractName);
    contractRepository.save(contractResult);
    aus.pollOrganizations();
    contractOpt = contractRepository.findContractByContractNumber(existingMock);
    assertTrue(contractOpt.isPresent());
    contractResult = contractOpt.get();
    assertNotNull(contractResult.getHpmsParentOrg());
    assertNotEquals("bogus", contractResult.getContractName());
}
Also used : Contract(gov.cms.ab2d.common.model.Contract) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Contract (gov.cms.ab2d.common.model.Contract)36 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 Test (org.junit.jupiter.api.Test)13 PdpClient (gov.cms.ab2d.common.model.PdpClient)6 CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)6 Job (gov.cms.ab2d.common.model.Job)5 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)4 OffsetDateTime (java.time.OffsetDateTime)4 ArrayList (java.util.ArrayList)4 DisplayName (org.junit.jupiter.api.DisplayName)4 PdpClientDTO (gov.cms.ab2d.common.dto.PdpClientDTO)3 PdpClientService (gov.cms.ab2d.common.service.PdpClientService)3 PropertiesService (gov.cms.ab2d.common.service.PropertiesService)3 Constants (gov.cms.ab2d.common.util.Constants)3 ContractForCoverageDTO (gov.cms.ab2d.coverage.model.ContractForCoverageDTO)3 CoverageMapping (gov.cms.ab2d.coverage.model.CoverageMapping)3 CoverageSearch (gov.cms.ab2d.coverage.model.CoverageSearch)3 CoverageSearchRepository (gov.cms.ab2d.coverage.repository.CoverageSearchRepository)3 CoverageService (gov.cms.ab2d.coverage.service.CoverageService)3 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)3