View Javadoc

1   /*
2    * Copyright 2007-2008 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.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.rice.kns.service;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.junit.Test;
22  import org.kuali.rice.kns.test.document.bo.Account;
23  import org.kuali.rice.kns.test.document.bo.AccountManager;
24  import org.kuali.test.KNSTestCase;
25  import org.kuali.test.KNSWithTestSpringContext;
26  
27  /**
28   * This class tests KULRICE-1666: missing Spring mapping for ojbCollectionHelper
29   * (not injected into BusinessObjectDaoTest)
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   *
33   */
34  @KNSWithTestSpringContext
35  public class BusinessObjectServiceTest extends KNSTestCase {
36  
37      public BusinessObjectServiceTest() {}
38  
39      /**
40       * This method tests saving a BO with a collection member
41       *
42       * @throws Exception
43       */
44      @Test
45      public void testSave() throws Exception {
46          BusinessObjectService businessObjectService = KNSServiceLocator.getBusinessObjectService();
47          
48          AccountManager am = new AccountManager();
49          am.setUserName("bhutchin");
50          List<Account> accounts = new ArrayList<Account>();
51          Account account1 = new Account();
52          account1.setNumber("1");
53          account1.setName("account 1");
54          account1.setAccountManager(am);
55          accounts.add(account1);
56  
57          Account account2 = new Account();
58          account2.setNumber("2");
59          account2.setName("account 2");
60          account2.setAccountManager(am);
61  
62          accounts.add(account2);
63          am.setAccounts(accounts);
64  
65          businessObjectService.save(am);
66      }
67  
68  }