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();
}
}
}
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);
}
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);
}
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);
}
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());
}
Aggregations