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);
}
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"));
}
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());
}
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"));
}
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);
}
Aggregations