use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class DynamoAppConfigElementDaoTest method saveElementRevision.
@Test
public void saveElementRevision() {
AppConfigElement element = AppConfigElement.create();
element.setVersion(1L);
VersionHolder returned = dao.saveElementRevision(element);
assertEquals(returned.getVersion(), new Long(1));
verify(mockMapper).save(element);
}
use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppController method updateAppForDeveloperOrAdmin.
@PostMapping(path = { "/v1/apps/self", "/v3/studies/self" })
public VersionHolder updateAppForDeveloperOrAdmin() {
UserSession session = getAuthenticatedSession(DEVELOPER);
App appUpdate = parseJson(App.class);
appUpdate.setIdentifier(session.getAppId());
appUpdate = appService.updateApp(appUpdate, session.isInRole(ADMIN));
return new VersionHolder(appUpdate.getVersion());
}
use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class StudyServiceTest method createStudyWithSponsorship.
@Test
public void createStudyWithSponsorship() {
RequestContext.set(new RequestContext.Builder().withCallerOrgMembership(TEST_ORG_ID).build());
Study study = Study.create();
study.setIdentifier(TEST_STUDY_ID);
study.setName("oneName");
study.setAppId("junk");
study.setVersion(10L);
study.setDeleted(true);
study.setPhase(IN_FLIGHT);
DateTime timestamp = DateTime.now().minusHours(2);
study.setCreatedOn(timestamp);
study.setModifiedOn(timestamp);
when(mockStudyDao.createStudy(any())).thenReturn(VERSION_HOLDER);
VersionHolder returnedValue = service.createStudy(TEST_APP_ID, study, true);
assertEquals(returnedValue, VERSION_HOLDER);
verify(mockStudyDao).createStudy(studyCaptor.capture());
Study persisted = studyCaptor.getValue();
assertEquals(persisted.getIdentifier(), TEST_STUDY_ID);
assertEquals(persisted.getName(), "oneName");
assertEquals(persisted.getAppId(), TEST_APP_ID);
assertEquals(persisted.getPhase(), DESIGN);
assertNull(persisted.getVersion());
assertFalse(persisted.isDeleted());
assertNotEquals(persisted.getCreatedOn(), timestamp);
assertNotEquals(persisted.getModifiedOn(), timestamp);
verify(mockSponsorService).createStudyWithSponsorship(TEST_APP_ID, TEST_STUDY_ID, TEST_ORG_ID);
}
use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppConfigElementServiceTest method createElementWithArbitraryRevision.
@Test
public void createElementWithArbitraryRevision() {
// revision = 3
AppConfigElement element = TestUtils.getAppConfigElement();
when(dao.saveElementRevision(element)).thenReturn(VERSION_HOLDER);
VersionHolder returned = service.createElement(TEST_APP_ID, element);
assertEquals(returned, VERSION_HOLDER);
verify(dao).saveElementRevision(elementCaptor.capture());
// Revision was maintained because it was set, and doesn't exist
assertEquals(elementCaptor.getValue().getRevision(), new Long(3));
}
use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class HibernateStudyDaoTest method createStudy.
@Test
public void createStudy() {
HibernateStudy study = new HibernateStudy();
study.setIdentifier(TEST_STUDY_ID);
study.setAppId(TEST_APP_ID);
study.setVersion(2L);
VersionHolder holder = dao.createStudy(study);
assertEquals(holder.getVersion(), new Long(2));
verify(hibernateHelper).create(studyCaptor.capture());
Study persisted = studyCaptor.getValue();
assertEquals(persisted.getVersion(), new Long(2));
}
Aggregations