use of org.sagebionetworks.bridge.exceptions.InvalidEntityException in project BridgeServer2 by Sage-Bionetworks.
the class MasterSchedulerServiceTest method testCreateSchedulerConfigValidates.
@Test
public void testCreateSchedulerConfigValidates() {
MasterSchedulerConfig mockConfig = TestUtils.getMasterSchedulerConfig();
mockConfig.setScheduleId(null);
try {
schedulerService.createSchedulerConfig(mockConfig);
fail("expected exception");
} catch (InvalidEntityException ex) {
// expected exception
}
verify(configDao, never()).createSchedulerConfig(any());
}
use of org.sagebionetworks.bridge.exceptions.InvalidEntityException in project BridgeServer2 by Sage-Bionetworks.
the class ConsentServiceTest method noConsentIfTooYoung.
@Test
public void noConsentIfTooYoung() {
ConsentSignature consentSignature = new ConsentSignature.Builder().withConsentSignature(CONSENT_SIGNATURE).withBirthdate("2018-05-12").build();
try {
consentService.consentToResearch(app, SUBPOP_GUID, PARTICIPANT, consentSignature, SharingScope.NO_SHARING, false);
fail("Exception expected.");
} catch (InvalidEntityException e) {
verifyNoMoreInteractions(accountService);
}
}
use of org.sagebionetworks.bridge.exceptions.InvalidEntityException in project BridgeServer2 by Sage-Bionetworks.
the class StudyParticipantValidatorTest method validatesUpdate.
// Password, email address, and externalId (if being validated) cannot be updated, so these don't need to be validated.
@Test
public void validatesUpdate() {
validator = makeValidator(false);
Map<String, String> attrs = Maps.newHashMap();
attrs.put("badValue", "value");
StudyParticipant participant = new StudyParticipant.Builder().withDataGroups(Sets.newHashSet("badGroup")).withAttributes(attrs).withPassword("bad").build();
try {
Validate.entityThrowingException(validator, participant);
} catch (InvalidEntityException e) {
assertNull(e.getErrors().get("email"));
assertNull(e.getErrors().get("externalId"));
assertNull(e.getErrors().get("password"));
}
assertValidatorMessage(validator, participant, "dataGroups", "'badGroup' is not defined for app (use group1, group2, bluebell)");
assertValidatorMessage(validator, participant, "attributes", "'badValue' is not defined for app (use attr1, attr2, phone)");
}
use of org.sagebionetworks.bridge.exceptions.InvalidEntityException in project BridgeServer2 by Sage-Bionetworks.
the class SubpopulationValidatorTest method testValidation.
@Test
public void testValidation() {
Subpopulation subpop = Subpopulation.create();
Criteria criteria = TestUtils.createCriteria(-10, -2, null, ImmutableSet.of("wrongGroup"));
criteria.setAllOfStudyIds(ImmutableSet.of("studyC"));
criteria.setNoneOfStudyIds(ImmutableSet.of("studyD"));
subpop.setCriteria(criteria);
subpop.setDataGroupsAssignedWhileConsented(ImmutableSet.of("group1", "dataGroup3"));
subpop.setStudyIdsAssignedOnConsent(ImmutableSet.of("studyC"));
try {
Validate.entityThrowingException(validator, subpop);
fail("Should have thrown an exception");
} catch (InvalidEntityException e) {
assertValidatorMessage(validator, subpop, "criteria.minAppVersions.iphone_os", " cannot be negative");
assertValidatorMessage(validator, subpop, "criteria.maxAppVersions.iphone_os", " cannot be negative");
assertValidatorMessage(validator, subpop, "appId", CANNOT_BE_NULL);
assertValidatorMessage(validator, subpop, "name", CANNOT_BE_NULL);
assertValidatorMessage(validator, subpop, "guid", CANNOT_BE_NULL);
assertValidatorMessage(validator, subpop, "criteria.noneOfGroups", " 'wrongGroup' is not in enumeration: group1, group2");
assertValidatorMessage(validator, subpop, "criteria.allOfStudyIds", " 'studyC' is not in enumeration: studyA, studyB");
assertValidatorMessage(validator, subpop, "criteria.noneOfStudyIds", " 'studyD' is not in enumeration: studyA, studyB");
assertValidatorMessage(validator, subpop, "dataGroupsAssignedWhileConsented", " 'dataGroup3' is not in enumeration: group1, group2");
assertValidatorMessage(validator, subpop, "studyIdsAssignedOnConsent", " 'studyC' is not in enumeration: studyA, studyB");
}
}
use of org.sagebionetworks.bridge.exceptions.InvalidEntityException 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);
}
Aggregations