Search in sources :

Example 1 with CompoundActivityDefinition

use of org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition in project BridgeServer2 by Sage-Bionetworks.

the class DynamoCompoundActivityDefinitionDaoTest method createCompoundActivityDefinition.

@Test
public void createCompoundActivityDefinition() {
    DynamoCompoundActivityDefinition def = new DynamoCompoundActivityDefinition();
    def.setAppId(TEST_APP_ID);
    def.setTaskId(TASK_ID);
    def.setVersion(1L);
    CompoundActivityDefinition result = dao.createCompoundActivityDefinition(def);
    assertSame(result, def);
    verify(mockMapper).save(defCaptor.capture());
    assertNull(defCaptor.getValue().getVersion());
}
Also used : CompoundActivityDefinition(org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition) Test(org.testng.annotations.Test)

Example 2 with CompoundActivityDefinition

use of org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition in project BridgeServer2 by Sage-Bionetworks.

the class CompoundActivityDefinitionController method updateCompoundActivityDefinition.

/**
 * Update a compound activity definition.
 */
@PostMapping(path = "/v3/compoundactivitydefinitions/{taskId}", produces = { APPLICATION_JSON_UTF8_VALUE })
public String updateCompoundActivityDefinition(@PathVariable String taskId) throws JsonProcessingException, IOException {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    CompoundActivityDefinition requestDef = parseJson(CompoundActivityDefinition.class);
    CompoundActivityDefinition updatedDef = compoundActivityDefService.updateCompoundActivityDefinition(session.getAppId(), taskId, requestDef);
    return PUBLIC_DEFINITION_WRITER.writeValueAsString(updatedDef);
}
Also used : CompoundActivityDefinition(org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with CompoundActivityDefinition

use of org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition in project BridgeServer2 by Sage-Bionetworks.

the class CompoundActivityDefinitionController method createCompoundActivityDefinition.

/**
 * Creates a compound activity definition.
 */
@PostMapping(path = "/v3/compoundactivitydefinitions", produces = { APPLICATION_JSON_UTF8_VALUE })
@ResponseStatus(HttpStatus.CREATED)
public String createCompoundActivityDefinition() throws JsonProcessingException, IOException {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    CompoundActivityDefinition requestDef = parseJson(CompoundActivityDefinition.class);
    CompoundActivityDefinition createdDef = compoundActivityDefService.createCompoundActivityDefinition(session.getAppId(), requestDef);
    return PUBLIC_DEFINITION_WRITER.writeValueAsString(createdDef);
}
Also used : CompoundActivityDefinition(org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 4 with CompoundActivityDefinition

use of org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition in project BridgeServer2 by Sage-Bionetworks.

the class CompoundActivityDefinitionServiceTest method createInvalidDef.

@Test
public void createInvalidDef() {
    // make invalid def by having it have no task ID
    CompoundActivityDefinition def = makeValidDef();
    def.setTaskId(null);
    // execute, will throw
    try {
        service.createCompoundActivityDefinition(TEST_APP_ID, def);
        fail("expected exception");
    } catch (InvalidEntityException ex) {
    // expected exception
    }
    // verify dao is never called
    verifyZeroInteractions(dao);
}
Also used : CompoundActivityDefinition(org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition) InvalidEntityException(org.sagebionetworks.bridge.exceptions.InvalidEntityException) Test(org.testng.annotations.Test)

Example 5 with CompoundActivityDefinition

use of org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition in project BridgeServer2 by Sage-Bionetworks.

the class CompoundActivityDefinitionServiceTest method makeValidDef.

private static CompoundActivityDefinition makeValidDef() {
    CompoundActivityDefinition def = CompoundActivityDefinition.create();
    def.setTaskId(TASK_ID);
    def.setSchemaList(SCHEMA_LIST);
    def.setSurveyList(SURVEY_LIST);
    return def;
}
Also used : CompoundActivityDefinition(org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition)

Aggregations

CompoundActivityDefinition (org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition)24 Test (org.testng.annotations.Test)14 InvalidEntityException (org.sagebionetworks.bridge.exceptions.InvalidEntityException)5 DynamoCompoundActivityDefinition (org.sagebionetworks.bridge.dynamodb.DynamoCompoundActivityDefinition)4 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)4 ResourceList (org.sagebionetworks.bridge.models.ResourceList)2 SchemaReference (org.sagebionetworks.bridge.models.schedules.SchemaReference)2 SurveyReference (org.sagebionetworks.bridge.models.schedules.SurveyReference)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)1 CompoundActivity (org.sagebionetworks.bridge.models.schedules.CompoundActivity)1 Survey (org.sagebionetworks.bridge.models.surveys.Survey)1 UploadSchema (org.sagebionetworks.bridge.models.upload.UploadSchema)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 BeforeMethod (org.testng.annotations.BeforeMethod)1