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;
}
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");
}
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");
}
}
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");
}
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");
}
Aggregations