use of org.sagebionetworks.bridge.models.apps.SynapseProjectIdTeamIdHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppController method createSynapse.
@PostMapping(path = { "/v1/apps/self/synapseProject", "/v3/studies/self/synapseProject" })
@ResponseStatus(HttpStatus.CREATED)
public SynapseProjectIdTeamIdHolder createSynapse() throws SynapseException {
// first get current app
UserSession session = getAuthenticatedSession(DEVELOPER);
App app = appService.getApp(session.getAppId());
// then create project and team and grant admin permission to current user and exporter
List<String> userIds = Arrays.asList(parseJson(String[].class));
appService.createSynapseProjectTeam(ImmutableList.copyOf(userIds), app);
return new SynapseProjectIdTeamIdHolder(app.getSynapseProjectId(), app.getSynapseDataAccessTeamId());
}
use of org.sagebionetworks.bridge.models.apps.SynapseProjectIdTeamIdHolder in project BridgeServer2 by Sage-Bionetworks.
the class AppControllerTest method canCreateSynapse.
@Test
public void canCreateSynapse() throws Exception {
// mock
List<String> mockUserIds = ImmutableList.of(TEST_USER_ID);
mockRequestBody(mockRequest, mockUserIds);
// stub
doReturn(mockSession).when(controller).getAuthenticatedSession(DEVELOPER);
SynapseProjectIdTeamIdHolder result = controller.createSynapse();
// verify
verify(mockAppService).getApp(TEST_APP_ID);
verify(mockAppService).createSynapseProjectTeam(mockUserIds, app);
assertEquals(result.getProjectId(), TEST_PROJECT_ID);
assertEquals(result.getTeamId(), TEST_TEAM_ID);
}
Aggregations