Search in sources :

Example 1 with TEST_USER_ID

use of org.sagebionetworks.bridge.TestConstants.TEST_USER_ID in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method placeOrderForHealthCode.

@Test
public void placeOrderForHealthCode() {
    when(mockRequest.getHeader(AUTHORIZATION)).thenReturn(AUTHORIZATION_HEADER_VALUE);
    when(mockAccountService.authenticate(any(), any())).thenReturn(account);
    setupShippingAddress();
    ArgumentCaptor<AccountId> accountIdCaptor = ArgumentCaptor.forClass(AccountId.class);
    when(mockAccountService.getAccount(accountIdCaptor.capture())).thenReturn(Optional.of(account));
    DateRangeResourceList<? extends ReportData> results = new DateRangeResourceList<>(ImmutableList.of());
    doReturn(results).when(mockReportService).getParticipantReport(APP_ID, TEST_USER_ID, SHIPMENT_REPORT, HEALTH_CODE, JAN1, JAN2);
    controller.postLabShipmentRequest("healthcode:" + HEALTH_CODE);
    verify(mockAccountService).authenticate(any(), any());
    verify(mockAccountService, atLeastOnce()).getAccount(accountIdCaptor.capture());
    assertTrue(accountIdCaptor.getAllValues().stream().anyMatch(accountId -> accountId.getHealthCode().equals(HEALTH_CODE)));
    verify(mockReportService).saveParticipantReport(eq(APP_ID), eq(TEST_USER_ID), eq(SHIPMENT_REPORT), eq(HEALTH_CODE), reportCaptor.capture());
    verify(controller).internalLabShipmentRequest(any(), any());
    ReportData capturedReport = reportCaptor.getValue();
    String orderId = capturedReport.getData().get(SHIPMENT_REPORT_KEY_ORDER_ID).asText();
    assertTrue(orderId.startsWith(ACCOUNT_ID.getId()));
}
Also used : ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) ENTEREDINERROR(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ENTEREDINERROR) CANCELLED(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.CANCELLED) SYN_USERNAME(org.sagebionetworks.bridge.spring.controllers.CRCController.SYN_USERNAME) Identifier(org.hl7.fhir.dstu3.model.Identifier) APPOINTMENT_REPORT(org.sagebionetworks.bridge.spring.controllers.CRCController.APPOINTMENT_REPORT) Test(org.testng.annotations.Test) RequestContext(org.sagebionetworks.bridge.RequestContext) AfterMethod(org.testng.annotations.AfterMethod) StatusLine(org.apache.http.StatusLine) EMAIL(org.sagebionetworks.bridge.TestConstants.EMAIL) MockitoAnnotations(org.mockito.MockitoAnnotations) CUIMC_USERNAME(org.sagebionetworks.bridge.spring.controllers.CRCController.CUIMC_USERNAME) NotAuthenticatedException(org.sagebionetworks.bridge.exceptions.NotAuthenticatedException) JsonNode(com.fasterxml.jackson.databind.JsonNode) RESEARCHER(org.sagebionetworks.bridge.Roles.RESEARCHER) Assert.assertFalse(org.testng.Assert.assertFalse) BOOKED(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.BOOKED) TIMESTAMP_FIELD(org.sagebionetworks.bridge.spring.controllers.CRCController.TIMESTAMP_FIELD) Reference(org.hl7.fhir.dstu3.model.Reference) OBSERVATION_REPORT(org.sagebionetworks.bridge.spring.controllers.CRCController.OBSERVATION_REPORT) TestUtils.createJson(org.sagebionetworks.bridge.TestUtils.createJson) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Set(java.util.Set) Account(org.sagebionetworks.bridge.models.accounts.Account) IOUtils(org.apache.commons.io.IOUtils) Order(org.sagebionetworks.bridge.models.crc.gbf.external.Order) Stream(java.util.stream.Stream) Logger(ch.qos.logback.classic.Logger) USER_STUDY_IDS(org.sagebionetworks.bridge.TestConstants.USER_STUDY_IDS) TestUtils.mockRequestBody(org.sagebionetworks.bridge.TestUtils.mockRequestBody) TEST_ORG_ID(org.sagebionetworks.bridge.TestConstants.TEST_ORG_ID) ContactPointSystem(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem) HealthDataSubmission(org.sagebionetworks.bridge.models.healthdata.HealthDataSubmission) SHIP_TESTS_REQUESTED(org.sagebionetworks.bridge.spring.controllers.CRCController.AccountStates.SHIP_TESTS_REQUESTED) SignIn(org.sagebionetworks.bridge.models.accounts.SignIn) SessionUpdateService(org.sagebionetworks.bridge.services.SessionUpdateService) AppointmentParticipantComponent(org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent) IP_ADDRESS(org.sagebionetworks.bridge.TestConstants.IP_ADDRESS) Mock(org.mockito.Mock) PHONE(org.sagebionetworks.bridge.TestConstants.PHONE) GBFOrderService(org.sagebionetworks.bridge.services.GBFOrderService) AppointmentStatus(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus) Roles(org.sagebionetworks.bridge.Roles) BridgeObjectMapper(org.sagebionetworks.bridge.json.BridgeObjectMapper) HttpServletRequest(javax.servlet.http.HttpServletRequest) GBF_TEST_KIT_SHIP_METHOD(org.sagebionetworks.bridge.spring.controllers.CRCController.GBF_TEST_KIT_SHIP_METHOD) App(org.sagebionetworks.bridge.models.apps.App) PROCEDURE_REPORT(org.sagebionetworks.bridge.spring.controllers.CRCController.PROCEDURE_REPORT) LimitExceededException(org.sagebionetworks.bridge.exceptions.LimitExceededException) InjectMocks(org.mockito.InjectMocks) IOException(java.io.IOException) Observation(org.hl7.fhir.dstu3.model.Observation) SHIPMENT_REPORT(org.sagebionetworks.bridge.spring.controllers.CRCController.SHIPMENT_REPORT) SHIPMENT_REPORT_KEY_ORDER_ID(org.sagebionetworks.bridge.spring.controllers.CRCController.SHIPMENT_REPORT_KEY_ORDER_ID) Patient(org.hl7.fhir.dstu3.model.Patient) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) HttpResponse(org.apache.http.HttpResponse) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) BadRequestException(org.sagebionetworks.bridge.exceptions.BadRequestException) AUTHORIZATION(com.google.common.net.HttpHeaders.AUTHORIZATION) LoggerFactory(org.slf4j.LoggerFactory) AccountId(org.sagebionetworks.bridge.models.accounts.AccountId) ReportData(org.sagebionetworks.bridge.models.reports.ReportData) LoggingEvent(ch.qos.logback.classic.spi.LoggingEvent) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) Spy(org.mockito.Spy) USER_AGENT(com.google.common.net.HttpHeaders.USER_AGENT) TestUtils(org.sagebionetworks.bridge.TestUtils) APP_ID(org.sagebionetworks.bridge.spring.controllers.CRCController.APP_ID) ImmutableSet(com.google.common.collect.ImmutableSet) Address(org.hl7.fhir.dstu3.model.Address) ImmutableMap(com.google.common.collect.ImmutableMap) TEST_USER_ID(org.sagebionetworks.bridge.TestConstants.TEST_USER_ID) HttpEntity(org.apache.http.HttpEntity) BeforeMethod(org.testng.annotations.BeforeMethod) USER_ID_VALUE_NS(org.sagebionetworks.bridge.spring.controllers.CRCController.USER_ID_VALUE_NS) Appointment(org.hl7.fhir.dstu3.model.Appointment) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) AppService(org.sagebionetworks.bridge.services.AppService) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender) AccountService(org.sagebionetworks.bridge.services.AccountService) Base64(java.util.Base64) ParticipantService(org.sagebionetworks.bridge.services.ParticipantService) Optional(java.util.Optional) BridgeUtils(org.sagebionetworks.bridge.BridgeUtils) Enrollment(org.sagebionetworks.bridge.models.studies.Enrollment) Assert.assertNull(org.testng.Assert.assertNull) Assert.assertEquals(org.testng.Assert.assertEquals) TestConstants(org.sagebionetworks.bridge.TestConstants) UTF_8(com.google.common.base.Charsets.UTF_8) Captor(org.mockito.Captor) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DateRangeResourceList(org.sagebionetworks.bridge.models.DateRangeResourceList) ArgumentCaptor(org.mockito.ArgumentCaptor) ImmutableList(com.google.common.collect.ImmutableList) ReportService(org.sagebionetworks.bridge.services.ReportService) Appender(ch.qos.logback.core.Appender) BridgeConfig(org.sagebionetworks.bridge.config.BridgeConfig) IParser(ca.uhn.fhir.parser.IParser) InOrder(org.mockito.InOrder) Assert.fail(org.testng.Assert.fail) HttpServletResponse(javax.servlet.http.HttpServletResponse) ShippingConfirmations(org.sagebionetworks.bridge.models.crc.gbf.external.ShippingConfirmations) LocalDate(org.joda.time.LocalDate) Mockito(org.mockito.Mockito) HealthDataService(org.sagebionetworks.bridge.services.HealthDataService) Level(ch.qos.logback.classic.Level) TEST_USER_GROUP(org.sagebionetworks.bridge.BridgeConstants.TEST_USER_GROUP) TIMESTAMP(org.sagebionetworks.bridge.TestConstants.TIMESTAMP) FHIR_CONTEXT(org.sagebionetworks.bridge.spring.controllers.CRCController.FHIR_CONTEXT) Assert.assertTrue(org.testng.Assert.assertTrue) ResponseEntity(org.springframework.http.ResponseEntity) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) AccountId(org.sagebionetworks.bridge.models.accounts.AccountId) ReportData(org.sagebionetworks.bridge.models.reports.ReportData) DateRangeResourceList(org.sagebionetworks.bridge.models.DateRangeResourceList) Test(org.testng.annotations.Test)

Example 2 with TEST_USER_ID

use of org.sagebionetworks.bridge.TestConstants.TEST_USER_ID in project BridgeServer2 by Sage-Bionetworks.

the class AuthUtilsTest method getAccountEnrolledIn.

private Account getAccountEnrolledIn(String... studyIds) {
    Account account = Account.create();
    account.setId(TEST_USER_ID);
    Set<Enrollment> enrollments = Arrays.asList(studyIds).stream().map(id -> Enrollment.create(TEST_APP_ID, id, TEST_USER_ID)).collect(toSet());
    account.setEnrollments(enrollments);
    return account;
}
Also used : CAN_EDIT_OTHER_ENROLLMENTS(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_OTHER_ENROLLMENTS) ORG_ADMIN(org.sagebionetworks.bridge.Roles.ORG_ADMIN) Enrollment(org.sagebionetworks.bridge.models.studies.Enrollment) Arrays(java.util.Arrays) TEST_STUDY_ID(org.sagebionetworks.bridge.TestConstants.TEST_STUDY_ID) CAN_EDIT_ASSESSMENTS(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_ASSESSMENTS) CAN_EDIT_SCHEDULES(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_SCHEDULES) Test(org.testng.annotations.Test) CAN_READ_STUDY_ASSOCIATIONS(org.sagebionetworks.bridge.AuthUtils.CAN_READ_STUDY_ASSOCIATIONS) NULL_INSTANCE(org.sagebionetworks.bridge.RequestContext.NULL_INSTANCE) CAN_EDIT_PARTICIPANTS(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_PARTICIPANTS) AfterMethod(org.testng.annotations.AfterMethod) STUDY_COORDINATOR(org.sagebionetworks.bridge.Roles.STUDY_COORDINATOR) USER_ID(org.sagebionetworks.bridge.AuthEvaluatorField.USER_ID) CAN_EDIT_ENROLLMENTS(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_ENROLLMENTS) TEST_OWNER_ID(org.sagebionetworks.bridge.TestConstants.TEST_OWNER_ID) CAN_EDIT_MEMBERS(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_MEMBERS) CAN_READ_EXTERNAL_IDS(org.sagebionetworks.bridge.AuthUtils.CAN_READ_EXTERNAL_IDS) OWNER_ID(org.sagebionetworks.bridge.AuthEvaluatorField.OWNER_ID) WORKER(org.sagebionetworks.bridge.Roles.WORKER) RESEARCHER(org.sagebionetworks.bridge.Roles.RESEARCHER) Assert.assertFalse(org.testng.Assert.assertFalse) Collectors.toSet(java.util.stream.Collectors.toSet) CAN_READ_PARTICIPANTS(org.sagebionetworks.bridge.AuthUtils.CAN_READ_PARTICIPANTS) ImmutableSet(com.google.common.collect.ImmutableSet) ORG_ID(org.sagebionetworks.bridge.AuthEvaluatorField.ORG_ID) CAN_DOWNLOAD_PARTICIPANT_ROSTER(org.sagebionetworks.bridge.AuthUtils.CAN_DOWNLOAD_PARTICIPANT_ROSTER) CAN_EDIT_STUDY_PARTICIPANTS(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_STUDY_PARTICIPANTS) TEST_APP_ID(org.sagebionetworks.bridge.TestConstants.TEST_APP_ID) SUPERADMIN(org.sagebionetworks.bridge.Roles.SUPERADMIN) TEST_USER_ID(org.sagebionetworks.bridge.TestConstants.TEST_USER_ID) Set(java.util.Set) CAN_EDIT_SHARED_ASSESSMENTS(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_SHARED_ASSESSMENTS) STUDY_DESIGNER(org.sagebionetworks.bridge.Roles.STUDY_DESIGNER) UnauthorizedException(org.sagebionetworks.bridge.exceptions.UnauthorizedException) Account(org.sagebionetworks.bridge.models.accounts.Account) ADMIN(org.sagebionetworks.bridge.Roles.ADMIN) Mockito(org.mockito.Mockito) CAN_ACCESS_ADHERENCE_DATA(org.sagebionetworks.bridge.AuthUtils.CAN_ACCESS_ADHERENCE_DATA) TEST_USER_GROUP(org.sagebionetworks.bridge.BridgeConstants.TEST_USER_GROUP) STUDY_ID(org.sagebionetworks.bridge.AuthEvaluatorField.STUDY_ID) CAN_TRANSITION_STUDY(org.sagebionetworks.bridge.AuthUtils.CAN_TRANSITION_STUDY) TEST_ORG_ID(org.sagebionetworks.bridge.TestConstants.TEST_ORG_ID) Assert.assertTrue(org.testng.Assert.assertTrue) DEVELOPER(org.sagebionetworks.bridge.Roles.DEVELOPER) Account(org.sagebionetworks.bridge.models.accounts.Account) Enrollment(org.sagebionetworks.bridge.models.studies.Enrollment)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)2 Set (java.util.Set)2 IParser (ca.uhn.fhir.parser.IParser)1 Level (ch.qos.logback.classic.Level)1 Logger (ch.qos.logback.classic.Logger)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 LoggingEvent (ch.qos.logback.classic.spi.LoggingEvent)1 Appender (ch.qos.logback.core.Appender)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 UTF_8 (com.google.common.base.Charsets.UTF_8)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 AUTHORIZATION (com.google.common.net.HttpHeaders.AUTHORIZATION)1 USER_AGENT (com.google.common.net.HttpHeaders.USER_AGENT)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Base64 (java.util.Base64)1 Optional (java.util.Optional)1