Search in sources :

Example 21 with PdpClient

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

the class DataSetup method setupNonStandardClient.

public PdpClient setupNonStandardClient(String clientdId, String contractNumber, List<String> clientRoles) {
    PdpClient testPdpClient = pdpClientRepository.findByClientId(clientdId);
    if (testPdpClient != null) {
        return testPdpClient;
    }
    Contract contract = setupContract(contractNumber);
    return savePdpClient(clientdId, contract, clientRoles);
}
Also used : PdpClient(gov.cms.ab2d.common.model.PdpClient) Contract(gov.cms.ab2d.common.model.Contract)

Example 22 with PdpClient

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

the class FileDeletionServiceTest method init.

@BeforeEach
public void init() {
    pathsToDelete = new ArrayList<>();
    PdpClient pdpClient = dataSetup.setupPdpClient(List.of());
    // Connected to a job that is finished and has expired
    job = new AuditMockJob(new StaleJob(UUID.randomUUID().toString(), pdpClient.getOrganization()), SUCCESSFUL, OffsetDateTime.now().minusDays(4));
    jobAuditClientMock.update(job);
    // Connected to a job, but in progress
    jobInProgress = new AuditMockJob(new StaleJob(UUID.randomUUID().toString(), pdpClient.getOrganization()), IN_PROGRESS, null);
    jobAuditClientMock.update(jobInProgress);
    // Connected to a job that is finished where the file has yet to expire
    jobNotExpiredYet = new AuditMockJob(new StaleJob(UUID.randomUUID().toString(), pdpClient.getOrganization()), SUCCESSFUL, OffsetDateTime.now().minusHours(55));
    jobAuditClientMock.update(jobNotExpiredYet);
    jobCancelled = new AuditMockJob(new StaleJob(UUID.randomUUID().toString(), pdpClient.getOrganization()), CANCELLED, null);
    jobAuditClientMock.update(jobCancelled);
    jobFailed = new AuditMockJob(new StaleJob(UUID.randomUUID().toString(), pdpClient.getOrganization()), FAILED, null);
    jobAuditClientMock.update(jobFailed);
    efsMount = tmpDirFolder.toPath().toString();
    ReflectionTestUtils.setField(fileDeletionService, "efsMount", efsMount);
}
Also used : AuditMockJob(gov.cms.ab2d.audit.dto.AuditMockJob) PdpClient(gov.cms.ab2d.common.model.PdpClient) StaleJob(gov.cms.ab2d.common.dto.StaleJob) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 23 with PdpClient

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

the class EndToEndBfdTests method setupClient.

private PdpClient setupClient(Contract contract) {
    PdpClient pdpClient = new PdpClient();
    pdpClient.setClientId(EndToEndBfdTests.CONTRACT_TO_USE_CLIENT_ID);
    pdpClient.setOrganization("Synthea Data");
    pdpClient.setEnabled(true);
    pdpClient.setContract(contract);
    return pdpClientRepository.save(pdpClient);
}
Also used : PdpClient(gov.cms.ab2d.common.model.PdpClient)

Example 24 with PdpClient

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

the class EndToEndBfdTests method runJobs.

/**
 *  Run a bunch of jobs with different scenarios to test the default _since capabilities. To run the jobs,
 *  we first need to do some setup:
 *
 *  1. Disable all contracts except the one we want to use
 *  2. Load all the coverage data for that contract
 *  3. Run the jobs
 *  4. Clean up files for the jobs if necessary
 */
@Test
void runJobs() throws InterruptedException {
    PdpClient pdpClient = setupClient(getContract());
    final String path = System.getProperty("java.io.tmpdir");
    // So we don't load coverage data for all the contracts we need, disable all but the one we want
    disableContractWeDontNeed();
    // Get all the coverage data for all enabled contracts
    getCoverage();
    // -------------- FIRST JOB --------------------
    Job firstJob = createJob(pdpClient);
    String firstJobId = firstJob.getJobUuid();
    OffsetDateTime firstTime = firstJob.getCreatedAt();
    firstJob = jobPreProcessor.preprocess(firstJob.getJobUuid());
    Assertions.assertEquals(SinceSource.FIRST_RUN, firstJob.getSinceSource());
    assertNull(firstJob.getSince());
    firstJob = jobProcessor.process(firstJob.getJobUuid());
    List<JobOutput> jobOutputs1 = firstJob.getJobOutputs();
    assertNotNull(jobOutputs1);
    assertEquals(JobStatus.SUCCESSFUL, firstJob.getStatus());
    assertTrue(jobOutputs1.size() > 0);
    jobOutputs1.forEach(f -> downloadFile(path, firstJobId, f.getFilePath()));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Job(gov.cms.ab2d.common.model.Job) PdpClient(gov.cms.ab2d.common.model.PdpClient) JobOutput(gov.cms.ab2d.common.model.JobOutput) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with PdpClient

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

the class JobPreProcessorIntegrationTest method createClient.

private PdpClient createClient(Contract contract) {
    PdpClient pdpClient = new PdpClient();
    pdpClient.setClientId("Harry_Potter");
    pdpClient.setOrganization("Harry_Potter");
    pdpClient.setEnabled(true);
    pdpClient.setContract(contract);
    pdpClient = pdpClientRepository.save(pdpClient);
    dataSetup.queueForCleanup(pdpClient);
    return pdpClient;
}
Also used : PdpClient(gov.cms.ab2d.common.model.PdpClient)

Aggregations

PdpClient (gov.cms.ab2d.common.model.PdpClient)43 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 BeforeEach (org.junit.jupiter.api.BeforeEach)8 Test (org.junit.jupiter.api.Test)7 Contract (gov.cms.ab2d.common.model.Contract)6 Job (gov.cms.ab2d.common.model.Job)5 ApiResponseEvent (gov.cms.ab2d.eventlogger.events.ApiResponseEvent)5 Role (gov.cms.ab2d.common.model.Role)4 PdpClientDTO (gov.cms.ab2d.common.dto.PdpClientDTO)3 LoggableEvent (gov.cms.ab2d.eventlogger.LoggableEvent)3 ApiRequestEvent (gov.cms.ab2d.eventlogger.events.ApiRequestEvent)3 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)3 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)3 TooManyRequestsException (gov.cms.ab2d.api.controller.TooManyRequestsException)2 BFDClient (gov.cms.ab2d.bfd.client.BFDClient)2 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)2 StaleJob (gov.cms.ab2d.common.dto.StaleJob)2 StartJobDTO (gov.cms.ab2d.common.dto.StartJobDTO)2 JobOutput (gov.cms.ab2d.common.model.JobOutput)2 LogManager (gov.cms.ab2d.eventlogger.LogManager)2