public ActivityOfferingInfo testCRUDActivityOffering(FormatOfferingInfo fo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException, ReadOnlyException, VersionMismatchException { ActivityOfferingInfo orig = new ActivityOfferingInfo(); orig.setFormatOfferingId(fo.getId()); orig.setActivityId(fo.getId() + "." + LuServiceConstants.COURSE_ACTIVITY_LECTURE_TYPE_KEY); orig.setTypeKey(LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY); orig.setStateKey(LuiServiceConstants.LUI_AO_STATE_DRAFT_KEY); orig.setMinimumEnrollment(100); orig.setMaximumEnrollment(150); orig.setIsEvaluated(true); orig.setIsMaxEnrollmentEstimate(false); orig.setIsHonorsOffering(true); ActivityOfferingInfo info = courseOfferingService.createActivityOffering( orig.getFormatOfferingId(), orig.getActivityId(), orig.getTypeKey(), orig, callContext); assertNotNull(info); assertNotNull(info.getId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getFormatOfferingId(), info.getFormatOfferingId()); assertEquals(orig.getActivityId(), info.getActivityId()); assertEquals(orig.getMinimumEnrollment(), info.getMinimumEnrollment()); assertEquals(orig.getMaximumEnrollment(), info.getMaximumEnrollment()); assertEquals(orig.getIsEvaluated(), info.getIsEvaluated()); assertEquals(orig.getIsMaxEnrollmentEstimate(), info.getIsMaxEnrollmentEstimate()); assertEquals(orig.getIsHonorsOffering(), info.getIsHonorsOffering()); orig = info; info = courseOfferingService.getActivityOffering(orig.getId(), callContext); assertNotNull(info); assertEquals(orig.getId(), info.getId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getFormatOfferingId(), info.getFormatOfferingId()); assertEquals(orig.getActivityId(), info.getActivityId()); assertEquals(orig.getMinimumEnrollment(), info.getMinimumEnrollment()); assertEquals(orig.getMaximumEnrollment(), info.getMaximumEnrollment()); orig = info; orig.setMinimumEnrollment(100); info = courseOfferingService.updateActivityOffering(orig.getId(), orig, callContext); assertNotNull(info); assertEquals(orig.getId(), info.getId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getFormatOfferingId(), info.getFormatOfferingId()); assertEquals(orig.getActivityId(), info.getActivityId()); assertEquals(orig.getMinimumEnrollment(), info.getMinimumEnrollment()); assertEquals(orig.getMaximumEnrollment(), info.getMaximumEnrollment()); return info; }
private void testDeletes(CourseOfferingInfo co, FormatOfferingInfo fo, ActivityOfferingInfo ao) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, DependentObjectsExistException { // delete activity offering StatusInfo status = this.courseOfferingService.deleteActivityOffering(ao.getId(), callContext); assertNotNull(status); assertEquals(Boolean.TRUE, status.getIsSuccess()); try { courseOfferingService.getActivityOffering(ao.getId(), callContext); fail("should have thrown DoesNotExistException"); } catch (DoesNotExistException ex) { assertNotNull(ex.getMessage()); assertEquals(ao.getId(), ex.getMessage()); } // delete fo status = this.courseOfferingService.deleteFormatOffering(fo.getId(), callContext); assertNotNull(status); assertEquals(Boolean.TRUE, status.getIsSuccess()); try { courseOfferingService.getFormatOffering(fo.getId(), callContext); fail("should have thrown DoesNotExistException"); } catch (DoesNotExistException ex) { assertNotNull(ex.getMessage()); assertEquals(fo.getId(), ex.getMessage()); } // delete co status = this.courseOfferingService.deleteCourseOffering(co.getId(), callContext); assertNotNull(status); assertEquals(Boolean.TRUE, status.getIsSuccess()); try { courseOfferingService.getCourseOffering(co.getId(), callContext); fail("should have thrown DoesNotExistException"); } catch (DoesNotExistException ex) { assertNotNull(ex.getMessage()); assertEquals(co.getId(), ex.getMessage()); } }
public FormatOfferingInfo testCRUDFormatOffering(CourseOfferingInfo co) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException, VersionMismatchException, ReadOnlyException, DependentObjectsExistException { FormatOfferingInfo orig = new FormatOfferingInfo(); orig.setCourseOfferingId(co.getId()); orig.setFormatId("COURSE1-FORMAT1"); orig.setActivityOfferingTypeKeys( Arrays.asList(LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY)); orig.setTypeKey(LuiServiceConstants.FORMAT_OFFERING_TYPE_KEY); orig.setStateKey(LuiServiceConstants.LUI_FO_STATE_DRAFT_KEY); FormatOfferingInfo info = courseOfferingService.createFormatOffering( orig.getCourseOfferingId(), orig.getFormatId(), orig.getTypeKey(), orig, callContext); assertNotNull(info); assertNotNull(info.getId()); assertEquals(orig.getCourseOfferingId(), info.getCourseOfferingId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getFormatId(), info.getFormatId()); // TODO: turn these tests back on once we get the corresponding JPA entities working // assertEquals(orig.getActivityOfferingTypeKeys().size(), // info.getActivityOfferingTypeKeys().size()); // assertEquals(orig.getActivityOfferingTypeKeys().get(0), // info.getActivityOfferingTypeKeys().get(0)); List<FormatOfferingInfo> formats = courseOfferingService.getFormatOfferingsByCourseOffering(co.getId(), callContext); info = formats.get(0); assertNotNull(info); assertNotNull(info.getId()); assertEquals(orig.getCourseOfferingId(), info.getCourseOfferingId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getFormatId(), info.getFormatId()); orig = info; info = courseOfferingService.getFormatOffering(orig.getId(), callContext); assertNotNull(info); assertEquals(orig.getId(), info.getId()); assertEquals(orig.getCourseOfferingId(), info.getCourseOfferingId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getFormatId(), info.getFormatId()); // assertEquals(orig.getActivityOfferingTypeKeys().size(), // info.getActivityOfferingTypeKeys().size()); // assertEquals(orig.getActivityOfferingTypeKeys().get(0), // info.getActivityOfferingTypeKeys().get(0)); orig = info; orig.setActivityOfferingTypeKeys( Arrays.asList(LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY)); info = courseOfferingService.updateFormatOffering(orig.getId(), orig, callContext); assertNotNull(info); assertEquals(orig.getId(), info.getId()); assertEquals(orig.getCourseOfferingId(), info.getCourseOfferingId()); assertEquals(orig.getStateKey(), info.getStateKey()); assertEquals(orig.getTypeKey(), info.getTypeKey()); assertEquals(orig.getFormatId(), info.getFormatId()); // assertEquals(orig.getActivityOfferingTypeKeys().size(), // info.getActivityOfferingTypeKeys().size()); // assertEquals(orig.getActivityOfferingTypeKeys().get(0), // info.getActivityOfferingTypeKeys().get(0)); return info; }