View Javadoc
1   /*
2    * Copyright 2005-2014 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  
17  package org.kuali.rice.krms.test;
18  
19  import org.junit.Before;
20  import org.junit.Test;
21  import org.kuali.rice.krms.api.repository.language.NaturalLanguageTemplate;
22  import org.springframework.dao.DataAccessException;
23  
24  import java.util.List;
25  
26  import static junit.framework.Assert.assertNotNull;
27  import static junit.framework.Assert.assertNull;
28  import static org.junit.Assert.assertEquals;
29  import static org.junit.Assert.fail;
30  
31  /**
32   *   RuleManagementNaturalLanguageTemplateTest is to test the methods of
33   *       ruleManagementServiceImpl relating to NaturalLanguageTemplates
34   *
35   *   Each test focuses on one of the methods.
36   */
37  public class RuleManagementNaturalLanguageTemplateTest extends RuleManagementBaseTest {
38      @Override
39      @Before
40      public void setClassDiscriminator() {
41          // set a unique discriminator for test objects of this class
42          CLASS_DISCRIMINATOR = "RMLTT";
43      }
44  
45      /**
46       *  Test testCreateNaturalLanguageTemplate()
47       *
48       *  This test focuses specifically on the RuleManagementServiceImpl .createNaturalLanguageTemplate(NaturalLanguageTemplate) method
49       */
50      @Test
51      public void testCreateNaturalLanguageTemplate() {
52          // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
53          RuleManagementBaseTestObjectNames t0 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t0");
54  
55          // validate that the NaturalLanguageTemplate being build, does not already exist
56          assertNull(ruleManagementService.getNaturalLanguageTemplate("en-reqActive"));
57  
58          // build a NaturalLanguageTemplate for testing
59          NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t0.namespaceName, "en", "reqActive",
60                  "Must not be inActive");
61  
62          // validate the resulting object
63          template = ruleManagementService.getNaturalLanguageTemplate("en-reqActive");
64          assertNotNull(ruleManagementService.getNaturalLanguageTemplate("en-reqActive"));
65          assertEquals("Unexpected language code found", "en", template.getLanguageCode());
66          assertEquals("Unexpected template found", "Must not be inActive", template.getTemplate());
67          assertEquals("Unexpected TypeId value",  krmsTypeRepository.getTypeByName(t0.namespaceName, "reqActive").getId(), template.getTypeId());
68          // will always return false  KULRICE-10653 NaturalLanguageTemplate "active" attribute missing from Database
69          assertEquals("Unexpected Active value", false, template.isActive());
70  
71          // try to create a NaturalLanguageTemplate with null languageCode
72          try {
73              NaturalLanguageTemplate.Builder.create(null,template.getNaturalLanguageUsageId(),"Ky objekt nuk duhet të jetë joaktive",template.getTypeId());
74              fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
75          } catch (IllegalArgumentException e ) {
76              // throws IllegalArgumentException: languageCode is null or blank
77          }
78  
79          // try to create a NaturalLanguageTemplate with blank languageCode
80          try {
81              NaturalLanguageTemplate.Builder.create("  ",template.getNaturalLanguageUsageId(),"Objektu hau ezin da ez-aktiboak",template.getTypeId());
82              fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
83          } catch (IllegalArgumentException e ) {
84              // throws IllegalArgumentException: languageCode is null or blank
85          }
86  
87          // try to create a NaturalLanguageTemplate with null  naturalLanguageUsageId
88          try {
89              NaturalLanguageTemplate.Builder.create("it",null,"Questo oggetto non deve essere inattivo",template.getTypeId());
90              fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
91          } catch (IllegalArgumentException e ) {
92              // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
93          }
94  
95          // try to create a NaturalLanguageTemplate with blank naturalLanguageUsageId
96          try {
97              NaturalLanguageTemplate.Builder.create("ja","  ","このオブジェクトは、非アクティブにすることはできません",template.getTypeId());
98              fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
99          } catch (IllegalArgumentException e ) {
100             // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
101         }
102 
103         // try to create a NaturalLanguageTemplate with null template
104         try {
105             NaturalLanguageTemplate.Builder.create("az",template.getNaturalLanguageUsageId(),null,template.getTypeId());
106             fail("Should have thrown IllegalArgumentException: template is null or blank");
107         } catch (IllegalArgumentException e ) {
108             // throws IllegalArgumentException: template is null or blank
109         }
110 
111         // try to create a NaturalLanguageTemplate with blank template
112         try {
113             NaturalLanguageTemplate.Builder.create("bg",template.getNaturalLanguageUsageId(),"   ",template.getTypeId());
114             fail("Should have thrown IllegalArgumentException: template is null or blank");
115         } catch (IllegalArgumentException e ) {
116             // throws IllegalArgumentException: template is null or blank
117         }
118 
119         // try to create a NaturalLanguageTemplate with null typeId
120         try {
121             NaturalLanguageTemplate.Builder.create("hr",template.getNaturalLanguageUsageId(),"Ovaj objekt ne smije biti neaktivna",null);
122             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
123         } catch (IllegalArgumentException e ) {
124             // throws IllegalArgumentException: typeId is null or blank
125         }
126 
127         // try to create a NaturalLanguageTemplate with blank typeId
128         try {
129             NaturalLanguageTemplate.Builder.create("cs",template.getNaturalLanguageUsageId(),"Tento objekt nesmí být neaktivní","  ");
130             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
131         } catch (IllegalArgumentException e ) {
132             // throws IllegalArgumentException: typeId is null or blank
133         }
134 
135         // try to create a NaturalLanguageTemplate with invalid typeId
136         NaturalLanguageTemplate.Builder naturalLanguageTemplateBuilder = NaturalLanguageTemplate.Builder.create("da",template.getNaturalLanguageUsageId(),"Dette formål må ikke være inaktiv","badId");
137         naturalLanguageTemplateBuilder.setId("da" + "-" + "reqActive");
138         try {
139             ruleManagementService.createNaturalLanguageTemplate(naturalLanguageTemplateBuilder.build());
140             fail("Should have thrown PersistenceException");
141         } catch (DataAccessException e) {
142             // Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot
143             // add or update a child row: a foreign key constraint fails (`rice24test`.`krms_nl_tmpl_t`, CONSTRAINT
144             // `KRMS_TYP_T` FOREIGN KEY (`TYP_ID`) REFERENCES `krms_typ_t` (`TYP_ID`))
145         }
146     }
147 
148     /**
149      *  Test testGetNaturalLanguageTemplate()
150      *
151      *  This test focuses specifically on the RuleManagementServiceImpl .getNaturalLanguageTemplate("naturalLanguageTemplateId") method
152      */
153     @Test
154     public void testGetNaturalLanguageTemplate() {
155         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
156         RuleManagementBaseTestObjectNames t1 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t1");
157 
158         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t1.namespaceName, "sw", "reqActive",
159                 "Detta ändamål får inte vara inaktiv");
160         assertNotNull(ruleManagementService.getNaturalLanguageTemplate("sw-reqActive"));
161         assertEquals("Unexpected language code found", "sw", template.getLanguageCode());
162         // try to getNaturalLanguageTemplate with null value
163         try {
164             ruleManagementService.getNaturalLanguageTemplate(null);
165             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was null");
166         } catch (IllegalArgumentException e) {
167             //throws g.IllegalArgumentException: naturalLanguageTemplateId was null
168         }
169 
170         // try to getNaturalLanguageTemplate with blank value
171         try {
172             ruleManagementService.getNaturalLanguageTemplate("  ");
173             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was blank");
174         } catch (IllegalArgumentException e) {
175             //throws IllegalArgumentException: naturalLanguageTemplateId was blank
176         }
177 
178         assertNull(ruleManagementService.getNaturalLanguageTemplate("badId"));
179     }
180 
181     /**
182      *  Test testUpdateNaturalLanguageTemplate()
183      *
184      *  This test focuses specifically on the RuleManagementServiceImpl .updateNaturalLanguageTemplate(NaturalLanguageTemplate) method
185      */
186     @Test
187     public void testUpdateNaturalLanguageTemplate() {
188         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
189         RuleManagementBaseTestObjectNames t2 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t2");
190 
191         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t2.namespaceName, "pl", "reqActive",
192                 "Isthay Objectway ustmay otnay ebay inActiveway");
193         NaturalLanguageTemplate.Builder naturalLanguageTemplateBuilder = NaturalLanguageTemplate.Builder.create(
194                 ruleManagementService.getNaturalLanguageTemplate("pl-reqActive"));
195         // update the template value  (pl is the lang_cd for polish not pig-latin so update template)
196         naturalLanguageTemplateBuilder.setTemplate("Ten obiekt nie moze byc nieaktywne");
197         naturalLanguageTemplateBuilder.setActive(true);
198         ruleManagementService.updateNaturalLanguageTemplate(naturalLanguageTemplateBuilder.build());
199 
200         assertEquals("Unexpected template value found", "Ten obiekt nie moze byc nieaktywne", ruleManagementService.getNaturalLanguageTemplate("pl-reqActive").getTemplate());
201         // will always return false  KULRICE-10653 NaturalLanguageTemplate "active" attribute missing from Database
202         assertEquals("Unexpected isActive value found", false, ruleManagementService.getNaturalLanguageTemplate("pl-reqActive").isActive());
203     }
204 
205     /**
206      *  Test testDeleteNaturalLanguageTemplate()
207      *
208      *  This test focuses specifically on the RuleManagementServiceImpl .deleteNaturalLanguageTemplate("naturalLanguageTemplateId") method
209      */
210     @Test
211     public void testDeleteNaturalLanguageTemplate() {
212         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
213         RuleManagementBaseTestObjectNames t3 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t3");
214 
215         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t3.namespaceName, "pt", "reqActive",
216                 "Este objeto nao deve ser inativo");
217         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("pt-reqActive"));
218 
219         ruleManagementService.deleteNaturalLanguageTemplate("pt-reqActive");
220 
221         // verify it was deleted
222         assertNull("Should not have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("pt-reqActive"));
223 
224         // test delete using null
225         try {
226             ruleManagementService.deleteNaturalLanguageTemplate(null);
227             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was null");
228         } catch (IllegalArgumentException e) {
229             // throws IllegalArgumentException: naturalLanguageTemplateId was null
230         }
231 
232         // test delete using blank
233         try {
234             ruleManagementService.deleteNaturalLanguageTemplate("    ");
235             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was blank");
236         } catch (IllegalArgumentException e) {
237             // throws IllegalArgumentException: naturalLanguageTemplateId was blank
238         }
239 
240         // test delete using bad value
241         try {
242             ruleManagementService.deleteNaturalLanguageTemplate("badValue");
243             fail("Should have thrown IllegalStateException: the NaturalLanguageTemplate to delete does not exists: badValue");
244         } catch (IllegalStateException e) {
245             // throws IllegalStateException: the NaturalLanguageTemplate to delete does not exists: badValue
246         }
247     }
248 
249 
250     /**
251      *  Test testFindNaturalLanguageTemplatesByLanguageCode()
252      *
253      *  This test focuses specifically on the RuleManagementServiceImpl .findNaturalLanguageTemplatesByLanguageCode("languageCode") method
254      */
255     @Test
256     public void testFindNaturalLanguageTemplatesByLanguageCode() {
257         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
258         RuleManagementBaseTestObjectNames t4 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t4");
259 
260         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t4.namespaceName, "ro", "reqActive",
261                 "Acest obiect nu trebuie sa fie inactiv");
262         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("ro-reqActive"));
263 
264         List<NaturalLanguageTemplate> nlTemplates = ruleManagementService.findNaturalLanguageTemplatesByLanguageCode("ro");
265         assertEquals("Unexpected number of templates returned ",1,nlTemplates.size());
266         assertEquals("Unexpected template id returned","ro-reqActive",nlTemplates.get(0).getId());
267 
268         // test find with null LanguageCode
269         try {
270             ruleManagementService.findNaturalLanguageTemplatesByLanguageCode(null);
271             fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
272         } catch (IllegalArgumentException e) {
273             // throws IllegalArgumentException: languageCode is null or blank
274         }
275 
276         // test find with blank LanguageCode
277         try {
278             ruleManagementService.findNaturalLanguageTemplatesByLanguageCode("  ");
279             fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
280         } catch (IllegalArgumentException e) {
281             // throws IllegalArgumentException: languageCode is null or blank
282         }
283 
284         // test find with non-existing LanguageCode
285         assertEquals("Unexpected number of templates returned ",0,
286                 ruleManagementService.findNaturalLanguageTemplatesByLanguageCode("badValue").size());
287     }
288 
289 
290     /**
291      *  Test testFindNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId()
292      *
293      *  This test focuses specifically on the RuleManagementServiceImpl
294      *     .findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(String languageCode, String typeId, String naturalLanguageUsageId) method
295      */
296     @Test
297     public void testFindNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId() {
298         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
299         RuleManagementBaseTestObjectNames t5 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t5");
300 
301         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t5.namespaceName, "sk", "reqActive",
302                 "Tento objekt nesmie byt neaktívne");
303         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("sk-reqActive"));
304 
305         // test find
306         template = ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
307                 template.getLanguageCode(),template.getTypeId(),template.getNaturalLanguageUsageId());
308 
309         // validate the returned object
310         assertEquals("Unexpected template id returned","sk-reqActive",template.getId());
311         assertEquals("Unexpected language code found", "sk", template.getLanguageCode());
312         assertEquals("Unexpected template found", "Tento objekt nesmie byt neaktívne", template.getTemplate());
313         assertEquals("Unexpected TypeId value",  krmsTypeRepository.getTypeByName(t5.namespaceName, "reqActive").getId(), template.getTypeId());
314         // change test to true after isActive is functional KULRICE-10653
315         assertEquals("Unexpected Active value", false, template.isActive());
316 
317         // test find with null language code
318         try {
319              ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
320                 null,template.getTypeId(),template.getNaturalLanguageUsageId());
321              fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
322         } catch (IllegalArgumentException e) {
323             // throws IllegalArgumentException: languageCode is null or blank
324         }
325 
326         // test find with null TypeId
327         ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
328                 template.getLanguageCode(),null,template.getNaturalLanguageUsageId());
329 
330         // test find with null NaturalLanguageUsageId
331         ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
332                 template.getLanguageCode(),template.getTypeId(),null);
333 
334         // test find with blank language code
335         try {
336             ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
337                     "  ",template.getTypeId(),template.getNaturalLanguageUsageId());
338             fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
339         } catch (IllegalArgumentException e) {
340             // throws IllegalArgumentException: languageCode is null or blank
341         }
342     }
343 
344 
345     /**
346      *  Test testFindNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId()
347      *
348      *  This test focuses specifically on the RuleManagementServiceImpl
349      *     .findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(String languageCode, String typeId, String naturalLanguageUsageId) method
350      */
351     @Test
352     public void testFindNaturalLanguageTemplatesByNaturalLanguageUsage() {
353         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
354         RuleManagementBaseTestObjectNames t6 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t6");
355 
356         // build test template (change seed value reqActive to reqActive-SL to discriminate nl usage from other tests
357         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t6.namespaceName, "sl", "reqActive-SL",
358                 "Ta predmet ne sme biti neaktiven");
359         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("sl-reqActive-SL"));
360 
361         // test find
362         List<NaturalLanguageTemplate> templates = ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage(template.getNaturalLanguageUsageId());
363         assertEquals("Unexpected number of templates returned ",1,templates.size());
364         template = templates.get(0);
365 
366         // validate the returned object
367         assertEquals("Unexpected template id returned","sl-reqActive-SL",template.getId());
368         assertEquals("Unexpected language code found", "sl", template.getLanguageCode());
369         assertEquals("Unexpected template found", "Ta predmet ne sme biti neaktiven", template.getTemplate());
370         assertEquals("Unexpected TypeId value",  krmsTypeRepository.getTypeByName(t6.namespaceName, "reqActive-SL").getId(), template.getTypeId());
371         // change test to true after isActive is functional KULRICE-10653
372         assertEquals("Unexpected Active value", false, template.isActive());
373 
374         // test find with null NaturalLanguageUsage
375         try {
376             ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage(null);
377             fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
378         } catch (IllegalArgumentException e) {
379             // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
380         }
381 
382         // test find with blank NaturalLanguageUsage
383         try {
384             ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage("   ");
385             fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
386         } catch (IllegalArgumentException e) {
387             // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
388         }
389 
390         // test find with nonexistant NaturalLanguageUsage code
391         assertEquals("Unexpected number of templates returned ",0,
392                 ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage("badValue").size());
393     }
394 
395 
396     /**
397      *  Test testFindNaturalLanguageTemplatesByType()
398      *
399      *  This test focuses specifically on the RuleManagementServiceImpl
400      *     .findNaturalLanguageTemplatesByType(String typeId) method
401      */
402     @Test
403     public void testFindNaturalLanguageTemplatesByType() {
404         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
405         RuleManagementBaseTestObjectNames t7 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t7");
406 
407         // build test template (change seed value reqActive to reqActive-SL to discriminate "Type" from other tests
408         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t7.namespaceName, "es", "reqActive-ES",
409                 "Este objeto no debe estar inactivo");
410         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("es-reqActive-ES"));
411 
412         // test find
413         List<NaturalLanguageTemplate> templates = ruleManagementService.findNaturalLanguageTemplatesByType(template.getTypeId());
414         assertEquals("Unexpected number of templates returned ",1,templates.size());
415 
416         // test find with null typeId
417         try {
418             ruleManagementService.findNaturalLanguageTemplatesByType(null);
419             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
420         } catch (IllegalArgumentException e) {
421             // throws IllegalArgumentException: typeId is null or blank
422         }
423 
424         // test find with null typeId
425         try {
426             ruleManagementService.findNaturalLanguageTemplatesByType("   ");
427             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
428         } catch (IllegalArgumentException e) {
429             // throws IllegalArgumentException: typeId is null or blank
430         }
431 
432         // test find non-existent  value for typeId
433         assertEquals("Unexpected number of templates returned ",0,
434                 ruleManagementService.findNaturalLanguageTemplatesByType("badValue").size());
435     }
436 
437 
438     /**
439      *  Test testFindNaturalLanguageTemplatesByTemplate()
440      *
441      *  This test focuses specifically on the RuleManagementServiceImpl
442      *     .findNaturalLanguageTemplatesByTemplate(String template) method
443      */
444     @Test
445     public void testFindNaturalLanguageTemplatesByTemplate() {
446         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
447         RuleManagementBaseTestObjectNames t8 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t8");
448 
449         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t8.namespaceName, "sv", "reqActive",
450                 "Detta ändamal far inte vara inaktiv");
451         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("sv-reqActive"));
452 
453         // test find
454         List<NaturalLanguageTemplate> templates =
455                 ruleManagementService.findNaturalLanguageTemplatesByTemplate("Detta ändamal far inte vara inaktiv");
456         assertEquals("Unexpected number of templates returned ",1,templates.size());
457 
458         // test find with null Template
459         try {
460             ruleManagementService.findNaturalLanguageTemplatesByTemplate(null);
461             fail("Should have thrown IllegalArgumentException: template is null or blank");
462         } catch (IllegalArgumentException e) {
463             // throws IllegalArgumentException: template is null or blank
464         }
465 
466         // test find with null Template
467         try {
468             ruleManagementService.findNaturalLanguageTemplatesByTemplate("   ");
469             fail("Should have thrown IllegalArgumentException: template is null or blank");
470         } catch (IllegalArgumentException e) {
471             // throws IllegalArgumentException: template is null or blank
472         }
473 
474         // test find non-existent value for Template
475         assertEquals("Unexpected number of templates returned ",0,
476                 ruleManagementService.findNaturalLanguageTemplatesByTemplate("badValue").size());
477     }
478 }