use of gov.cms.ab2d.common.dto.PdpClientDTO in project ab2d by CMSgov.
the class AdminAPI method udpateClient.
@ResponseStatus(value = HttpStatus.OK)
@PutMapping("/client")
public ResponseEntity<PdpClientDTO> udpateClient(@RequestBody PdpClientDTO pdpClientDTO) {
PdpClientDTO client = pdpClientService.updateClient(pdpClientDTO);
log.info("client {} updated", pdpClientDTO.getOrganization());
return new ResponseEntity<>(client, null, HttpStatus.OK);
}
use of gov.cms.ab2d.common.dto.PdpClientDTO in project ab2d by CMSgov.
the class AdminAPIPdpClientTests method testCreateDuplicateClient.
@Test
public void testCreateDuplicateClient() throws Exception {
PdpClientDTO pdpClientDTO = new PdpClientDTO();
pdpClientDTO.setClientId(TEST_CLIENT);
pdpClientDTO.setEnabled(true);
pdpClientDTO.setContract(buildContractDTO());
pdpClientDTO.setRole(ADMIN_ROLE);
Role role = roleService.findRoleByName(ADMIN_ROLE);
pdpClientDTO.setRole(role.getName());
ObjectMapper mapper = getMapper();
this.mockMvc.perform(post(API_PREFIX_V1 + ADMIN_PREFIX + CLIENT_URL).contentType(MediaType.APPLICATION_JSON).content(mapper.writeValueAsString(pdpClientDTO)).header("Authorization", "Bearer " + token));
this.mockMvc.perform(post(API_PREFIX_V1 + ADMIN_PREFIX + CLIENT_URL).contentType(MediaType.APPLICATION_JSON).content(mapper.writeValueAsString(pdpClientDTO)).header("Authorization", "Bearer " + token)).andExpect(status().is(500)).andExpect(jsonPath("$.resourceType", Is.is("OperationOutcome"))).andExpect(jsonPath("$.issue[0].severity", Is.is("error"))).andExpect(jsonPath("$.issue[0].code", Is.is("invalid"))).andExpect(jsonPath("$.issue[0].details.text", Is.is("An internal error occurred")));
PdpClient anotherPdpClient = pdpClientRepository.findByClientId(("anotherEmail@test.com"));
dataSetup.queueForCleanup(anotherPdpClient);
}
use of gov.cms.ab2d.common.dto.PdpClientDTO in project ab2d by CMSgov.
the class AdminAPIPdpClientTests method testCreateClientAttestor.
@Test
public void testCreateClientAttestor() throws Exception {
PdpClientDTO pdpClientDTO = new PdpClientDTO();
pdpClientDTO.setClientId(TEST_CLIENT);
pdpClientDTO.setOrganization(TEST_ORG);
pdpClientDTO.setEnabled(true);
pdpClientDTO.setContract(buildContractDTO());
Role role = roleService.findRoleByName(ATTESTOR_ROLE);
pdpClientDTO.setRole(role.getName());
ObjectMapper mapper = getMapper();
MvcResult mvcResult = this.mockMvc.perform(post(API_PREFIX_V1 + ADMIN_PREFIX + CLIENT_URL).contentType(MediaType.APPLICATION_JSON).content(mapper.writeValueAsString(pdpClientDTO)).header("Authorization", "Bearer " + token)).andReturn();
assertEquals(201, mvcResult.getResponse().getStatus());
String result = mvcResult.getResponse().getContentAsString();
PdpClientDTO createdPdpClientDTO = mapper.readValue(result, PdpClientDTO.class);
assertEquals(createdPdpClientDTO.getClientId(), pdpClientDTO.getClientId());
assertEquals(createdPdpClientDTO.getEnabled(), pdpClientDTO.getEnabled());
assertEquals(createdPdpClientDTO.getContract().getContractNumber(), pdpClientDTO.getContract().getContractNumber());
assertEquals(createdPdpClientDTO.getContract().getContractName(), pdpClientDTO.getContract().getContractName());
assertEquals(createdPdpClientDTO.getRole(), pdpClientDTO.getRole());
}
use of gov.cms.ab2d.common.dto.PdpClientDTO in project ab2d by CMSgov.
the class CoverageDriverTest method before.
@BeforeEach
void before() {
mapping = new ContractToContractCoverageMapping();
// Set properties values in database
addPropertiesTableValues();
contract = dataSetup.setupContract("TST-12", AB2D_EPOCH.toOffsetDateTime());
contract1 = dataSetup.setupContract("TST-45", AB2D_EPOCH.toOffsetDateTime());
contractForCoverageDTO = new ContractForCoverageDTO("TST-12", AB2D_EPOCH.toOffsetDateTime(), ContractForCoverageDTO.ContractType.NORMAL);
contractForCoverageDTO1 = new ContractForCoverageDTO("TST-45", AB2D_EPOCH.toOffsetDateTime(), ContractForCoverageDTO.ContractType.NORMAL);
contractRepo.saveAndFlush(contract);
january = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), 1, 2020);
february = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), 2, 2020);
march = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), 3, 2020);
PdpClientDTO contractPdpClient = createClient(contract, "TST-12", SPONSOR_ROLE);
pdpClientService.createClient(contractPdpClient);
dataSetup.queueForCleanup(pdpClientService.getClientById("TST-12"));
PdpClient pdpClient = dataSetup.setupPdpClient(List.of());
job = new Job();
job.setContractNumber(contract.getContractNumber());
job.setJobUuid("unique");
job.setOrganization(pdpClient.getOrganization());
job.setStatus(gov.cms.ab2d.common.model.JobStatus.SUBMITTED);
job.setCreatedAt(OffsetDateTime.now());
job.setFhirVersion(STU3);
jobRepo.saveAndFlush(job);
dataSetup.queueForCleanup(job);
bfdClient = mock(BFDClient.class);
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setMaxPoolSize(6);
taskExecutor.setCorePoolSize(3);
taskExecutor.initialize();
processor = new CoverageProcessorImpl(coverageService, bfdClient, taskExecutor, MAX_ATTEMPTS, contractWorkerClient);
driver = new CoverageDriverImpl(coverageSearchRepo, pdpClientService, coverageService, propertiesService, processor, searchLock, contractToContractCoverageMapping);
}
use of gov.cms.ab2d.common.dto.PdpClientDTO in project ab2d by CMSgov.
the class CoverageDriverTest method discoverCoveragePeriods.
@DisplayName("Loading coverage periods")
@Test
void discoverCoveragePeriods() {
Contract attestedAfterEpoch = dataSetup.setupContract("TST-AFTER-EPOCH", AB2D_EPOCH.toOffsetDateTime().plusMonths(3));
contractRepo.saveAndFlush(attestedAfterEpoch);
PdpClientDTO attestedAfterClient = createClient(attestedAfterEpoch, "TST-AFTER-EPOCH", SPONSOR_ROLE);
pdpClientService.createClient(attestedAfterClient);
dataSetup.queueForCleanup(pdpClientService.getClientById("TST-AFTER-EPOCH"));
Contract attestedBeforeEpoch = dataSetup.setupContract("TST-BEFORE-EPOCH", AB2D_EPOCH.toOffsetDateTime().minusNanos(1));
contractRepo.saveAndFlush(attestedBeforeEpoch);
PdpClientDTO attestedBeforeClient = createClient(attestedBeforeEpoch, "TST-BEFORE-EPOCH", SPONSOR_ROLE);
pdpClientService.createClient(attestedBeforeClient);
dataSetup.queueForCleanup(pdpClientService.getClientById("TST-BEFORE-EPOCH"));
long months = ChronoUnit.MONTHS.between(AB2D_EPOCH.toOffsetDateTime(), OffsetDateTime.now());
long expectedNumPeriods = months + 1;
try {
driver.discoverCoveragePeriods();
} catch (CoverageDriverException | InterruptedException exception) {
fail("could not queue periods due to driver exception", exception);
}
List<CoveragePeriod> periods = coveragePeriodRepo.findAllByContractNumber(contract.getContractNumber());
assertFalse(periods.isEmpty());
assertEquals(expectedNumPeriods, periods.size());
periods = coveragePeriodRepo.findAllByContractNumber(attestedAfterEpoch.getContractNumber());
assertFalse(periods.isEmpty());
assertEquals(expectedNumPeriods - 3, periods.size());
periods = coveragePeriodRepo.findAllByContractNumber(attestedBeforeEpoch.getContractNumber());
assertFalse(periods.isEmpty());
assertEquals(expectedNumPeriods, periods.size());
}
Aggregations