View Javadoc

1   /**
2    * Copyright 2012 The Kuali Foundation
3    *
4    * Licensed under the the Educational Community License, Version 1.0
5    * (the "License"); you may not use this file except in compliance
6    * with the License.  You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.student.enrollment.class2.courseoffering.service.impl;
17  
18  import org.junit.After;
19  import org.junit.Assert;
20  import org.junit.Before;
21  import org.junit.Test;
22  import org.junit.runner.RunWith;
23  import org.kuali.student.common.test.spring.log4j.KSLog4JConfigurer;
24  import org.kuali.student.common.test.util.AttributeTester;
25  import org.kuali.student.common.test.util.ListOfStringTester;
26  import org.kuali.student.common.test.util.MetaTester;
27  import org.kuali.student.common.test.util.RichTextTester;
28  import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingClusterInfo;
29  import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
30  import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingSetInfo;
31  import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
32  import org.kuali.student.enrollment.courseoffering.dto.FormatOfferingInfo;
33  import org.kuali.student.enrollment.courseoffering.dto.OfferingInstructorInfo;
34  import org.kuali.student.enrollment.courseoffering.dto.RegistrationGroupInfo;
35  import org.kuali.student.enrollment.courseoffering.dto.SeatPoolDefinitionInfo;
36  import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
37  import org.kuali.student.r2.common.dto.AttributeInfo;
38  import org.kuali.student.r2.common.dto.BulkStatusInfo;
39  import org.kuali.student.r2.common.dto.ContextInfo;
40  import org.kuali.student.r2.common.dto.StatusInfo;
41  import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
42  import org.kuali.student.r2.common.exceptions.CircularRelationshipException;
43  import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
44  import org.kuali.student.r2.common.exceptions.DependentObjectsExistException;
45  import org.kuali.student.r2.common.exceptions.DoesNotExistException;
46  import org.kuali.student.r2.common.exceptions.InvalidParameterException;
47  import org.kuali.student.r2.common.exceptions.MissingParameterException;
48  import org.kuali.student.r2.common.exceptions.OperationFailedException;
49  import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
50  import org.kuali.student.r2.common.exceptions.ReadOnlyException;
51  import org.kuali.student.r2.common.exceptions.UnsupportedActionException;
52  import org.kuali.student.r2.common.exceptions.VersionMismatchException;
53  import org.kuali.student.r2.common.util.ContextUtils;
54  import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
55  import org.kuali.student.r2.common.util.constants.LprServiceConstants;
56  import org.kuali.student.r2.common.util.constants.LuServiceConstants;
57  import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
58  import org.kuali.student.r2.core.acal.service.AcademicCalendarService;
59  import org.kuali.student.r2.core.atp.service.AtpService;
60  import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
61  import org.kuali.student.r2.core.constants.AtpServiceConstants;
62  import org.kuali.student.r2.lum.course.dto.CourseInfo;
63  import org.kuali.student.r2.lum.course.service.CourseService;
64  import org.slf4j.Logger;
65  import org.springframework.test.context.ContextConfiguration;
66  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
67  
68  import javax.annotation.Resource;
69  import java.util.ArrayList;
70  import java.util.Arrays;
71  import java.util.Collections;
72  import java.util.List;
73  
74  import static org.junit.Assert.assertEquals;
75  import static org.junit.Assert.assertNotNull;
76  import static org.junit.Assert.assertNull;
77  import static org.junit.Assert.assertTrue;
78  import static org.junit.Assert.fail;
79  
80  /**
81   * @author ocleirig
82   *         <p/>
83   *         This is a set of unit test cases that runs directly against a mock
84   *         implementation of the class 2 course offering service.
85   */
86  @RunWith(SpringJUnit4ClassRunner.class)
87  @ContextConfiguration(locations = {"classpath:co-test-with-class2-mock-context.xml"})
88  public class TestCourseOfferingServiceImplWithClass2Mocks {
89  
90      private static final Logger log = KSLog4JConfigurer
91              .getLogger(TestCourseOfferingServiceImplWithClass2Mocks.class);
92  
93      @Resource(name = "CourseOfferingService")
94      protected CourseOfferingService coService;
95  
96      @Resource
97      protected AcademicCalendarService acalService;
98  
99      @Resource
100     protected AtpService atpService;
101 
102     @Resource
103     protected CourseService canonicalCourseService;
104 
105     @Resource
106     protected CourseOfferingServiceTestDataLoader dataLoader;
107 
108     private final boolean testAwareDataLoader;
109 
110     /**
111      *
112      */
113     public TestCourseOfferingServiceImplWithClass2Mocks() {
114         this(true);
115     }
116 
117 
118     protected TestCourseOfferingServiceImplWithClass2Mocks(boolean testAwareDataLoader) {
119         this.testAwareDataLoader = testAwareDataLoader;
120 
121     }
122 
123 
124   
125 
126     public static String principalId = "123";
127     public ContextInfo callContext = null;
128 
129     @Before
130     public void setup() throws Exception {
131 
132         callContext = new ContextInfo();
133         callContext.setPrincipalId(principalId);
134 
135 
136 
137         if (testAwareDataLoader || !dataLoader.isInitialized()) {
138             dataLoader.beforeTest();
139             
140         }
141 
142     }
143 
144 
145     @After
146     public void tearDown() throws Exception {
147         if (testAwareDataLoader)
148             dataLoader.afterTest();
149     }
150 
151     @Test
152     public void testCreateAndGetRegistrationGroup()
153             throws AlreadyExistsException, DoesNotExistException,
154             DataValidationErrorException, InvalidParameterException,
155             MissingParameterException, OperationFailedException,
156             PermissionDeniedException {
157         List<String> activityOfferingIds = new ArrayList<String>();
158 
159         activityOfferingIds.add("CO-1:LEC-ONLY:LEC-A");
160 
161         String formatOfferingId = "CO-1:LEC-ONLY";
162 
163         String activityOfferingClusterId = "fake-aoc-id";
164 
165         RegistrationGroupInfo rgLecA = CourseOfferingServiceTestDataUtils
166                 .createRegistrationGroup("CO-1", formatOfferingId, "2012FA",
167                         activityOfferingClusterId, activityOfferingIds, "RG-1", "RG-1", true, true,
168                         10, LuiServiceConstants.REGISTRATION_GROUP_OFFERED_STATE_KEY);
169 
170         try {
171             RegistrationGroupInfo created = coService.createRegistrationGroup(
172                     formatOfferingId, activityOfferingClusterId,
173                     LuiServiceConstants.REGISTRATION_GROUP_TYPE_KEY, rgLecA,
174                     callContext);
175             assertNotNull(created);
176 
177             RegistrationGroupInfo retrieved = coService.getRegistrationGroup(
178                     created.getId(), callContext);
179             assertNotNull(retrieved);
180 
181             assertEquals(rgLecA.getFormatOfferingId(),
182                     retrieved.getFormatOfferingId());
183             assertEquals(rgLecA.getActivityOfferingClusterId(), retrieved.getActivityOfferingClusterId());
184             assertEquals(rgLecA.getName(), retrieved.getName());
185             assertEquals(rgLecA.getStateKey(), retrieved.getStateKey());
186             assertEquals(rgLecA.getTypeKey(), retrieved.getTypeKey());
187 
188             // test getRegistrationGroupsForCourseOffering
189 
190         } catch (Exception ex) {
191             log.error("failed from service call:", ex);
192 
193             fail("Exception from service call :" + ex.getMessage());
194         }
195     }
196 
197 
198     @Test
199     public void testActivityOfferingClusters() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException, ReadOnlyException {
200 
201         // default cluster is 2x3 = 6 reg groups
202 
203         // we want to constrain to not use lec-b
204         // 1x3 = 3 reg groups
205 
206         ActivityOfferingInfo activities[] = new ActivityOfferingInfo[]{
207                 coService.getActivityOffering("CO-1:LEC-AND-LAB:LEC-A",
208                         callContext),
209                 coService.getActivityOffering("CO-1:LEC-AND-LAB:LAB-A",
210                         callContext),
211                 coService.getActivityOffering("CO-1:LEC-AND-LAB:LAB-B",
212                         callContext),
213                 coService.getActivityOffering("CO-1:LEC-AND-LAB:LAB-C",
214                         callContext),};
215 
216         ActivityOfferingClusterInfo expected = CourseOfferingServiceTestDataUtils
217                 .createActivityOfferingCluster("CO-1:LEC-AND-LAB", "Default Cluster",
218                         Arrays.asList(activities));
219 
220         expected.setId("AOC-1");
221         new AttributeTester().add2ForCreate(expected.getAttributes());
222 
223         ActivityOfferingClusterInfo actual = coService.createActivityOfferingCluster("CO-1:LEC-AND-LAB", CourseOfferingServiceConstants.AOC_ROOT_TYPE_KEY, expected, callContext);
224 
225         validateAoc(actual, expected, activities);
226 
227         expected = actual;
228         actual = coService.getActivityOfferingCluster(expected.getId(), callContext);
229 
230         validateAoc(actual, expected, activities);
231 
232         List<String> aocIds = new ArrayList<String>();
233         aocIds.add(actual.getId());
234         List<String> aocIdsTwo = coService.getActivityOfferingClustersIdsByFormatOffering("CO-2:LEC-ONLY", callContext);
235         aocIds.addAll(aocIdsTwo);
236         List<ActivityOfferingClusterInfo> aocList = coService.getActivityOfferingClustersByIds(aocIds, callContext);
237         assertEquals(2, aocList.size());
238         assertTrue(aocList.get(0).getId().equals(aocIds.get(0)) || aocList.get(1).getId().equals(aocIds.get(0)));
239         assertTrue(aocList.get(0).getId().equals(aocIds.get(1)) || aocList.get(1).getId().equals(aocIds.get(1)));
240 
241         List<RegistrationGroupInfo> rgList = coService.getRegistrationGroupsByActivityOfferingCluster(actual.getId(), callContext);
242 
243         assertEquals(0, rgList.size());
244 
245         coService.generateRegistrationGroupsForCluster(actual.getId(), callContext);
246 
247         rgList = coService.getRegistrationGroupsByActivityOfferingCluster(actual.getId(), callContext);
248 
249         assertEquals(3, rgList.size());
250 
251         coService.generateRegistrationGroupsForCluster(actual.getId(), callContext);
252 
253         // verify count stays the same even after calling the method again.
254         rgList = coService.getRegistrationGroupsByActivityOfferingCluster(actual.getId(), callContext);
255 
256         assertEquals(3, rgList.size());
257     }
258 
259     private void validateAoc(ActivityOfferingClusterInfo actual, ActivityOfferingClusterInfo expected, ActivityOfferingInfo... activities) {
260         assertNotNull(actual.getId());
261         assertEquals(expected.getId(), actual.getId());
262         assertEquals(expected.getTypeKey(), actual.getTypeKey());
263         assertEquals(expected.getStateKey(), actual.getStateKey());
264         assertEquals(expected.getFormatOfferingId(), actual.getFormatOfferingId());
265         assertEquals(expected.getPrivateName(), actual.getPrivateName());
266         assertEquals(expected.getName(), actual.getName());
267 
268         new AttributeTester().check(expected.getAttributes(), actual.getAttributes());
269         new MetaTester().checkAfterCreate(actual.getMeta());
270         new RichTextTester().check(expected.getDescr(), actual.getDescr());
271 
272         // check that the union of activity id's matches what we declared
273         assertEquals(expected.getActivityOfferingSets().size(), actual.getActivityOfferingSets().size());
274         List<String> activityIds = new ArrayList<String>();
275         for(ActivityOfferingInfo info : activities) {
276             activityIds.add(info.getId());
277         }
278 
279         new ListOfStringTester().checkExistsAnyOrder(activityIds, extractActivityOfferingIds(actual.getActivityOfferingSets()), true);
280     }
281 
282     private List<String> extractActivityOfferingIds(List<ActivityOfferingSetInfo> aoList) {
283         List<String> idList = new ArrayList<String>();
284 
285         for (ActivityOfferingSetInfo activityOfferingSetInfo : aoList) {
286 
287             idList.addAll(activityOfferingSetInfo.getActivityOfferingIds());
288 
289         }
290         return idList;
291     }
292 
293 
294     private ActivityOfferingClusterInfo createDefaultActivityOfferingCluster(String formatOfferingId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException, ReadOnlyException {
295 
296         List<ActivityOfferingInfo> activities = coService.getActivityOfferingsByFormatOffering(formatOfferingId, callContext);
297 
298         ActivityOfferingClusterInfo defaultAoc = CourseOfferingServiceTestDataUtils.createActivityOfferingCluster(formatOfferingId, "Default Cluster", activities);
299 
300         defaultAoc = coService.createActivityOfferingCluster(formatOfferingId, CourseOfferingServiceConstants.AOC_ROOT_TYPE_KEY, defaultAoc, callContext);
301 
302         Assert.assertNotNull(defaultAoc.getId());
303 
304         return defaultAoc;
305     }
306 
307     @Test
308     public void testGenerateRegistrationGroupsSimple() throws DoesNotExistException,
309             InvalidParameterException, MissingParameterException,
310             OperationFailedException, PermissionDeniedException, AlreadyExistsException, DataValidationErrorException, ReadOnlyException {
311 
312         String formatOfferingId = "CO-1:LEC-AND-LAB";
313 
314         createDefaultActivityOfferingCluster(formatOfferingId);
315 
316         List<BulkStatusInfo> status = coService
317                 .generateRegistrationGroupsForFormatOffering(
318                         formatOfferingId, callContext);
319 
320         Assert.assertNotNull(status);
321         Assert.assertEquals(6, status.size());
322 
323         List<RegistrationGroupInfo> rgList = coService.getRegistrationGroupsByFormatOffering("CO-1:LEC-AND-LAB", callContext);
324 
325         Assert.assertEquals(6, rgList.size());
326 
327     }
328 
329     @Test
330     public void testGenerateAndDeleteRegistrationGroups() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException, ReadOnlyException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException, AlreadyExistsException, DependentObjectsExistException {
331 
332         ActivityOfferingClusterInfo cluster = createDefaultActivityOfferingCluster("CO-1:LEC-AND-LAB");
333 
334         List<RegistrationGroupInfo> rgList = coService.getRegistrationGroupsForCourseOffering("CO-1", callContext);
335 
336         assertEquals(0, rgList.size());
337 
338         List<BulkStatusInfo> status = coService
339                 .generateRegistrationGroupsForFormatOffering(
340                         "CO-1:LEC-AND-LAB", callContext);
341 
342 
343         Assert.assertNotNull(status);
344         Assert.assertEquals(6, status.size());
345 
346         rgList = coService.getRegistrationGroupsByFormatOffering("CO-1:LEC-AND-LAB", callContext);
347 
348         Assert.assertEquals(6, rgList.size());
349 
350         // this is harder so for now just skip
351 
352 //		FormatOfferingInfo fo = coService.getFormatOffering("CO-1:LEC-AND-LAB", callContext);
353 //		
354 //		fo.getActivityOfferingTypeKeys().add(LuiServiceConstants.DISCUSSION_ACTIVITY_OFFERING_TYPE_KEY);
355 //		
356 //		coService.updateFormatOffering(fo.getId(), fo, callContext);
357 
358         List<ActivityOfferingInfo> ao = coService.getActivityOfferingsByFormatOffering("CO-1:LEC-AND-LAB", callContext);
359 
360         Assert.assertEquals(5, ao.size());
361 
362         dataLoader.createLabActivityOfferingForCHEM123("LAB-F", callContext);
363 
364         ao = coService.getActivityOfferingsByFormatOffering("CO-1:LEC-AND-LAB", callContext);
365 
366         Assert.assertEquals(6, ao.size());
367 
368         status = coService
369                     .generateRegistrationGroupsForFormatOffering(
370                             "CO-1:LEC-AND-LAB", callContext);
371 
372         ao = coService.getActivityOfferingsByFormatOffering("CO-1:LEC-AND-LAB", callContext);
373 
374         // should stay the same size.
375         Assert.assertEquals(6, ao.size());
376 
377         status = coService.deleteGeneratedRegistrationGroupsByFormatOffering("CO-1:LEC-AND-LAB", callContext);
378 
379         assertTrue("Failed to delete existing generated registration groups", status.size() > 0);
380 
381         status = coService
382                 .generateRegistrationGroupsForFormatOffering(
383                         "CO-1:LEC-AND-LAB", callContext);
384 
385         rgList = coService.getRegistrationGroupsByFormatOffering("CO-1:LEC-AND-LAB", callContext);
386 
387         Assert.assertEquals(6, rgList.size());
388 
389         // in order to get 8 we need to assign the new AO into the default cluster
390 
391         // or just delete the existing default cluster and recreate it.
392 
393         coService.deleteRegistrationGroupsForCluster(cluster.getId(), callContext);
394         coService.deleteActivityOfferingCluster(cluster.getId(), callContext);
395 
396         createDefaultActivityOfferingCluster("CO-1:LEC-AND-LAB");
397 
398         coService.generateRegistrationGroupsForFormatOffering("CO-1:LEC-AND-LAB", callContext);
399 
400         rgList = coService.getRegistrationGroupsByFormatOffering("CO-1:LEC-AND-LAB", callContext);
401 
402         Assert.assertEquals(8, rgList.size());
403 
404 
405     }
406 
407     @Test
408     public void testServiceSetup() {
409         assertNotNull(coService);
410     }
411 
412     /**
413      * **********************************************************************
414      * COURSE TESTS ***********************************************************************
415      */
416     @Test
417     public void testGetCourseOffering() throws DoesNotExistException,
418             InvalidParameterException, MissingParameterException,
419             OperationFailedException, PermissionDeniedException {
420         try {
421             try {
422                 coService.getCourseOffering("Lui-blah", callContext);
423                 fail("Lui-blah should have thrown DoesNotExistException");
424             } catch (DoesNotExistException enee) {
425                 // expected
426             }
427 
428             CourseOfferingInfo co = coService.getCourseOffering("CO-1",
429                     callContext);
430             assertNotNull(co);
431             assertEquals(LuiServiceConstants.COURSE_OFFERING_LIFECYCLE_STATE_KEYS[0],
432                     co.getStateKey());
433             assertEquals(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY,
434                     co.getTypeKey());
435         } catch (Exception ex) {
436             fail(ex.getMessage());
437         }
438     }
439 
440     @Test
441     public void testGetCourseOfferingIdsByTerm() throws DoesNotExistException,
442             InvalidParameterException, MissingParameterException,
443             OperationFailedException, PermissionDeniedException {
444         List<String> offerings = coService.getCourseOfferingIdsByTerm(
445                 "TermId-blah", true, callContext);
446 
447         assertEquals(0, offerings.size());
448 
449         List<String> idList = coService.getCourseOfferingIdsByTerm("2012FA",
450                 true, callContext);
451         assertTrue(idList.size() > 0);
452     }
453 
454     @Test
455     public void testGetCourseOfferingsByIds() throws DoesNotExistException,
456             InvalidParameterException, MissingParameterException,
457             OperationFailedException, PermissionDeniedException {
458         List<String> idsList = new ArrayList<String>();
459         idsList.add("test1");
460         idsList.add("test2");
461         idsList.add("test3");
462 
463         try {
464             try {
465                 coService.getCourseOfferingsByIds(idsList, callContext);
466                 fail("idsList should have thrown DoesNotExistException");
467             } catch (DoesNotExistException enee) {
468                 // expected
469             }
470 
471             idsList.clear();
472 
473             idsList.add("CO-1");
474             idsList.add("CO-2");
475 
476             List<CourseOfferingInfo> co = coService.getCourseOfferingsByIds(
477                     idsList, callContext);
478 
479             assertNotNull(co);
480             for (CourseOfferingInfo coItem : co) {
481                 assertEquals(LuiServiceConstants.COURSE_OFFERING_LIFECYCLE_STATE_KEYS[0],
482                         coItem.getStateKey());
483                 assertEquals(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY,
484                         coItem.getTypeKey());
485             }
486         } catch (Exception ex) {
487             fail(ex.getMessage());
488         }
489     }
490 
491     @Test
492     public void testGetCourseOfferingsByCourseAndTerm()
493             throws DoesNotExistException, InvalidParameterException,
494             MissingParameterException, OperationFailedException,
495             PermissionDeniedException {
496         try {
497             List<CourseOfferingInfo> offerings = coService
498                     .getCourseOfferingsByCourseAndTerm("Lui-blah",
499                             "TermId-blah", callContext);
500 
501             assertEquals(0, offerings.size());
502 
503             List<CourseOfferingInfo> co = coService
504                     .getCourseOfferingsByCourseAndTerm("CLU-1", "2012FA",
505                             callContext);
506             assertTrue(co.size() > 0);
507 
508             for (CourseOfferingInfo coItem : co) {
509                 assertEquals(LuiServiceConstants.COURSE_OFFERING_LIFECYCLE_STATE_KEYS[0],
510                         coItem.getStateKey());
511                 assertEquals(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY,
512                         coItem.getTypeKey());
513             }
514         } catch (Exception ex) {
515             fail(ex.getMessage());
516         }
517     }
518 
519     @Test
520     public void testCreateCourseOffering() throws AlreadyExistsException,
521             DoesNotExistException, DataValidationErrorException,
522             InvalidParameterException, MissingParameterException,
523             OperationFailedException, PermissionDeniedException,
524             ReadOnlyException,
525             DoesNotExistException,
526             InvalidParameterException,
527             MissingParameterException,
528             OperationFailedException,
529             PermissionDeniedException,
530             AlreadyExistsException,  VersionMismatchException, CircularRelationshipException, DependentObjectsExistException, UnsupportedActionException, DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException
531     {
532 
533         String courseId = dataLoader.createCourse(dataLoader.getFall2012(),"MATH", "123", callContext);
534 
535         List<CourseOfferingInfo> offerings = coService
536                 .getCourseOfferingsByCourse(courseId, callContext);
537 
538         int expectedOfferings = offerings.size() + 1;
539 
540         List<String> optionKeys = new ArrayList<String>();
541         CourseInfo canonicalCourse = this.canonicalCourseService
542                 .getCourse(courseId, ContextUtils.getContextInfo());
543         CourseOfferingInfo coInfo = CourseOfferingServiceTestDataUtils
544                 .createCourseOffering(canonicalCourse, "2012FA");
545 
546         CourseOfferingInfo created = coService.createCourseOffering(courseId,
547                 "2012FA", LuiServiceConstants.COURSE_OFFERING_TYPE_KEY, coInfo,
548                 optionKeys, callContext);
549 
550         assertNotNull(created);
551         assertEquals("MATH123-ID", created.getCourseId());
552         assertEquals("2012FA", created.getTermId());
553         assertEquals(LuiServiceConstants.COURSE_OFFERING_LIFECYCLE_STATE_KEYS[0],
554                 created.getStateKey());
555         assertEquals(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY,
556                 created.getTypeKey());
557         assertEquals("MATH123", created.getCourseOfferingCode());
558         assertEquals("MATH MATH123", created.getCourseOfferingTitle());
559 
560         CourseOfferingInfo retrieved = coService.getCourseOffering(
561                 created.getId(), callContext);
562         assertNotNull(retrieved);
563         assertEquals("MATH123-ID", retrieved.getCourseId());
564         assertEquals("2012FA", retrieved.getTermId());
565         assertEquals(LuiServiceConstants.COURSE_OFFERING_LIFECYCLE_STATE_KEYS[0],
566                 retrieved.getStateKey());
567         assertEquals(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY,
568                 retrieved.getTypeKey());
569 
570         assertEquals("MATH123", retrieved.getCourseOfferingCode());
571         assertEquals("MATH MATH123", retrieved.getCourseOfferingTitle());
572 
573         offerings = coService.getCourseOfferingsByCourse("CLU-1", callContext);
574 
575         // we and maybe another test have added one
576         assertEquals(expectedOfferings, offerings.size());
577     }
578 
579     @Test
580     public void testUpdateCourseOffering() throws DataValidationErrorException,
581             DoesNotExistException, InvalidParameterException,
582             MissingParameterException, OperationFailedException,
583             PermissionDeniedException, ReadOnlyException,
584             VersionMismatchException {
585         try {
586             CourseOfferingInfo coi = coService.getCourseOffering("CO-2",
587                     callContext);
588             assertNotNull(coi);
589 
590             coi.setTermId("testAtpId1");
591             coi.setIsHonorsOffering(true);
592             coi.setMaximumEnrollment(40);
593             coi.setMinimumEnrollment(10);
594             List<OfferingInstructorInfo> instructors = new ArrayList<OfferingInstructorInfo>();
595             OfferingInstructorInfo instructor = new OfferingInstructorInfo();
596             instructor.setPersonId("Pers-1");
597             instructor.setPercentageEffort(Float.valueOf("60"));
598             instructor.setTypeKey(LprServiceConstants.INSTRUCTOR_MAIN_TYPE_KEY);
599             instructor.setStateKey(LprServiceConstants.ASSIGNED_STATE_KEY);
600             instructors.add(instructor);
601             coi.setInstructors(instructors);
602             CourseOfferingInfo updated = coService.updateCourseOffering("CO-2",
603                     coi, callContext);
604             assertNotNull(updated);
605 
606             CourseOfferingInfo retrieved = coService.getCourseOffering("CO-2",
607                     callContext);
608             assertNotNull(retrieved);
609 
610             assertTrue(retrieved.getIsHonorsOffering());
611             assertEquals(1, retrieved.getInstructors().size());
612             assertEquals(coi.getMaximumEnrollment(),
613                     retrieved.getMaximumEnrollment());
614             assertEquals(coi.getMinimumEnrollment(),
615                     retrieved.getMinimumEnrollment());
616 
617             retrieved.setIsHonorsOffering(false);
618             List<OfferingInstructorInfo> instructors1 = new ArrayList<OfferingInstructorInfo>();
619             OfferingInstructorInfo instructor1 = new OfferingInstructorInfo();
620             instructor1.setPersonId("Pers-2");
621             instructor1.setPercentageEffort(Float.valueOf("60"));
622             instructor1
623                     .setTypeKey(LprServiceConstants.INSTRUCTOR_MAIN_TYPE_KEY);
624             instructor1.setStateKey(LprServiceConstants.ASSIGNED_STATE_KEY);
625             instructors1.add(instructor1);
626             OfferingInstructorInfo instructor2 = new OfferingInstructorInfo();
627             instructor2.setPersonId("Pers-1");
628             instructor2.setPercentageEffort(Float.valueOf("30"));
629             instructor2
630                     .setTypeKey(LprServiceConstants.INSTRUCTOR_MAIN_TYPE_KEY);
631             instructor2.setStateKey(LprServiceConstants.ASSIGNED_STATE_KEY);
632             instructors1.add(instructor2);
633             retrieved.setInstructors(instructors1);
634             CourseOfferingInfo updated1 = coService.updateCourseOffering(
635                     "CO-2", retrieved, callContext);
636             assertNotNull(updated1);
637 
638             CourseOfferingInfo retrieved1 = coService.getCourseOffering("CO-2",
639                     callContext);
640             assertNotNull(retrieved1);
641             assertEquals(2, retrieved1.getInstructors().size());
642         } catch (Exception ex) {
643             log.error("exception due to", ex);
644             fail("Exception from service call :" + ex.getMessage());
645         }
646     }
647 
648     @Test
649     public void testUpdateCourseOfferingWithDynAttrs()
650             throws DataValidationErrorException, DoesNotExistException,
651             InvalidParameterException, MissingParameterException,
652             OperationFailedException, PermissionDeniedException,
653             ReadOnlyException, VersionMismatchException {
654         try {
655 
656             CourseOfferingInfo coi = coService.getCourseOffering("CO-2",
657                     callContext);
658             assertNotNull(coi);
659 
660             coi.setTermId("atpId1");
661 
662             // dynamic attributes
663             AttributeTester attributeTester = new AttributeTester();
664 
665             List<AttributeInfo> expectedList = new ArrayList<AttributeInfo>();
666 
667             attributeTester.add2ForCreate(expectedList);
668 
669             coi.getAttributes().addAll(expectedList);
670 
671             coi.setFundingSource("state");
672 
673             CourseOfferingInfo updated = coService.updateCourseOffering(
674                     coi.getId(), coi, callContext);
675             assertNotNull(updated);
676 
677             CourseOfferingInfo retrieved = coService.getCourseOffering(
678                     coi.getId(), callContext);
679             assertNotNull(retrieved);
680 
681             assertEquals("state", coi.getFundingSource());
682 
683             attributeTester.check(expectedList, coi.getAttributes());
684 
685             // TODO: fix once waitlists are implemented
686             // assertEquals("WaitlistLevelType1",
687             // coi.getWaitlistLevelTypeKey());
688         } catch (Exception ex) {
689             log.error("exception due to ", ex);
690             fail("Exception from service call :" + ex.getMessage());
691         }
692     }
693 
694     @Test
695     // TODO fix KSENROLL-2671, add back validation decorator and this will work again
696     public void testDeleteFormatOffering() throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DependentObjectsExistException, DoesNotExistException, DataValidationErrorException, VersionMismatchException, ReadOnlyException {
697 
698         boolean exception = false;
699 
700         try {
701             coService.deleteFormatOffering("DOES NOT EXIST", callContext);
702         } catch (DoesNotExistException e) {
703             exception = true;
704         }
705 
706         assertTrue("Activity should not exist but seems to.", exception);
707 
708         exception = false;
709 
710         String formatOfferingId = "CO-1:LEC-ONLY";
711         try {
712             coService.deleteFormatOffering(formatOfferingId, callContext);
713         } catch (DependentObjectsExistException e) {
714             exception = true;
715         }
716 
717         assertTrue("Deleted a format that has activities", exception);
718 
719         StatusInfo status = coService.deleteFormatOfferingCascaded(formatOfferingId, callContext);
720 
721         assertTrue(status.getIsSuccess());
722 
723         // verify no activity offerings remain
724         List<ActivityOfferingInfo> aos = coService.getActivityOfferingsByFormatOffering(formatOfferingId, callContext);
725 
726         assertEquals(0, aos.size());
727     }
728 
729 
730     @Test
731     public void testDeleteActivityOffering() throws DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, AlreadyExistsException, DoesNotExistException, VersionMismatchException {
732 
733         SeatPoolDefinitionInfo seatPoolDefinitionInfo = CourseOfferingServiceTestDataUtils.createSeatPoolDefinition("POP1", "Test Seat Pool", "expiration milestone", false, 12, 5);
734 
735         seatPoolDefinitionInfo = coService.createSeatPoolDefinition(seatPoolDefinitionInfo, callContext);
736 
737         String activityOfferingId = "CO-1:LEC-ONLY:LEC-A";
738         coService.addSeatPoolDefinitionToActivityOffering(seatPoolDefinitionInfo.getId(), activityOfferingId, callContext);
739 
740         boolean exception = false;
741         try {
742             coService.deleteActivityOffering(activityOfferingId, callContext);
743         } catch (DependentObjectsExistException e) {
744             exception = true;
745         }
746 
747         assertTrue("Failed to detect associated seat pool for activity offering and abort delete", exception);
748 
749         // now cascade the delete
750 
751         String formatOfferingId = "CO-1:LEC-ONLY";
752         StatusInfo status = coService.deleteActivityOfferingCascaded(activityOfferingId, callContext);
753 
754         assertTrue(status.getIsSuccess());
755 
756         // check that the activity offering and seat pool are gone.
757 
758         exception = false;
759 
760         try {
761             coService.getActivityOffering(activityOfferingId, callContext);
762         } catch (DoesNotExistException e) {
763             exception = true;
764         }
765 
766         assertTrue("activity still exists after delete", exception);
767 
768         exception = false;
769         try {
770             List<SeatPoolDefinitionInfo> spls = coService.getSeatPoolDefinitionsForActivityOffering(activityOfferingId, callContext);
771         } catch (DoesNotExistException e) {
772             exception = true;
773         }
774 
775         assertTrue("activity still exists after delete", exception);
776 
777     }
778 
779 
780     @Test
781     public void testDeleteCourseOffering() throws AlreadyExistsException,
782             DoesNotExistException, DataValidationErrorException,
783             InvalidParameterException, MissingParameterException,
784             OperationFailedException, PermissionDeniedException,
785             ReadOnlyException,
786             DoesNotExistException,
787             InvalidParameterException,
788             MissingParameterException,
789             OperationFailedException,
790             PermissionDeniedException {
791 
792         CourseInfo canonicalCourse = canonicalCourseService.getCourse("CLU-1", ContextUtils.getContextInfo());
793 
794         // Create a CO
795         CourseOfferingInfo coInfo = CourseOfferingServiceTestDataUtils
796                 .createCourseOffering(canonicalCourse, "2012SP");
797         List<String> optionKeys = new ArrayList<String>();
798         CourseOfferingInfo created = coService.createCourseOffering("CLU-1",
799                 "2012SP", LuiServiceConstants.COURSE_OFFERING_TYPE_KEY, coInfo,
800                 optionKeys, callContext);
801 
802         // Verify that the CO was created
803         assertNotNull(created);
804         assertEquals("CLU-1", created.getCourseId());
805         assertEquals("2012SP", created.getTermId());
806         assertEquals(LuiServiceConstants.COURSE_OFFERING_LIFECYCLE_STATE_KEYS[0],
807                 created.getStateKey());
808         assertEquals(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY,
809                 created.getTypeKey());
810 
811         try {
812             // Delete the course offering and check that the status returned was
813             // a success
814             StatusInfo delResult = coService.deleteCourseOffering(
815                     created.getId(), callContext);
816             assertTrue(delResult.getIsSuccess());
817         } catch (Exception ex) {
818             log.error("exception due to ", ex);
819             fail("Exception from service call :" + ex.getMessage());
820         }
821 
822         boolean exception = false;
823 
824         try {
825             coService.deleteCourseOffering("CO-1", callContext);
826         } catch (DependentObjectsExistException e) {
827             exception = true;
828         }
829 
830         assertTrue("Failed to detect dependent objects", exception);
831 
832 
833     }
834 
835     @Test
836     //@Ignore //KSENROLL-3482// TODO: update cascade to deal with AOC's instead of Reg Groups.
837     public void testDeleteCourseOfferingCascaded() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, AlreadyExistsException, DataValidationErrorException, VersionMismatchException, ReadOnlyException {
838 
839         boolean dependantObjects = false;
840 
841         try {
842             coService.deleteCourseOffering("CO-2", callContext);
843         } catch (DependentObjectsExistException e) {
844             dependantObjects = true;
845         }
846 
847         assertTrue("No dependent objects exist for CO-2", dependantObjects);
848 
849 
850         List<BulkStatusInfo> rgStatus = coService.generateRegistrationGroupsForFormatOffering("CO-2:LEC-ONLY", callContext);
851 
852         List<RegistrationGroupInfo> rgs = coService.getRegistrationGroupsByFormatOffering("CO-2:LEC-ONLY", callContext);
853 
854         assertTrue(rgs.size() > 0);
855 
856         StatusInfo status = coService.deleteCourseOfferingCascaded("CO-2", callContext);
857 
858         assertTrue(status.getIsSuccess());
859 
860         List<FormatOfferingInfo> formats = coService.getFormatOfferingsByCourseOffering("CO-2", callContext);
861 
862         assertEquals(0, formats.size());
863 
864         rgs = coService.getRegistrationGroupsForCourseOffering("CO-2", callContext);
865 
866         assertEquals(0, rgs.size());
867 
868     }
869 
870 
871     @Test
872     public void testCreateFormatOffering() throws DoesNotExistException,
873             InvalidParameterException, MissingParameterException,
874             OperationFailedException, PermissionDeniedException {
875         try {
876 
877             List<CourseOfferingInfo> coList = coService
878                     .getCourseOfferingsByCourse("CLU-1", callContext);
879 
880             assertTrue(coList.size() > 0);
881 
882             CourseOfferingInfo co = coList.get(0);
883 
884             FormatOfferingInfo newFO = CourseOfferingServiceTestDataUtils
885                     .createFormatOffering(co.getId(), "format1",
886                             co.getTermId(), "TEST FORMAT OFFERING",
887                             LuiServiceConstants.ALL_ACTIVITY_TYPES);
888             FormatOfferingInfo fo = coService.createFormatOffering(co.getId(),
889                     "format1", LuiServiceConstants.FORMAT_OFFERING_TYPE_KEY,
890                     newFO, callContext);
891             assertNotNull(fo);
892             assertEquals(LuiServiceConstants.LUI_FO_STATE_PLANNED_KEY,
893                     fo.getStateKey());
894             assertEquals(LuiServiceConstants.FORMAT_OFFERING_TYPE_KEY,
895                     fo.getTypeKey());
896             assertEquals("TEST FORMAT OFFERING", fo.getDescr().getPlain());
897         } catch (Exception ex) {
898             log.error("exception due to ", ex);
899             fail(ex.getMessage());
900         }
901     }
902 
903     @Test
904     public void testGetFormatOffering() throws DoesNotExistException,
905             InvalidParameterException, MissingParameterException,
906             OperationFailedException, PermissionDeniedException {
907         try {
908 
909             FormatOfferingInfo fo = coService.getFormatOffering(
910                     "CO-2:LEC-ONLY", callContext);
911             assertNotNull(fo);
912             assertEquals(LuiServiceConstants.LUI_FO_STATE_PLANNED_KEY,
913                     fo.getStateKey());
914             assertEquals(LuiServiceConstants.FORMAT_OFFERING_TYPE_KEY,
915                     fo.getTypeKey());
916             assertEquals("Lecture", fo.getDescr().getPlain());
917         } catch (Exception ex) {
918             log.error("exception due to ", ex);
919             fail(ex.getMessage());
920         }
921     }
922 
923     @Test
924     public void testCreateAndGetActivityOffering()
925             throws AlreadyExistsException, DataValidationErrorException,
926             InvalidParameterException, MissingParameterException,
927             OperationFailedException, PermissionDeniedException, DoesNotExistException {
928 
929         CourseOfferingInfo courseOffering = coService.getCourseOffering("CO-1", callContext);
930 
931         List<OfferingInstructorInfo> instructors = new ArrayList<OfferingInstructorInfo>();
932 
933         instructors.add(CourseOfferingServiceTestDataUtils.createInstructor(
934                 "Pers-1", "Person One", 60.00F));
935 
936         String activityId = CourseOfferingServiceTestDataUtils
937                 .createCanonicalActivityId("CO-1:LEC-ONLY",
938                         LuServiceConstants.COURSE_ACTIVITY_LECTURE_TYPE_KEY);
939 
940         ActivityOfferingInfo ao = CourseOfferingServiceTestDataUtils
941                 .createActivityOffering("2012FA", courseOffering, "CO-1:LEC-ONLY",
942                         new ArrayList<String>(Collections.singletonList("SCHED-ID")), activityId, "Lecture", "A",
943                         LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY,
944                         instructors);
945 
946         try {
947             ActivityOfferingInfo created = coService.createActivityOffering(
948                     "CO-1:LEC-ONLY", activityId,
949                     LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY, ao,
950                     callContext);
951             assertNotNull(created);
952 
953             ActivityOfferingInfo retrieved = coService.getActivityOffering(
954                     created.getId(), callContext);
955             assertNotNull(retrieved);
956 
957             assertEquals(created.getActivityId(), retrieved.getActivityId());
958             assertEquals(created.getTermId(), retrieved.getTermId());
959             assertEquals(LuiServiceConstants.LUI_AO_STATE_DRAFT_KEY,
960                     retrieved.getStateKey());
961             assertEquals(
962                     LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY,
963                     retrieved.getTypeKey());
964             assertEquals(1, retrieved.getInstructors().size());
965 
966             // test getActivityOfferingsByCourseOffering
967             List<ActivityOfferingInfo> activities = coService
968                     .getActivityOfferingsByCourseOffering("CO-1", callContext);
969             assertNotNull(activities);
970             // 3 existing plus this new one
971             // this one should probably not have been added so this test case
972             // may need to be adapted
973             // in the future.
974             assertEquals(8, activities.size());
975 
976             boolean foundActivityId = false;
977             boolean foundId = false;
978 
979             for (ActivityOfferingInfo activityOfferingInfo : activities) {
980 
981                 if (activityOfferingInfo.getActivityId().equals(
982                         created.getActivityId())) {
983                     foundActivityId = true;
984                 }
985 
986                 if (activityOfferingInfo.getId().equals("CO-1:LEC-ONLY:LEC-B"))
987                     foundId = true;
988             }
989             assertTrue(foundActivityId);
990             assertTrue(foundId);
991 
992             assertEquals(1, activities.get(0).getInstructors().size());
993         } catch (Exception ex) {
994             log.error("Exception from serviceCall", ex);
995 
996             fail("Exception from service call :" + ex.getMessage());
997         }
998     }
999 
1000 
1001     @Test
1002     public void testUpdateRegistrationGroup() throws InvalidParameterException,
1003             DataValidationErrorException, MissingParameterException,
1004             DoesNotExistException, VersionMismatchException,
1005             PermissionDeniedException, OperationFailedException,
1006             ReadOnlyException {
1007 
1008         List<RegistrationGroupInfo> rgList = coService.getRegistrationGroupsByFormatOffering("CO-2:LEC-ONLY", callContext);
1009 
1010         assertEquals(2, rgList.size());
1011 
1012         for (RegistrationGroupInfo regGroup : rgList) {
1013 
1014             // TODO: find a way to reach in and check that the reg groups are generated properly.
1015             if (regGroup.getActivityOfferingIds().get(0).indexOf("LEC-A") > 0) {
1016                 assertEquals("CO-2", regGroup.getCourseOfferingId());
1017                 assertEquals(1, regGroup.getActivityOfferingIds().size());
1018                 assertEquals("CO-2:LEC-ONLY:LEC-A", regGroup.getActivityOfferingIds()
1019                         .get(0));
1020             } else if (regGroup.getActivityOfferingIds().get(0).indexOf("LEC-B") > 0) {
1021                 regGroup.getActivityOfferingIds().remove(0);
1022                 regGroup.getActivityOfferingIds().add("CO-2:LEC-ONLY:LEC-B");
1023                 RegistrationGroupInfo updatedRegGroup = coService
1024                         .updateRegistrationGroup(regGroup.getId(), regGroup,
1025                                 callContext);
1026                 assertEquals("CO-2", regGroup.getCourseOfferingId());
1027                 assertEquals(1, updatedRegGroup.getActivityOfferingIds().size());
1028                 assertEquals("CO-2:LEC-ONLY:LEC-B", regGroup.getActivityOfferingIds()
1029                         .get(0));
1030             } else {
1031                 Assert.fail("invalid reg group with id = " + regGroup.getId());
1032             }
1033         }
1034 
1035 
1036     }
1037 
1038     @Test
1039     public void testDeleteRegistrationGroup() throws InvalidParameterException,
1040             MissingParameterException, DoesNotExistException,
1041             PermissionDeniedException, OperationFailedException {
1042 
1043         List<RegistrationGroupInfo> rgList = coService.getRegistrationGroupsByFormatOffering("CO-2:LEC-ONLY", callContext);
1044 
1045         assertEquals(2, rgList.size());
1046 
1047         RegistrationGroupInfo rg = rgList.get(0);
1048 
1049         StatusInfo statusInfo = coService.deleteRegistrationGroup(
1050                 rg.getId(), callContext);
1051         assertTrue(statusInfo.getIsSuccess());
1052         try {
1053             coService.getRegistrationGroup(rg.getId(), callContext);
1054             fail("Expected DoesNotExistException.");
1055         } catch (DoesNotExistException e) {
1056             // Expected. Do nothing.
1057         }
1058     }
1059 
1060     @Test
1061     public void testGetActivityOfferingType() throws InvalidParameterException,
1062             MissingParameterException, DoesNotExistException,
1063             PermissionDeniedException, OperationFailedException {
1064         TypeInfo validType = coService.getActivityOfferingType(
1065                 LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY,
1066                 callContext);
1067         assertNotNull(validType);
1068         assertEquals(LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY,
1069                 validType.getKey());
1070 
1071         TypeInfo shouldBeNull = null;
1072         try {
1073             shouldBeNull = coService.getActivityOfferingType(
1074                     "madeUpINAVLIDAoType", callContext);
1075             fail("Expected DoesNotExistException");
1076         } catch (DoesNotExistException e) {
1077             assertNull(shouldBeNull);
1078         }
1079     }
1080 
1081     @Test
1082     public void testGetActivityOfferingTypes()
1083             throws InvalidParameterException, MissingParameterException,
1084             PermissionDeniedException, OperationFailedException {
1085         List<TypeInfo> validTypes = coService
1086                 .getActivityOfferingTypes(callContext);
1087 
1088         assertNotNull(validTypes);
1089         assertTrue("Expecting at least one activity offering type",
1090                 !validTypes.isEmpty());
1091 
1092         boolean found = false;
1093         for (TypeInfo type : validTypes) {
1094             found = type.getKey().equals(
1095                     LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY);
1096             if (found) {
1097                 break;
1098             }
1099         }
1100 
1101         assertTrue("Expecting to find at least "
1102                 + LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY
1103                 + " type.", found);
1104     }
1105 
1106 
1107     @Test
1108     public void testCreateSeatPoolDefinition() throws DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
1109 
1110         SeatPoolDefinitionInfo mainPool = CourseOfferingServiceTestDataUtils.createSeatPoolDefinition("EVERYONE", "Lab 123", AtpServiceConstants.MILESTONE_COURSE_SELECTION_PERIOD_END_TYPE_KEY, true, 85, 1);
1111 
1112         SeatPoolDefinitionInfo secondaryPool = CourseOfferingServiceTestDataUtils.createSeatPoolDefinition("EVERYONE", "Lab 123B", AtpServiceConstants.MILESTONE_COURSE_SELECTION_PERIOD_END_TYPE_KEY, true, 15, 2);
1113 
1114         mainPool = coService.createSeatPoolDefinition(mainPool, callContext);
1115 
1116         secondaryPool = coService.createSeatPoolDefinition(secondaryPool, callContext);
1117 
1118         boolean exceptionEncountered = false;
1119         try {
1120             coService.addSeatPoolDefinitionToActivityOffering(mainPool.getId(), "CO-1:LEC-ONLY:LEC-A", callContext);
1121             coService.addSeatPoolDefinitionToActivityOffering(secondaryPool.getId(), "CO-1:LEC-ONLY:LEC-A", callContext);
1122         } catch (AlreadyExistsException e) {
1123             exceptionEncountered = true;
1124         } catch (DoesNotExistException e) {
1125             exceptionEncountered = true;
1126         }
1127 
1128         Assert.assertFalse(exceptionEncountered);
1129 
1130         try {
1131             List<SeatPoolDefinitionInfo> spds = coService.getSeatPoolDefinitionsForActivityOffering("CO-1:LEC-ONLY:LEC-A", callContext);
1132 
1133             Assert.assertEquals(2, spds.size());
1134 
1135         } catch (DoesNotExistException e) {
1136             // should not happen
1137             Assert.assertFalse("Activity does not exist exception", true);
1138         }
1139 
1140         exceptionEncountered = false;
1141 
1142         try {
1143             coService.removeSeatPoolDefinitionFromActivityOffering(mainPool.getId(), "CO-1:LEC-ONLY:LEC-A", callContext);
1144         } catch (DoesNotExistException e) {
1145 
1146             exceptionEncountered = true;
1147         }
1148 
1149         Assert.assertFalse(exceptionEncountered);
1150 
1151         try {
1152             List<SeatPoolDefinitionInfo> spds = coService.getSeatPoolDefinitionsForActivityOffering("CO-1:LEC-ONLY:LEC-A", callContext);
1153 
1154             Assert.assertEquals(1, spds.size());
1155 
1156         } catch (DoesNotExistException e) {
1157             // should not happen
1158             Assert.assertFalse("Activity does not exist exception", true);
1159         }
1160 
1161     }
1162 }