View Javadoc

1   /**
2    * Copyright 2005-2013 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.krms.impl.repository;
17  
18  import org.junit.Before;
19  import org.junit.Test;
20  import org.kuali.rice.krad.service.BusinessObjectService;
21  import org.kuali.rice.krms.api.repository.NaturalLanguageUsageGenTest;
22  import org.kuali.rice.krms.api.repository.language.NaturalLanguageUsage;
23  
24  import static org.mockito.Mockito.mock;
25  
26  /**
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   * 
29   */
30  public final class NaturalLanguageUsageBoServiceImplGenTest {
31  
32      NaturalLanguageUsageBoServiceImpl naturalLanguageUsageBoServiceImpl;
33      NaturalLanguageUsage naturalLanguageUsage;
34  
35      NaturalLanguageUsage getNaturalLanguageUsage() {
36          return naturalLanguageUsage;
37      }
38  
39      public void setNaturalLanguageUsageBoServiceImpl(NaturalLanguageUsageBoServiceImpl impl) {
40          this.naturalLanguageUsageBoServiceImpl = impl;
41      }
42  
43      public static org.kuali.rice.krms.impl.repository.NaturalLanguageUsageBoServiceImplGenTest create(NaturalLanguageUsageBoServiceImpl impl) {
44          org.kuali.rice.krms.impl.repository.NaturalLanguageUsageBoServiceImplGenTest test = new org.kuali.rice.krms.impl.repository.NaturalLanguageUsageBoServiceImplGenTest();
45          test.setNaturalLanguageUsageBoServiceImpl(impl);
46          return test;
47      }
48  
49      @Before
50      public void setUp() {
51          naturalLanguageUsageBoServiceImpl = new NaturalLanguageUsageBoServiceImpl();
52          naturalLanguageUsageBoServiceImpl.setBusinessObjectService(mock(BusinessObjectService.class));
53      }
54  
55      @Test(expected = java.lang.IllegalArgumentException.class)
56      public void test_findNaturalLanguageUsagesByName_null_fail() {
57          naturalLanguageUsageBoServiceImpl.findNaturalLanguageUsagesByName(null);
58      }
59  
60      @Test(expected = java.lang.IllegalArgumentException.class)
61      public void test_findNaturalLanguageUsagesByDescription_null_fail() {
62          naturalLanguageUsageBoServiceImpl.findNaturalLanguageUsagesByDescription(null);
63      }
64  
65      @Test(expected = java.lang.IllegalArgumentException.class)
66      public void test_findNaturalLanguageUsagesByNamespace_null_fail() {
67          naturalLanguageUsageBoServiceImpl.findNaturalLanguageUsagesByNamespace(null);
68      }
69  
70      @Test
71      public void test_from_null_yields_null() {
72          assert(naturalLanguageUsageBoServiceImpl.from(null) == null);
73      }
74  
75      @Test
76      public void test_from() {
77          NaturalLanguageUsage def = NaturalLanguageUsageGenTest.buildFullNaturalLanguageUsage();
78          NaturalLanguageUsageBo naturalLanguageUsageBo = naturalLanguageUsageBoServiceImpl.from(def);
79          assert(naturalLanguageUsageBo.getName().equals(def.getName()));
80          assert(naturalLanguageUsageBo.getNamespace().equals(def.getNamespace()));
81          assert(naturalLanguageUsageBo.getId().equals(def.getId()));
82      }
83  
84      @Test
85      public void test_to() {
86          NaturalLanguageUsage def = NaturalLanguageUsageGenTest.buildFullNaturalLanguageUsage();
87          NaturalLanguageUsageBo naturalLanguageUsageBo = naturalLanguageUsageBoServiceImpl.from(def);
88          NaturalLanguageUsage def2 = NaturalLanguageUsageBo.to(naturalLanguageUsageBo);
89          assert(def.equals(def2));
90      }
91  
92      @Test
93      public void test_createNaturalLanguageUsage() {
94          NaturalLanguageUsage def = NaturalLanguageUsageGenTest.buildFullNaturalLanguageUsage();
95  
96          naturalLanguageUsage = naturalLanguageUsageBoServiceImpl.getNaturalLanguageUsageByName(def.getNamespace(), def.getName());
97  
98          if (naturalLanguageUsage == null) {
99              naturalLanguageUsage = naturalLanguageUsageBoServiceImpl.createNaturalLanguageUsage(def);
100         }
101     }
102 
103     @Test(expected = java.lang.IllegalArgumentException.class)
104     public void test_createNaturalLanguageUsage_null_fail() {
105         naturalLanguageUsageBoServiceImpl.createNaturalLanguageUsage(null);
106     }
107 
108     @Test(expected = java.lang.IllegalArgumentException.class)
109     public void test_updateNaturalLanguageUsage_null_fail() {
110         naturalLanguageUsageBoServiceImpl.updateNaturalLanguageUsage(null);
111     }
112 
113     @Test(expected = java.lang.IllegalArgumentException.class)
114     public void test_deleteNaturalLanguageUsage_null_fail() {
115         naturalLanguageUsageBoServiceImpl.deleteNaturalLanguageUsage(null);
116     }
117 
118 //    void createNaturalLanguageUsage() { // TODO gen what to do when no FKs?
119 //        // TODO change the Object type of the parameters
120 //        NaturalLanguageUsage def = NaturalLanguageUsageGenTest.buildFullFKNaturalLanguageUsage();
121 //        naturalLanguageUsage = naturalLanguageUsageBoServiceImpl.createNaturalLanguageUsage(def);
122 //    }
123 
124 }