Search in sources :

Example 1 with Activity

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

the class TestUtils method getSchedule.

public static Schedule getSchedule(String label) {
    Activity activity = new Activity.Builder().withGuid(BridgeUtils.generateGuid()).withLabel("Test survey").withSurvey("identifier", "ABC", TEST_CREATED_ON).build();
    Schedule schedule = new Schedule();
    schedule.setLabel(label);
    schedule.addActivity(activity);
    schedule.setScheduleType(ScheduleType.RECURRING);
    schedule.setCronTrigger("0 0 8 ? * TUE *");
    return schedule;
}
Also used : Schedule(org.sagebionetworks.bridge.models.schedules.Schedule) Activity(org.sagebionetworks.bridge.models.schedules.Activity) ScheduledActivity(org.sagebionetworks.bridge.models.schedules.ScheduledActivity)

Example 2 with Activity

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

the class BridgeUtilsTest method createReferentGuid.

@Test
public void createReferentGuid() {
    Activity activity = TestUtils.getActivity2();
    String referent = BridgeUtils.createReferentGuidIndex(activity, LOCAL_DATE_TIME);
    assertEquals(referent, "BBB:survey:2010-10-10T10:10:10.111");
}
Also used : Activity(org.sagebionetworks.bridge.models.schedules.Activity) Test(org.testng.annotations.Test) AssessmentConfigValidatorTest(org.sagebionetworks.bridge.validators.AssessmentConfigValidatorTest)

Example 3 with Activity

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

the class CompoundActivityDefinitionServiceTest method deleteWithConstraintViolation.

@Test
public void deleteWithConstraintViolation() {
    SchedulePlan plan = TestUtils.getSimpleSchedulePlan(TEST_APP_ID);
    CompoundActivity compoundActivity = new CompoundActivity.Builder().withTaskIdentifier(TASK_ID).build();
    Activity newActivity = new Activity.Builder().withCompoundActivity(compoundActivity).build();
    plan.getStrategy().getAllPossibleSchedules().get(0).getActivities().set(0, newActivity);
    when(schedulePlanService.getSchedulePlans(ClientInfo.UNKNOWN_CLIENT, TEST_APP_ID, true)).thenReturn(Lists.newArrayList(plan));
    // Now, a schedule plan exists that references this task ID. It cannot be deleted.
    try {
        service.deleteCompoundActivityDefinition(TEST_APP_ID, TASK_ID);
        fail("Shoud have thrown exception");
    } catch (ConstraintViolationException e) {
        assertEquals(e.getReferrerKeys().get("guid"), "GGG");
        assertEquals(e.getReferrerKeys().get("type"), "SchedulePlan");
        assertEquals(e.getEntityKeys().get("taskId"), TASK_ID);
        assertEquals(e.getEntityKeys().get("type"), "CompoundActivityDefinition");
    }
}
Also used : CompoundActivity(org.sagebionetworks.bridge.models.schedules.CompoundActivity) CompoundActivity(org.sagebionetworks.bridge.models.schedules.CompoundActivity) Activity(org.sagebionetworks.bridge.models.schedules.Activity) ConstraintViolationException(org.sagebionetworks.bridge.exceptions.ConstraintViolationException) SchedulePlan(org.sagebionetworks.bridge.models.schedules.SchedulePlan) Test(org.testng.annotations.Test)

Example 4 with Activity

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

the class ActivityValidatorTest method rejectsWithoutGuid.

@Test
public void rejectsWithoutGuid() {
    Activity activity = new Activity.Builder().withLabel("label").withPublishedSurvey("identifier", "BBB").build();
    assertValidatorMessage(VALIDATOR, activity, "guid", "cannot be missing, null, or blank");
}
Also used : CompoundActivity(org.sagebionetworks.bridge.models.schedules.CompoundActivity) Activity(org.sagebionetworks.bridge.models.schedules.Activity) Test(org.testng.annotations.Test)

Example 5 with Activity

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

the class ActivityValidatorTest method multipleSources.

@Test
public void multipleSources() {
    CompoundActivity compoundActivity = new CompoundActivity.Builder().withTaskIdentifier("combo-activity").build();
    Activity activity = new Activity.Builder().withLabel("Label").withCompoundActivity(compoundActivity).withPublishedSurvey("My Survey", "CCC").build();
    assertValidatorMessage(VALIDATOR_WITH_TASKS, activity, "activity", "must have exactly one of compound activity, task, or survey");
}
Also used : CompoundActivity(org.sagebionetworks.bridge.models.schedules.CompoundActivity) CompoundActivity(org.sagebionetworks.bridge.models.schedules.CompoundActivity) Activity(org.sagebionetworks.bridge.models.schedules.Activity) Test(org.testng.annotations.Test)

Aggregations

Activity (org.sagebionetworks.bridge.models.schedules.Activity)56 Test (org.testng.annotations.Test)44 CompoundActivity (org.sagebionetworks.bridge.models.schedules.CompoundActivity)32 ScheduledActivity (org.sagebionetworks.bridge.models.schedules.ScheduledActivity)25 SchedulePlan (org.sagebionetworks.bridge.models.schedules.SchedulePlan)16 DynamoSchedulePlan (org.sagebionetworks.bridge.dynamodb.DynamoSchedulePlan)14 Schedule (org.sagebionetworks.bridge.models.schedules.Schedule)12 SchemaReference (org.sagebionetworks.bridge.models.schedules.SchemaReference)8 SurveyReference (org.sagebionetworks.bridge.models.schedules.SurveyReference)8 DateTime (org.joda.time.DateTime)6 DynamoScheduledActivity (org.sagebionetworks.bridge.dynamodb.DynamoScheduledActivity)6 LocalDateTime (org.joda.time.LocalDateTime)5 SimpleScheduleStrategy (org.sagebionetworks.bridge.models.schedules.SimpleScheduleStrategy)5 TaskReference (org.sagebionetworks.bridge.models.schedules.TaskReference)5 ForwardCursorPagedResourceList (org.sagebionetworks.bridge.models.ForwardCursorPagedResourceList)4 Item (com.amazonaws.services.dynamodbv2.document.Item)3 QueryOutcome (com.amazonaws.services.dynamodbv2.document.QueryOutcome)3 Mockito.anyString (org.mockito.Mockito.anyString)3 DynamoSurvey (org.sagebionetworks.bridge.dynamodb.DynamoSurvey)3 Survey (org.sagebionetworks.bridge.models.surveys.Survey)3