use of gov.cms.ab2d.eventlogger.LoggableEvent in project ab2d by CMSgov.
the class BulkDataAccessAPIUnusualDataTests method testPatientExportWithNoAttestation.
@Test
void testPatientExportWithNoAttestation() throws Exception {
// Valid contract number for sponsor, but no attestation
String token = testUtil.setupContractWithNoAttestation(List.of(SPONSOR_ROLE));
Optional<Contract> contractOptional = contractRepository.findContractByContractNumber(VALID_CONTRACT_NUMBER);
Contract contract = contractOptional.get();
this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + "/Group/" + contract.getContractNumber() + "/$export").contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andExpect(status().is(403));
List<LoggableEvent> apiRequestEvents = loggerEventRepository.load(ApiRequestEvent.class);
ApiRequestEvent requestEvent = (ApiRequestEvent) apiRequestEvents.get(0);
List<LoggableEvent> apiResponseEvents = loggerEventRepository.load(ApiResponseEvent.class);
ApiResponseEvent responseEvent = (ApiResponseEvent) apiResponseEvents.get(0);
assertEquals(requestEvent.getRequestId(), responseEvent.getRequestId());
List<LoggableEvent> errorEvents = loggerEventRepository.load(ErrorEvent.class);
ErrorEvent errorEvent = (ErrorEvent) errorEvents.get(0);
assertEquals(ErrorEvent.ErrorType.UNAUTHORIZED_CONTRACT, errorEvent.getErrorType());
assertTrue(UtilMethods.allEmpty(loggerEventRepository.load(ReloadEvent.class), loggerEventRepository.load(ContractSearchEvent.class), loggerEventRepository.load(JobStatusChangeEvent.class), loggerEventRepository.load(FileEvent.class)));
}
use of gov.cms.ab2d.eventlogger.LoggableEvent in project ab2d by CMSgov.
the class AdminAPIMaintenanceModeTests method testSwitchMaintenanceModeOnAndOff.
@Test
public void testSwitchMaintenanceModeOnAndOff() throws Exception {
List<PropertiesDTO> propertiesDTOs = new ArrayList<>();
PropertiesDTO maintenanceModeDTO = new PropertiesDTO();
maintenanceModeDTO.setKey(MAINTENANCE_MODE);
maintenanceModeDTO.setValue("true");
propertiesDTOs.add(maintenanceModeDTO);
ObjectMapper mapper = new ObjectMapper();
this.mockMvc.perform(put(API_PREFIX_V1 + ADMIN_PREFIX + PROPERTIES_URL).contentType(MediaType.APPLICATION_JSON).content(mapper.writeValueAsString(propertiesDTOs)).header("Authorization", "Bearer " + token)).andExpect(status().is(200));
this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + PATIENT_EXPORT_PATH).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andExpect(status().is(HttpStatus.SERVICE_UNAVAILABLE.value()));
List<LoggableEvent> apiReqEvents = loggerEventRepository.load(ApiRequestEvent.class);
assertEquals(2, apiReqEvents.size());
List<LoggableEvent> apiResEvents = loggerEventRepository.load(ApiResponseEvent.class);
assertEquals(1, apiResEvents.size());
ApiResponseEvent responseEvent = (ApiResponseEvent) apiResEvents.get(0);
assertEquals(HttpStatus.SERVICE_UNAVAILABLE.value(), responseEvent.getResponseCode());
List<LoggableEvent> reloadEvents = loggerEventRepository.load(ReloadEvent.class);
assertEquals(1, reloadEvents.size());
ReloadEvent reloadEvent = (ReloadEvent) reloadEvents.get(0);
assertEquals(ReloadEvent.FileType.PROPERTIES, reloadEvent.getFileType());
assertTrue(UtilMethods.allEmpty(loggerEventRepository.load(ContractSearchEvent.class), loggerEventRepository.load(ErrorEvent.class), loggerEventRepository.load(FileEvent.class), loggerEventRepository.load(JobStatusChangeEvent.class)));
propertiesDTOs.clear();
maintenanceModeDTO.setValue("false");
propertiesDTOs.add(maintenanceModeDTO);
this.mockMvc.perform(put(API_PREFIX_V1 + ADMIN_PREFIX + PROPERTIES_URL).contentType(MediaType.APPLICATION_JSON).content(mapper.writeValueAsString(propertiesDTOs)).header("Authorization", "Bearer " + token)).andExpect(status().is(200));
this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + PATIENT_EXPORT_PATH).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andExpect(status().is(202));
}
use of gov.cms.ab2d.eventlogger.LoggableEvent in project ab2d by CMSgov.
the class JobProcessorIntegrationTest method processJob.
@Test
@DisplayName("When a job is in submitted status, it can be processed")
void processJob() {
var processedJob = cut.process(job.getJobUuid());
List<LoggableEvent> jobStatusChange = loggerEventRepository.load(JobStatusChangeEvent.class);
assertEquals(1, jobStatusChange.size());
JobStatusChangeEvent jobEvent = (JobStatusChangeEvent) jobStatusChange.get(0);
assertEquals(JobStatus.SUCCESSFUL.name(), jobEvent.getNewStatus());
assertEquals(JobStatus.IN_PROGRESS.name(), jobEvent.getOldStatus());
assertEquals(JobStatus.SUCCESSFUL, processedJob.getStatus());
assertEquals(COMPLETED_PERCENT, processedJob.getStatusMessage());
assertNotNull(processedJob.getExpiresAt());
assertNotNull(processedJob.getCompletedAt());
}
use of gov.cms.ab2d.eventlogger.LoggableEvent in project ab2d by CMSgov.
the class JobProcessorIntegrationTest method when_beneHasNoEobs_notCounted.
@Test
@DisplayName("When bene has no eobs then do not count bene toward statistic")
void when_beneHasNoEobs_notCounted() {
reset(mockBfdClient);
OngoingStubbing<IBaseBundle> stubbing = when(mockBfdClient.requestEOBFromServer(eq(STU3), anyLong(), any()));
stubbing = andThenAnswerEobs(stubbing, 0, 95);
stubbing.thenReturn(BundleUtils.createBundle()).thenReturn(BundleUtils.createBundle()).thenReturn(BundleUtils.createBundle()).thenReturn(BundleUtils.createBundle()).thenReturn(BundleUtils.createBundle());
var processedJob = cut.process(job.getJobUuid());
assertEquals(JobStatus.SUCCESSFUL, processedJob.getStatus());
assertEquals(COMPLETED_PERCENT, processedJob.getStatusMessage());
assertNotNull(processedJob.getExpiresAt());
assertNotNull(processedJob.getCompletedAt());
List<LoggableEvent> beneSearchEvents = loggerEventRepository.load(ContractSearchEvent.class);
assertEquals(1, beneSearchEvents.size());
ContractSearchEvent event = (ContractSearchEvent) beneSearchEvents.get(0);
assertEquals(JOB_UUID, event.getJobId());
assertEquals(100, event.getBenesExpected());
assertEquals(100, event.getBenesSearched());
assertEquals(CONTRACT_NAME, event.getContractNumber());
assertEquals(95, event.getBenesWithEobs());
final List<JobOutput> jobOutputs = processedJob.getJobOutputs();
assertFalse(jobOutputs.isEmpty());
}
use of gov.cms.ab2d.eventlogger.LoggableEvent in project ab2d by CMSgov.
the class JobPreProcessorIntegrationTest method whenJobIsInSubmittedStatus_ThenJobShouldBePutInProgress.
@Test
@DisplayName("When a job is in submitted status, it can be put into progress upon starting processing")
void whenJobIsInSubmittedStatus_ThenJobShouldBePutInProgress() throws InterruptedException {
when(coverageDriver.isCoverageAvailable(any(Job.class), any(ContractDTO.class))).thenReturn(true);
var processedJob = cut.preprocess(job.getJobUuid());
assertEquals(JobStatus.IN_PROGRESS, processedJob.getStatus());
List<LoggableEvent> jobStatusChange = loggerEventRepository.load(JobStatusChangeEvent.class);
assertEquals(1, jobStatusChange.size());
JobStatusChangeEvent event = (JobStatusChangeEvent) jobStatusChange.get(0);
assertEquals("SUBMITTED", event.getOldStatus());
assertEquals("IN_PROGRESS", event.getNewStatus());
assertTrue(UtilMethods.allEmpty(loggerEventRepository.load(ApiRequestEvent.class), loggerEventRepository.load(ApiResponseEvent.class), loggerEventRepository.load(ReloadEvent.class), loggerEventRepository.load(ContractSearchEvent.class), loggerEventRepository.load(ErrorEvent.class), loggerEventRepository.load(FileEvent.class)));
loggerEventRepository.delete();
}
Aggregations