Search in sources :

Example 1 with SynapseProjectIdTeamIdHolder

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());
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) SynapseProjectIdTeamIdHolder(org.sagebionetworks.bridge.models.apps.SynapseProjectIdTeamIdHolder) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 2 with SynapseProjectIdTeamIdHolder

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);
}
Also used : SynapseProjectIdTeamIdHolder(org.sagebionetworks.bridge.models.apps.SynapseProjectIdTeamIdHolder) Test(org.testng.annotations.Test)

Aggregations

SynapseProjectIdTeamIdHolder (org.sagebionetworks.bridge.models.apps.SynapseProjectIdTeamIdHolder)2 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)1 App (org.sagebionetworks.bridge.models.apps.App)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 Test (org.testng.annotations.Test)1