001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/course-management/tags/sakai_2-4-1/cm-impl/hibernate-impl/impl/src/test/org/sakaiproject/coursemanagement/test/CourseManagementAdministrationTest.java $
003: * $Id: CourseManagementAdministrationTest.java 22338 2007-03-08 20:42:33Z jholtzman@berkeley.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.coursemanagement.test;
021:
022: import java.sql.Time;
023: import java.util.Date;
024: import java.util.HashSet;
025: import java.util.Set;
026:
027: import junit.framework.Assert;
028:
029: import org.apache.commons.logging.Log;
030: import org.apache.commons.logging.LogFactory;
031: import org.sakaiproject.coursemanagement.api.CanonicalCourse;
032: import org.sakaiproject.coursemanagement.api.CourseManagementAdministration;
033: import org.sakaiproject.coursemanagement.api.CourseManagementService;
034: import org.sakaiproject.coursemanagement.api.CourseOffering;
035: import org.sakaiproject.coursemanagement.api.Enrollment;
036: import org.sakaiproject.coursemanagement.api.Meeting;
037: import org.sakaiproject.coursemanagement.api.Membership;
038: import org.sakaiproject.coursemanagement.api.Section;
039: import org.sakaiproject.coursemanagement.api.exception.IdExistsException;
040: import org.sakaiproject.coursemanagement.api.exception.IdNotFoundException;
041: import org.sakaiproject.coursemanagement.impl.EnrollmentCmImpl;
042:
043: public class CourseManagementAdministrationTest extends
044: CourseManagementTestBase {
045: private static final Log log = LogFactory
046: .getLog(CourseManagementAdministrationTest.class);
047:
048: private CourseManagementService cm;
049: private CourseManagementAdministration cmAdmin;
050:
051: protected void onSetUpBeforeTransaction() throws Exception {
052: }
053:
054: protected void onSetUpInTransaction() throws Exception {
055: cm = (CourseManagementService) applicationContext
056: .getBean("org.sakaiproject.coursemanagement.api.CourseManagementService");
057: cmAdmin = (CourseManagementAdministration) applicationContext
058: .getBean("org.sakaiproject.coursemanagement.api.CourseManagementAdministration");
059: }
060:
061: public void testCreateAcademicSession() throws Exception {
062: cmAdmin.createAcademicSession("as1", "academic session 1",
063: "an academic session", new Date(), new Date());
064: Assert.assertTrue(cm.getAcademicSession("as1").getTitle()
065: .equals("academic session 1"));
066:
067: try {
068: cmAdmin.createAcademicSession("as1", "foo", "foo", null,
069: null);
070: fail();
071: } catch (IdExistsException ide) {
072: }
073: }
074:
075: public void testCreateCanonicalCourse() throws Exception {
076: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
077: Assert.assertTrue(cm.getCanonicalCourse("cc1").getTitle()
078: .equals("cc 1"));
079:
080: try {
081: cmAdmin.createCanonicalCourse("cc1",
082: "another canon course", "another canonical course");
083: fail();
084: } catch (IdExistsException ide) {
085: }
086: }
087:
088: public void testCreateCourseOffering() throws Exception {
089: cmAdmin.createAcademicSession("as1", "academic session 1",
090: "an academic session", new Date(), new Date());
091: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
092: cmAdmin.createCourseOffering("co1", "co 1",
093: "a course offering", "open", "as1", "cc1", null, null);
094: Assert.assertTrue(cm.getCourseOffering("co1").getTitle()
095: .equals("co 1"));
096:
097: try {
098: cmAdmin.createCourseOffering("co1", "another course",
099: "another course", "open", "as1", "cc1", null, null);
100: fail();
101: } catch (IdExistsException ide) {
102: }
103: }
104:
105: public void testCreateCourseSet() throws Exception {
106: cmAdmin.createCourseSet("cs1", "set 1", "a course set", null,
107: null);
108: Assert.assertTrue(cm.getCourseSet("cs1").getTitle().equals(
109: "set 1"));
110:
111: try {
112: cmAdmin.createCourseSet("cs1", "another set 1",
113: "another cset", null, null);
114: fail();
115: } catch (IdExistsException ide) {
116: }
117: }
118:
119: public void testAddCanonicalCourseToCourseSet() throws Exception {
120: cmAdmin.createCourseSet("cs1", "course set", "course set",
121: null, null);
122: cmAdmin.createCanonicalCourse("cc1", "canon course 1",
123: "canon course");
124: cmAdmin.addCanonicalCourseToCourseSet("cs1", "cc1");
125: CanonicalCourse cc = cm.getCanonicalCourse("cc1");
126: Assert.assertTrue(cm.getCanonicalCourses("cs1").contains(cc));
127: }
128:
129: public void testRemoveCanonicalCourseFromCourseSet()
130: throws Exception {
131: cmAdmin.createCourseSet("cs1", "course set", "course set",
132: null, null);
133: cmAdmin.createCanonicalCourse("cc1", "canon course 1",
134: "canon course");
135: cmAdmin.addCanonicalCourseToCourseSet("cs1", "cc1");
136: cmAdmin.removeCanonicalCourseFromCourseSet("cs1", "cc1");
137: CanonicalCourse cc = cm.getCanonicalCourse("cc1");
138: Assert.assertFalse(cm.getCanonicalCourses("cs1").contains(cc));
139: }
140:
141: public void testAddCourseOfferingToCourseSet() throws Exception {
142: cmAdmin.createCourseSet("cs1", "course set", "course set",
143: null, null);
144: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
145: cmAdmin.createAcademicSession("as1", "academic session 1",
146: "an academic session", new Date(), new Date());
147: cmAdmin.createCourseOffering("co1", "course 1", "course",
148: "open", "as1", "cc1", null, null);
149: cmAdmin.addCourseOfferingToCourseSet("cs1", "co1");
150: CourseOffering co = cm.getCourseOffering("co1");
151: Assert.assertTrue(cm.getCourseOfferingsInCourseSet("cs1")
152: .contains(co));
153: }
154:
155: public void testRemoveCourseOfferingFromCourseSet()
156: throws Exception {
157: cmAdmin.createCourseSet("cs1", "course set", "course set",
158: null, null);
159: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
160: cmAdmin.createAcademicSession("as1", "academic session 1",
161: "an academic session", new Date(), new Date());
162: cmAdmin.createCourseOffering("co1", "course 1", "course",
163: "open", "as1", "cc1", null, null);
164: cmAdmin.addCourseOfferingToCourseSet("cs1", "co1");
165: cmAdmin.removeCourseOfferingFromCourseSet("cs1", "co1");
166: CourseOffering co = cm.getCourseOffering("co1");
167: Assert.assertFalse(cm.getCourseOfferingsInCourseSet("cs1")
168: .contains(co));
169: }
170:
171: public void testSetEquivalentCanonicalCourses() throws Exception {
172: // Create some courses
173: cmAdmin.createCanonicalCourse("cc1", "cc1", "cc1");
174: cmAdmin.createCanonicalCourse("cc2", "cc2", "cc2");
175: cmAdmin.createCanonicalCourse("cc3", "cc3", "cc3");
176:
177: // Add them to a set
178: Set courses = new HashSet();
179: courses.add(cm.getCanonicalCourse("cc1"));
180: courses.add(cm.getCanonicalCourse("cc2"));
181: courses.add(cm.getCanonicalCourse("cc3"));
182:
183: // Crosslist them
184: cmAdmin.setEquivalentCanonicalCourses(courses);
185:
186: // Ensure that CM sees them as crosslisted
187: Set equivalents = cm.getEquivalentCanonicalCourses("cc1");
188: Assert.assertTrue(equivalents.contains(cm
189: .getCanonicalCourse("cc2")));
190: Assert.assertTrue(equivalents.contains(cm
191: .getCanonicalCourse("cc3")));
192:
193: // Ensure that we can remove one of the equivalents
194: courses.remove(cm.getCanonicalCourse("cc3"));
195: cmAdmin.setEquivalentCanonicalCourses(courses);
196: equivalents = cm.getEquivalentCanonicalCourses("cc1");
197: Assert.assertTrue(equivalents.contains(cm
198: .getCanonicalCourse("cc2")));
199: Assert.assertFalse(equivalents.contains(cm
200: .getCanonicalCourse("cc3")));
201: }
202:
203: public void testRemoveEquivalencyCanonCourse() throws Exception {
204: // Create some courses
205: cmAdmin.createCanonicalCourse("cc1", "cc1", "cc1");
206: cmAdmin.createCanonicalCourse("cc2", "cc2", "cc2");
207: cmAdmin.createCanonicalCourse("cc3", "cc3", "cc3");
208:
209: // Add them to a set
210: Set courses = new HashSet();
211: courses.add(cm.getCanonicalCourse("cc1"));
212: courses.add(cm.getCanonicalCourse("cc2"));
213:
214: // Crosslist them
215: cmAdmin.setEquivalentCanonicalCourses(courses);
216:
217: // Remove a course that was crosslisted
218: Assert.assertTrue(cmAdmin.removeEquivalency(cm
219: .getCanonicalCourse("cc1")));
220:
221: // Remove one that wasn't crosslisted
222: Assert.assertFalse(cmAdmin.removeEquivalency(cm
223: .getCanonicalCourse("cc3")));
224: }
225:
226: public void testSetEquivalentCourseOfferings() throws Exception {
227: cmAdmin.createAcademicSession("as1", "academic session 1",
228: "an academic session", new Date(), new Date());
229: cmAdmin.createAcademicSession("as2", "academic session 2",
230: "another academic session", new Date(), new Date());
231: cmAdmin.createCanonicalCourse("cc1", "cc1", "cc1");
232: cmAdmin.createCourseOffering("co1", "co1", "co1", "", "as1",
233: "cc1", null, null);
234: cmAdmin.createCourseOffering("co2", "co2", "co2", "", "as2",
235: "cc1", null, null);
236:
237: // Add them to a set
238: Set<CourseOffering> courses = new HashSet<CourseOffering>();
239: courses.add(cm.getCourseOffering("co1"));
240: courses.add(cm.getCourseOffering("co2"));
241:
242: // Crosslist them
243: cmAdmin.setEquivalentCourseOfferings(courses);
244:
245: // Ensure that CM sees them as crosslisted
246: Set equivalents = cm.getEquivalentCourseOfferings("co1");
247: Assert.assertTrue(equivalents.contains(cm
248: .getCourseOffering("co2")));
249: }
250:
251: public void testCreateEnrollmentSet() throws Exception {
252: cmAdmin.createAcademicSession("as1", "academic session 1",
253: "an academic session", new Date(), new Date());
254: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
255: cmAdmin.createCourseOffering("co1", "course 1", "course",
256: "open", "as1", "cc1", null, null);
257: cmAdmin.createEnrollmentSet("es1", "enr set 1", "an enr set",
258: "lecture", "3", "co1", null);
259: Assert.assertTrue(cm.getEnrollmentSet("es1").getTitle().equals(
260: "enr set 1"));
261:
262: try {
263: cmAdmin.createEnrollmentSet("es1", "enr set 1",
264: "an enr set", "lecture", "3", "co1", null);
265: fail();
266: } catch (IdExistsException ide) {
267: }
268: }
269:
270: public void testAddEnrollment() throws Exception {
271: // Create the EnrollmentSet
272: cmAdmin.createAcademicSession("as1", "academic session 1",
273: "an academic session", new Date(), new Date());
274: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
275: cmAdmin.createCourseOffering("co1", "course 1", "course",
276: "open", "as1", "cc1", null, null);
277: cmAdmin.createEnrollmentSet("es1", "enr set 1", "an enr set",
278: "lecture", "3", "co1", null);
279:
280: // Add an enrollment
281: cmAdmin.addOrUpdateEnrollment("josh", "es1", "enrolled", "4",
282: "pass/fail");
283:
284: // Ensure that the enrollment exists
285: Assert.assertNotNull(cm.findEnrollment("josh", "es1"));
286: }
287:
288: public void testUpdateEnrollment() throws Exception {
289: // Create the EnrollmentSet
290: cmAdmin.createAcademicSession("as1", "academic session 1",
291: "an academic session", new Date(), new Date());
292: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
293: cmAdmin.createCourseOffering("co1", "course 1", "course",
294: "open", "as1", "cc1", null, null);
295: cmAdmin.createEnrollmentSet("es1", "enr set 1", "an enr set",
296: "lecture", "3", "co1", null);
297:
298: // Add an enrollment
299: cmAdmin.addOrUpdateEnrollment("josh", "es1", "enrolled", "4",
300: "pass/fail");
301:
302: // Update the enrollment
303: cmAdmin.addOrUpdateEnrollment("josh", "es1", "waitlisted", "3",
304: "lettter gradel");
305:
306: // Ensure that the enrollment has been updated
307: Assert.assertEquals("waitlisted", cm.findEnrollment("josh",
308: "es1").getEnrollmentStatus());
309: }
310:
311: public void testDropEnrollment() throws Exception {
312: // Create the EnrollmentSet
313: cmAdmin.createAcademicSession("as1", "academic session 1",
314: "an academic session", new Date(), new Date());
315: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
316: cmAdmin.createCourseOffering("co1", "course 1", "course",
317: "open", "as1", "cc1", null, null);
318: cmAdmin.createEnrollmentSet("es1", "enr set 1", "an enr set",
319: "lecture", "3", "co1", null);
320:
321: // Add an enrollment
322: cmAdmin.addOrUpdateEnrollment("josh", "es1", "enrolled", "4",
323: "pass/fail");
324:
325: // Drop the enrollment
326: cmAdmin.removeEnrollment("josh", "es1");
327:
328: // Ensure that the enrollment has been dropped
329: Assert.assertTrue(((Enrollment) cm.getEnrollments("es1")
330: .iterator().next()).isDropped());
331:
332: // Add the same enrollment again
333: cmAdmin.addOrUpdateEnrollment("josh", "es1", "enrolled", "4",
334: "pass/fail");
335:
336: // Ensure that the hibernate version has been incremented
337: Assert.assertNotSame(new Integer(0), ((EnrollmentCmImpl) cm
338: .getEnrollments("es1").iterator().next()).getVersion());
339: }
340:
341: public void testAddCourseSetMembership() throws Exception {
342: // Create a course set
343: cmAdmin.createCourseSet("cs1", "cs1", "cs1", null, null);
344:
345: // Create a membership in the courseSet
346: cmAdmin.addOrUpdateCourseSetMembership("josh", "student",
347: "cs1", "active");
348:
349: // Ensure that the membership was added
350: Assert
351: .assertEquals(1, cm.getCourseSetMemberships("cs1")
352: .size());
353:
354: // Add the same username, this time with a different role
355: cmAdmin.addOrUpdateCourseSetMembership("josh", "ta", "cs1",
356: "active");
357:
358: // Ensure that the membership was updated, not added
359: Assert
360: .assertEquals(1, cm.getCourseSetMemberships("cs1")
361: .size());
362: Assert.assertEquals("ta", ((Membership) cm
363: .getCourseSetMemberships("cs1").iterator().next())
364: .getRole());
365: }
366:
367: public void testRemoveCourseSetMembers() throws Exception {
368: // Create a course set
369: cmAdmin.createCourseSet("cs1", "cs1", "cs1", null, null);
370:
371: // Create a membership in the courseSet
372: cmAdmin.addOrUpdateCourseSetMembership("josh", "student",
373: "cs1", "active");
374:
375: // Remove the membership (should return true)
376: Assert.assertTrue(cmAdmin.removeCourseSetMembership("josh",
377: "cs1"));
378:
379: // Try to remove it again (should return false)
380: Assert.assertFalse(cmAdmin.removeCourseSetMembership("josh",
381: "cs1"));
382: }
383:
384: public void testAddCourseOfferingMembership() throws Exception {
385: // Create a course offering
386: cmAdmin.createAcademicSession("as1", "academic session 1",
387: "an academic session", new Date(), new Date());
388: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
389: cmAdmin.createCourseOffering("co1", "course 1", "course",
390: "open", "as1", "cc1", null, null);
391:
392: // Create a membership in the courseOffering
393: cmAdmin.addOrUpdateCourseOfferingMembership("josh", "student",
394: "co1", "active");
395:
396: // Ensure that the membership was added
397: Assert.assertEquals(1, cm.getCourseOfferingMemberships("co1")
398: .size());
399:
400: // Add the same username, this time with a different role
401: cmAdmin.addOrUpdateCourseOfferingMembership("josh", "ta",
402: "co1", "active");
403:
404: // Ensure that the membership was updated, not added
405: Assert.assertEquals(1, cm.getCourseOfferingMemberships("co1")
406: .size());
407: Assert.assertEquals("ta", ((Membership) cm
408: .getCourseOfferingMemberships("co1").iterator().next())
409: .getRole());
410: }
411:
412: public void testRemoveCourseOfferingMembers() throws Exception {
413: // Create a course offering
414: cmAdmin.createAcademicSession("as1", "academic session 1",
415: "an academic session", new Date(), new Date());
416: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
417: cmAdmin.createCourseOffering("co1", "course 1", "course",
418: "open", "as1", "cc1", null, null);
419:
420: // Create a membership in the courseOffering
421: cmAdmin.addOrUpdateCourseOfferingMembership("josh", "student",
422: "co1", "active");
423:
424: // Remove the membership (should return true)
425: Assert.assertTrue(cmAdmin.removeCourseOfferingMembership(
426: "josh", "co1"));
427:
428: // Try to remove it again (should return false)
429: Assert.assertFalse(cmAdmin.removeCourseOfferingMembership(
430: "josh", "co1"));
431: }
432:
433: public void testCreateSection() throws Exception {
434: // Create a course offering
435: cmAdmin.createAcademicSession("as1", "academic session 1",
436: "an academic session", new Date(), new Date());
437: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
438: cmAdmin.createCourseOffering("co1", "course 1", "course",
439: "open", "as1", "cc1", null, null);
440:
441: cmAdmin.createSection("sec1", "sec 1", "a sec", "lecture",
442: null, "co1", null);
443: Assert.assertTrue(cm.getSection("sec1").getTitle().equals(
444: "sec 1"));
445:
446: try {
447: cmAdmin.createSection("sec1", "sec 1", "a sec", "lecture",
448: null, null, null);
449: fail();
450: } catch (IdExistsException ide) {
451: }
452: }
453:
454: public void testAddSectionMembership() throws Exception {
455: // Create a course offering
456: cmAdmin.createAcademicSession("as1", "academic session 1",
457: "an academic session", new Date(), new Date());
458: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
459: cmAdmin.createCourseOffering("co1", "course 1", "course",
460: "open", "as1", "cc1", null, null);
461:
462: // Add a section
463: cmAdmin.createSection("sec1", "sec1", "sec1", "sec1", null,
464: "co1", null);
465:
466: // Create a membership in the section
467: cmAdmin.addOrUpdateSectionMembership("josh", "student", "sec1",
468: "active");
469:
470: // Ensure that the membership was added
471: Assert.assertEquals(1, cm.getSectionMemberships("sec1").size());
472:
473: // Add the same username, this time with a different role
474: cmAdmin.addOrUpdateSectionMembership("josh", "ta", "sec1",
475: "active");
476:
477: // Ensure that the membership was updated, not added
478: Assert.assertEquals(1, cm.getSectionMemberships("sec1").size());
479: Assert.assertEquals("ta", ((Membership) cm
480: .getSectionMemberships("sec1").iterator().next())
481: .getRole());
482: }
483:
484: public void testRemoveSectionMembers() throws Exception {
485: // Create a course offering
486: cmAdmin.createAcademicSession("as1", "academic session 1",
487: "an academic session", new Date(), new Date());
488: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
489: cmAdmin.createCourseOffering("co1", "course 1", "course",
490: "open", "as1", "cc1", null, null);
491:
492: // Add a section
493: cmAdmin.createSection("sec1", "sec1", "sec1", "sec1", null,
494: "co1", null);
495:
496: // Create a membership in the section
497: cmAdmin.addOrUpdateSectionMembership("josh", "student", "sec1",
498: "active");
499:
500: // Remove the membership (should return true)
501: Assert.assertTrue(cmAdmin.removeSectionMembership("josh",
502: "sec1"));
503:
504: // Try to remove it again (should return false)
505: Assert.assertFalse(cmAdmin.removeSectionMembership("josh",
506: "sec1"));
507: }
508:
509: public void testMeetingCascading() throws Exception {
510: // Create a course offering
511: cmAdmin.createAcademicSession("as1", "academic session 1",
512: "an academic session", new Date(), new Date());
513: cmAdmin.createCanonicalCourse("cc1", "cc 1", "a canon course");
514: cmAdmin.createCourseOffering("co1", "course 1", "course",
515: "open", "as1", "cc1", null, null);
516:
517: // Add a section
518: Section section1 = cmAdmin.createSection("sec1", "sec1",
519: "sec1", "sec1", null, "co1", null);
520:
521: // Add some meetings for the section
522: Meeting meeting1 = cmAdmin.newSectionMeeting("sec1",
523: "a lecture hall", new Time(new Date().getTime()),
524: new Time(new Date().getTime()),
525: "If you're late, I won't let you in.");
526: section1.getMeetings().add(meeting1);
527:
528: // Update the section
529: cmAdmin.updateSection(section1);
530:
531: // Ensure that the section has the right meetings
532: Section section2 = cm.getSection("sec1");
533: Assert.assertEquals(1, section2.getMeetings().size());
534: Assert.assertEquals("a lecture hall", ((Meeting) section2
535: .getMeetings().iterator().next()).getLocation());
536: }
537:
538: public void testRemoveAcademicSession() throws Exception {
539: cmAdmin.createAcademicSession("foo", "foo", "foo", null, null);
540:
541: // Ensure that the service can find the new AS
542: Assert.assertEquals("foo", cm.getAcademicSession("foo")
543: .getTitle());
544:
545: // Remove the AS, and ensure that the service can no longer access it
546: cmAdmin.removeAcademicSession("foo");
547: try {
548: cm.getAcademicSession("foo");
549: fail();
550: } catch (IdNotFoundException ide) {
551: }
552: }
553:
554: public void testRemoveEnrollmentSet() throws Exception {
555: cmAdmin.createAcademicSession("as", "as", "as", null, null);
556: cmAdmin.createCanonicalCourse("cc", "cc", "cc");
557: cmAdmin.createCourseOffering("co", "co", "co", "co", "as",
558: "cc", null, null);
559: cmAdmin.createEnrollmentSet("es", "es", "es", "es", "es", "co",
560: null);
561: cmAdmin.addOrUpdateEnrollment("student1", "es", "enrolled",
562: "4", "letter grade");
563:
564: // Remove the ES
565: cmAdmin.removeEnrollmentSet("es");
566:
567: // Ensure that the enrollment was deleted as well
568: Assert.assertEquals(0, cm.getEnrollments("es").size());
569:
570: // Ensure that the CM service can no longer find the ES
571: try {
572: cm.getEnrollmentSet("es");
573: fail();
574: } catch (IdNotFoundException ide) {
575: }
576:
577: }
578:
579: public void testRemoveSection() throws Exception {
580: cmAdmin.createAcademicSession("as", "as", "as", null, null);
581: cmAdmin.createCanonicalCourse("cc", "cc", "cc");
582: cmAdmin.createCourseOffering("co", "co", "co", "co", "as",
583: "cc", null, null);
584: cmAdmin.createSection("sec", "sec", "sec", "sec", null, "co",
585: null);
586: cmAdmin.addOrUpdateSectionMembership("member1", "TA", "sec",
587: "active");
588:
589: // Remove the section
590: cmAdmin.removeSection("sec");
591:
592: // Ensure that the CM service can no longer find the section
593: try {
594: cm.getSection("sec");
595: fail();
596: } catch (IdNotFoundException ide) {
597: }
598:
599: // Ensure that the membership was deleted as well
600: try {
601: cm.getSectionMemberships("sec");
602: fail();
603: } catch (IdNotFoundException ide) {
604: }
605: }
606:
607: public void testRemoveCourseOffering() throws Exception {
608: cmAdmin.createAcademicSession("as", "as", "as", null, null);
609: cmAdmin.createCanonicalCourse("cc", "cc", "cc");
610: cmAdmin.createCourseOffering("co", "co", "co", "co", "as",
611: "cc", null, null);
612: cmAdmin.createEnrollmentSet("es", "es", "es", "es", "3", "co",
613: null);
614: cmAdmin.createSection("sec", "sec", "sec", "sec", null, "co",
615: "es");
616:
617: // Remove the CO
618: cmAdmin.removeCourseOffering("co");
619:
620: // Ensure that the CM service can no longer find the CO
621: try {
622: cm.getCourseOffering("co");
623: fail();
624: } catch (IdNotFoundException ide) {
625: }
626:
627: // Ensure that the ES was deleted as well
628: try {
629: cm.getEnrollmentSet("es");
630: fail();
631: } catch (IdNotFoundException ide) {
632: }
633:
634: // Ensure that the section was deleted as well
635: try {
636: cm.getSection("sec");
637: fail();
638: } catch (IdNotFoundException ide) {
639: }
640: }
641:
642: public void testRemoveCanonicalCourse() throws Exception {
643:
644: }
645:
646: public void testRemoveCourseSet() throws Exception {
647:
648: }
649:
650: }
|