use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppControllerTest method updateApp.
@Test
public void updateApp() throws Exception {
when(mockSession.getAppId()).thenReturn(TEST_APP_ID);
doReturn(mockSession).when(controller).getAuthenticatedSession(SUPERADMIN);
App created = App.create();
created.setVersion(3L);
when(mockAppService.updateApp(any(), anyBoolean())).thenReturn(created);
App app = App.create();
app.setName("value to seek");
mockRequestBody(mockRequest, app);
VersionHolder holder = controller.updateApp(TEST_APP_ID);
assertEquals(holder.getVersion(), Long.valueOf(3L));
verify(mockAppService).updateApp(appCaptor.capture(), eq(true));
assertEquals(appCaptor.getValue().getName(), "value to seek");
}
use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppConfigElementServiceTest method createElement.
@Test
public void createElement() {
AppConfigElement element = TestUtils.getAppConfigElement();
element.setRevision(null);
element.setDeleted(true);
when(dao.saveElementRevision(element)).thenReturn(VERSION_HOLDER);
VersionHolder returned = service.createElement(TEST_APP_ID, element);
assertEquals(returned, VERSION_HOLDER);
verify(dao).saveElementRevision(elementCaptor.capture());
// These have been correctly reset
assertEquals(elementCaptor.getValue().getRevision(), new Long(1));
AppConfigElement captured = elementCaptor.getValue();
assertNull(captured.getVersion());
assertFalse(captured.isDeleted());
assertEquals(captured.getAppId(), TEST_APP_ID);
assertEquals(captured.getKey(), TEST_APP_ID + ":id");
assertEquals(captured.getCreatedOn(), TIMESTAMP.getMillis());
assertEquals(captured.getModifiedOn(), TIMESTAMP.getMillis());
}
use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppConfigElementServiceTest method updateElementRevision.
@Test
public void updateElementRevision() {
AppConfigElement element = TestUtils.getAppConfigElement();
AppConfigElement existing = TestUtils.getAppConfigElement();
when(dao.getElementRevision(TEST_APP_ID, element.getId(), element.getRevision())).thenReturn(existing);
when(dao.saveElementRevision(element)).thenReturn(VERSION_HOLDER);
VersionHolder returned = service.updateElementRevision(TEST_APP_ID, element);
assertEquals(returned, VERSION_HOLDER);
verify(dao).saveElementRevision(elementCaptor.capture());
AppConfigElement captured = elementCaptor.getValue();
assertEquals(captured.getAppId(), TEST_APP_ID);
assertEquals(captured.getKey(), TEST_APP_ID + ":id");
assertNotEquals(captured.getCreatedOn(), TIMESTAMP.getMillis());
assertEquals(captured.getModifiedOn(), TIMESTAMP.getMillis());
}
use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppConfigElementsController method createElement.
@PostMapping("/v3/appconfigs/elements")
@ResponseStatus(HttpStatus.CREATED)
public VersionHolder createElement() {
UserSession session = getAuthenticatedSession(DEVELOPER);
AppConfigElement element = parseJson(AppConfigElement.class);
VersionHolder version = service.createElement(session.getAppId(), element);
// App config elements are included in the app configs, so allow cache to update
cacheProvider.removeSetOfCacheKeys(CacheKey.appConfigList(session.getAppId()));
return version;
}
use of org.sagebionetworks.bridge.models.VersionHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppConfigElementsController method updateElementRevision.
@PostMapping("/v3/appconfigs/elements/{id}/revisions/{revision}")
public VersionHolder updateElementRevision(@PathVariable String id, @PathVariable String revision) {
UserSession session = getAuthenticatedSession(DEVELOPER);
Long revisionLong = BridgeUtils.getLongOrDefault(revision, null);
if (revisionLong == null) {
throw new BadRequestException("Revision is not a valid revision number");
}
AppConfigElement element = parseJson(AppConfigElement.class);
element.setId(id);
element.setRevision(revisionLong);
VersionHolder holder = service.updateElementRevision(session.getAppId(), element);
// App config elements are included in the app configs, so allow cache to update
cacheProvider.removeSetOfCacheKeys(CacheKey.appConfigList(session.getAppId()));
return holder;
}
Aggregations