Search in sources :

Example 1 with EntityNotFoundException

use of org.sagebionetworks.bridge.exceptions.EntityNotFoundException in project BridgeServer2 by Sage-Bionetworks.

the class DefaultAppBootstrapperTest method skipBootstrapAccountIfNotConfigured.

@Test
public void skipBootstrapAccountIfNotConfigured() {
    when(mockConfig.getEnvironment()).thenReturn(Environment.DEV);
    List<TableDescription> tables = ImmutableList.of();
    when(mockAnnotationBasedTableCreator.getTables("org.sagebionetworks.bridge.dynamodb")).thenReturn(tables);
    when(mockAppService.getApp(any())).thenThrow(new EntityNotFoundException(App.class));
    when(mockAppService.createApp(any())).thenAnswer((args) -> args.getArgument(0));
    // We don't care about the context
    bootstrapper.onApplicationEvent(null);
    verify(mockDynamoInitializer).init(tables);
    verify(mockS3Initializer).initBuckets();
    verify(mockAppService, times(3)).createApp(appCaptor.capture());
    verify(mockUserAdminService, never()).createUser(any(), any(), any(), anyBoolean(), anyBoolean());
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) TableDescription(com.amazonaws.services.dynamodbv2.model.TableDescription) Test(org.testng.annotations.Test)

Example 2 with EntityNotFoundException

use of org.sagebionetworks.bridge.exceptions.EntityNotFoundException in project BridgeServer2 by Sage-Bionetworks.

the class ConsentServiceTest method userCannotGetConsentSignatureForSubpopulationToWhichTheyAreNotMapped.

@Test(expectedExceptions = EntityNotFoundException.class)
public void userCannotGetConsentSignatureForSubpopulationToWhichTheyAreNotMapped() {
    when(subpopService.getSubpopulation(app.getIdentifier(), SUBPOP_GUID)).thenThrow(new EntityNotFoundException(Subpopulation.class));
    consentService.getConsentSignature(app, SUBPOP_GUID, PARTICIPANT.getId());
}
Also used : Subpopulation(org.sagebionetworks.bridge.models.subpopulations.Subpopulation) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) Test(org.testng.annotations.Test)

Example 3 with EntityNotFoundException

use of org.sagebionetworks.bridge.exceptions.EntityNotFoundException in project BridgeServer2 by Sage-Bionetworks.

the class EnrollmentServiceTest method getEnrollmentsForUser_studyNotFound.

@Test(expectedExceptions = EntityNotFoundException.class, expectedExceptionsMessageRegExp = "Study not found.")
public void getEnrollmentsForUser_studyNotFound() {
    when(mockStudyService.getStudy(TEST_APP_ID, TEST_STUDY_ID, true)).thenThrow(new EntityNotFoundException(Study.class));
    service.getEnrollmentsForUser(TEST_APP_ID, TEST_STUDY_ID, TEST_USER_ID);
}
Also used : Study(org.sagebionetworks.bridge.models.studies.Study) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) Test(org.testng.annotations.Test)

Example 4 with EntityNotFoundException

use of org.sagebionetworks.bridge.exceptions.EntityNotFoundException in project BridgeServer2 by Sage-Bionetworks.

the class EnrollmentServiceTest method addEnrollment_studyNotFound.

@Test(expectedExceptions = EntityNotFoundException.class, expectedExceptionsMessageRegExp = "Study not found.")
public void addEnrollment_studyNotFound() {
    when(mockStudyService.getStudy(TEST_APP_ID, TEST_STUDY_ID, true)).thenThrow(new EntityNotFoundException(Study.class));
    service.addEnrollment(Account.create(), Enrollment.create(TEST_APP_ID, TEST_STUDY_ID, TEST_USER_ID), false);
}
Also used : Study(org.sagebionetworks.bridge.models.studies.Study) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) Test(org.testng.annotations.Test)

Example 5 with EntityNotFoundException

use of org.sagebionetworks.bridge.exceptions.EntityNotFoundException in project BridgeServer2 by Sage-Bionetworks.

the class EnrollmentServiceTest method enroll_studyNotFound.

@Test(expectedExceptions = EntityNotFoundException.class, expectedExceptionsMessageRegExp = "Study not found.")
public void enroll_studyNotFound() {
    when(mockStudyService.getStudy(TEST_APP_ID, TEST_STUDY_ID, true)).thenThrow(new EntityNotFoundException(Study.class));
    service.enroll(Enrollment.create(TEST_APP_ID, TEST_STUDY_ID, TEST_USER_ID));
}
Also used : Study(org.sagebionetworks.bridge.models.studies.Study) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) Test(org.testng.annotations.Test)

Aggregations

EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)253 Account (org.sagebionetworks.bridge.models.accounts.Account)77 Test (org.testng.annotations.Test)74 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)44 AccountId (org.sagebionetworks.bridge.models.accounts.AccountId)35 App (org.sagebionetworks.bridge.models.apps.App)32 GetMapping (org.springframework.web.bind.annotation.GetMapping)31 BadRequestException (org.sagebionetworks.bridge.exceptions.BadRequestException)22 Survey (org.sagebionetworks.bridge.models.surveys.Survey)20 DateTime (org.joda.time.DateTime)17 Study (org.sagebionetworks.bridge.models.studies.Study)17 StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)15 Assessment (org.sagebionetworks.bridge.models.assessments.Assessment)14 RequestContext (org.sagebionetworks.bridge.RequestContext)11 Enrollment (org.sagebionetworks.bridge.models.studies.Enrollment)11 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)11 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)10 Subpopulation (org.sagebionetworks.bridge.models.subpopulations.Subpopulation)10 Organization (org.sagebionetworks.bridge.models.organizations.Organization)9 ReportIndex (org.sagebionetworks.bridge.models.reports.ReportIndex)9