Search in sources :

Example 1 with PagedResourceList

use of org.sagebionetworks.bridge.models.PagedResourceList in project BridgeServer2 by Sage-Bionetworks.

the class ExternalIdServiceTest method getExternalIdsNullParams.

@Test
public void getExternalIdsNullParams() {
    List<ExternalIdentifierInfo> list = ImmutableList.of(new ExternalIdentifierInfo(null, null, true), new ExternalIdentifierInfo(null, null, true));
    PagedResourceList<ExternalIdentifierInfo> page = new PagedResourceList<>(list, 100);
    when(mockAccountService.getPagedExternalIds(TEST_APP_ID, STUDY_ID, null, null, null)).thenReturn(page);
    PagedResourceList<ExternalIdentifierInfo> retValue = externalIdService.getPagedExternalIds(TEST_APP_ID, STUDY_ID, null, null, null);
    assertSame(retValue, page);
    verify(mockAccountService).getPagedExternalIds(TEST_APP_ID, STUDY_ID, null, null, null);
}
Also used : ExternalIdentifierInfo(org.sagebionetworks.bridge.models.accounts.ExternalIdentifierInfo) PagedResourceList(org.sagebionetworks.bridge.models.PagedResourceList) Test(org.testng.annotations.Test)

Example 2 with PagedResourceList

use of org.sagebionetworks.bridge.models.PagedResourceList in project BridgeServer2 by Sage-Bionetworks.

the class AssessmentServiceTest method getAssessmentRevisionsByGuid.

@Test
public void getAssessmentRevisionsByGuid() {
    Assessment rev1 = AssessmentTest.createAssessment();
    Assessment rev2 = AssessmentTest.createAssessment();
    Assessment rev3 = AssessmentTest.createAssessment();
    PagedResourceList<Assessment> page = new PagedResourceList<>(ImmutableList.of(rev3, rev2, rev1), 10);
    when(mockDao.getAssessmentRevisions(TEST_APP_ID, TEST_OWNER_ID, IDENTIFIER, 10, 25, true)).thenReturn(page);
    Assessment assessment = AssessmentTest.createAssessment();
    // identifier is the correct identifier already
    when(mockDao.getAssessment(TEST_APP_ID, TEST_OWNER_ID, GUID)).thenReturn(Optional.of(assessment));
    PagedResourceList<Assessment> retValue = service.getAssessmentRevisionsByGuid(TEST_APP_ID, TEST_OWNER_ID, GUID, 10, 25, true);
    assertEquals(retValue.getTotal(), Integer.valueOf(10));
    assertEquals(retValue.getItems().size(), 3);
    assertEquals(retValue.getRequestParams().get("guid"), GUID);
    assertEquals(retValue.getRequestParams().get("offsetBy"), 10);
    assertEquals(retValue.getRequestParams().get("pageSize"), 25);
    assertTrue((Boolean) retValue.getRequestParams().get("includeDeleted"));
}
Also used : Assessment(org.sagebionetworks.bridge.models.assessments.Assessment) PagedResourceList(org.sagebionetworks.bridge.models.PagedResourceList) Test(org.testng.annotations.Test) AssessmentTest(org.sagebionetworks.bridge.models.assessments.AssessmentTest)

Example 3 with PagedResourceList

use of org.sagebionetworks.bridge.models.PagedResourceList in project BridgeServer2 by Sage-Bionetworks.

the class AssessmentServiceTest method publishAssessmentPriorPublishedVersion.

@Test
public void publishAssessmentPriorPublishedVersion() {
    when(mockOrganizationService.getOrganization(TEST_APP_ID, TEST_OWNER_ID)).thenReturn(mockOrganization);
    Assessment local = AssessmentTest.createAssessment();
    when(mockDao.getAssessment(TEST_APP_ID, TEST_OWNER_ID, GUID)).thenReturn(Optional.of(local));
    AssessmentConfig localConfig = new AssessmentConfig();
    when(mockConfigService.getAssessmentConfig(TEST_APP_ID, GUID)).thenReturn(localConfig);
    // Same as the happy path version, but this time there is a revision in the
    // shared library
    Assessment revision = AssessmentTest.createAssessment();
    revision.setRevision(10);
    revision.setOwnerId(TEST_APP_ID + ":" + TEST_OWNER_ID);
    PagedResourceList<Assessment> page = new PagedResourceList<>(ImmutableList.of(revision), 1);
    when(mockDao.getAssessmentRevisions(SHARED_APP_ID, null, IDENTIFIER, 0, 1, true)).thenReturn(page);
    service.publishAssessment(TEST_APP_ID, TEST_OWNER_ID, null, GUID);
    verify(mockDao).publishAssessment(eq(TEST_APP_ID), assessmentCaptor.capture(), assessmentCaptor.capture(), configCaptor.capture());
    Assessment assessmentToPublish = assessmentCaptor.getAllValues().get(1);
    assertEquals(assessmentToPublish.getRevision(), 11);
    assertSame(localConfig, configCaptor.getValue());
}
Also used : AssessmentConfig(org.sagebionetworks.bridge.models.assessments.config.AssessmentConfig) Assessment(org.sagebionetworks.bridge.models.assessments.Assessment) PagedResourceList(org.sagebionetworks.bridge.models.PagedResourceList) Test(org.testng.annotations.Test) AssessmentTest(org.sagebionetworks.bridge.models.assessments.AssessmentTest)

Example 4 with PagedResourceList

use of org.sagebionetworks.bridge.models.PagedResourceList in project BridgeServer2 by Sage-Bionetworks.

the class AssessmentServiceTest method getAssessmentRevisions.

@Test
public void getAssessmentRevisions() {
    Assessment rev1 = AssessmentTest.createAssessment();
    Assessment rev2 = AssessmentTest.createAssessment();
    Assessment rev3 = AssessmentTest.createAssessment();
    PagedResourceList<Assessment> page = new PagedResourceList<>(ImmutableList.of(rev3, rev2, rev1), 10);
    when(mockDao.getAssessmentRevisions(TEST_APP_ID, TEST_OWNER_ID, IDENTIFIER, 10, 25, true)).thenReturn(page);
    PagedResourceList<Assessment> retValue = service.getAssessmentRevisionsById(TEST_APP_ID, TEST_OWNER_ID, IDENTIFIER, 10, 25, true);
    assertEquals(retValue.getTotal(), Integer.valueOf(10));
    assertEquals(retValue.getItems().size(), 3);
    assertEquals(retValue.getRequestParams().get("identifier"), IDENTIFIER);
    assertEquals(retValue.getRequestParams().get("offsetBy"), 10);
    assertEquals(retValue.getRequestParams().get("pageSize"), 25);
    assertTrue((Boolean) retValue.getRequestParams().get("includeDeleted"));
}
Also used : Assessment(org.sagebionetworks.bridge.models.assessments.Assessment) PagedResourceList(org.sagebionetworks.bridge.models.PagedResourceList) Test(org.testng.annotations.Test) AssessmentTest(org.sagebionetworks.bridge.models.assessments.AssessmentTest)

Example 5 with PagedResourceList

use of org.sagebionetworks.bridge.models.PagedResourceList in project BridgeServer2 by Sage-Bionetworks.

the class AssessmentServiceTest method publishAssessmentPriorPublishedVersionDifferentOwner.

@Test(expectedExceptions = UnauthorizedException.class, expectedExceptionsMessageRegExp = ".*Assessment exists in shared library.*")
public void publishAssessmentPriorPublishedVersionDifferentOwner() {
    when(mockOrganizationService.getOrganization(TEST_APP_ID, TEST_OWNER_ID)).thenReturn(mockOrganization);
    Assessment local = AssessmentTest.createAssessment();
    when(mockDao.getAssessment(TEST_APP_ID, TEST_OWNER_ID, GUID)).thenReturn(Optional.of(local));
    // Same as the happy path version, but this time there is a revision in the
    // shared library
    Assessment revision = AssessmentTest.createAssessment();
    revision.setRevision(10);
    revision.setOwnerId("otherApp:" + TEST_OWNER_ID);
    PagedResourceList<Assessment> page = new PagedResourceList<>(ImmutableList.of(revision), 1);
    when(mockDao.getAssessmentRevisions(SHARED_APP_ID, null, IDENTIFIER, 0, 1, true)).thenReturn(page);
    service.publishAssessment(TEST_APP_ID, TEST_OWNER_ID, null, GUID);
}
Also used : Assessment(org.sagebionetworks.bridge.models.assessments.Assessment) PagedResourceList(org.sagebionetworks.bridge.models.PagedResourceList) Test(org.testng.annotations.Test) AssessmentTest(org.sagebionetworks.bridge.models.assessments.AssessmentTest)

Aggregations

PagedResourceList (org.sagebionetworks.bridge.models.PagedResourceList)57 Test (org.testng.annotations.Test)49 StudyActivityEvent (org.sagebionetworks.bridge.models.activities.StudyActivityEvent)12 Assessment (org.sagebionetworks.bridge.models.assessments.Assessment)12 AssessmentTest (org.sagebionetworks.bridge.models.assessments.AssessmentTest)12 WeeklyAdherenceReport (org.sagebionetworks.bridge.models.schedules2.adherence.weekly.WeeklyAdherenceReport)12 RequestContext (org.sagebionetworks.bridge.RequestContext)10 Account (org.sagebionetworks.bridge.models.accounts.Account)10 AdherenceRecord (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord)10 StudyAdherenceReportGeneratorTest (org.sagebionetworks.bridge.models.schedules2.adherence.study.StudyAdherenceReportGeneratorTest)8 Study (org.sagebionetworks.bridge.models.studies.Study)8 AdherenceReportSearch (org.sagebionetworks.bridge.models.AdherenceReportSearch)7 AccountSummarySearch (org.sagebionetworks.bridge.models.AccountSummarySearch)6 ResourceList (org.sagebionetworks.bridge.models.ResourceList)6 AccountSummary (org.sagebionetworks.bridge.models.accounts.AccountSummary)6 EnrollmentDetail (org.sagebionetworks.bridge.models.studies.EnrollmentDetail)5 ArrayList (java.util.ArrayList)4 StudyActivityEventIdsMap (org.sagebionetworks.bridge.models.activities.StudyActivityEventIdsMap)4 ForwardCursorPagedResourceList (org.sagebionetworks.bridge.models.ForwardCursorPagedResourceList)3 AdherenceRecordsSearch (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecordsSearch)3