View Javadoc

1   /*
2    * Copyright 2006-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  
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.DataIntegrityViolationException;
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 DataIntegrityViolationException: OJB operation; SQL []; Cannot add or update a child row: a foreign key constraint fails");
141         } catch (DataIntegrityViolationException e) {
142             // throws DataIntegrityViolationException: OJB operation; SQL []; Cannot add or update a child row: a foreign key constraint fails
143         }
144     }
145 
146     /**
147      *  Test testGetNaturalLanguageTemplate()
148      *
149      *  This test focuses specifically on the RuleManagementServiceImpl .getNaturalLanguageTemplate("naturalLanguageTemplateId") method
150      */
151     @Test
152     public void testGetNaturalLanguageTemplate() {
153         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
154         RuleManagementBaseTestObjectNames t1 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t1");
155 
156         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t1.namespaceName, "sw", "reqActive",
157                 "Detta ändamål får inte vara inaktiv");
158         assertNotNull(ruleManagementService.getNaturalLanguageTemplate("sw-reqActive"));
159         assertEquals("Unexpected language code found", "sw", template.getLanguageCode());
160         // try to getNaturalLanguageTemplate with null value
161         try {
162             ruleManagementService.getNaturalLanguageTemplate(null);
163             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was null");
164         } catch (IllegalArgumentException e) {
165             //throws g.IllegalArgumentException: naturalLanguageTemplateId was null
166         }
167 
168         // try to getNaturalLanguageTemplate with blank value
169         try {
170             ruleManagementService.getNaturalLanguageTemplate("  ");
171             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was blank");
172         } catch (IllegalArgumentException e) {
173             //throws IllegalArgumentException: naturalLanguageTemplateId was blank
174         }
175 
176         assertNull(ruleManagementService.getNaturalLanguageTemplate("badId"));
177     }
178 
179     /**
180      *  Test testUpdateNaturalLanguageTemplate()
181      *
182      *  This test focuses specifically on the RuleManagementServiceImpl .updateNaturalLanguageTemplate(NaturalLanguageTemplate) method
183      */
184     @Test
185     public void testUpdateNaturalLanguageTemplate() {
186         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
187         RuleManagementBaseTestObjectNames t2 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t2");
188 
189         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t2.namespaceName, "pl", "reqActive",
190                 "Isthay Objectway ustmay otnay ebay inActiveway");
191         NaturalLanguageTemplate.Builder naturalLanguageTemplateBuilder = NaturalLanguageTemplate.Builder.create(
192                 ruleManagementService.getNaturalLanguageTemplate("pl-reqActive"));
193         // update the template value  (pl is the lang_cd for polish not pig-latin so update template)
194         naturalLanguageTemplateBuilder.setTemplate("Ten obiekt nie moze byc nieaktywne");
195         naturalLanguageTemplateBuilder.setActive(true);
196         ruleManagementService.updateNaturalLanguageTemplate(naturalLanguageTemplateBuilder.build());
197 
198         assertEquals("Unexpected template value found", "Ten obiekt nie moze byc nieaktywne", ruleManagementService.getNaturalLanguageTemplate("pl-reqActive").getTemplate());
199         // will always return false  KULRICE-10653 NaturalLanguageTemplate "active" attribute missing from Database
200         assertEquals("Unexpected isActive value found", false, ruleManagementService.getNaturalLanguageTemplate("pl-reqActive").isActive());
201     }
202 
203     /**
204      *  Test testDeleteNaturalLanguageTemplate()
205      *
206      *  This test focuses specifically on the RuleManagementServiceImpl .deleteNaturalLanguageTemplate("naturalLanguageTemplateId") method
207      */
208     @Test
209     public void testDeleteNaturalLanguageTemplate() {
210         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
211         RuleManagementBaseTestObjectNames t3 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t3");
212 
213         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t3.namespaceName, "pt", "reqActive",
214                 "Este objeto nao deve ser inativo");
215         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("pt-reqActive"));
216 
217         ruleManagementService.deleteNaturalLanguageTemplate("pt-reqActive");
218 
219         // verify it was deleted
220         assertNull("Should not have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("pt-reqActive"));
221 
222         // test delete using null
223         try {
224             ruleManagementService.deleteNaturalLanguageTemplate(null);
225             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was null");
226         } catch (IllegalArgumentException e) {
227             // throws IllegalArgumentException: naturalLanguageTemplateId was null
228         }
229 
230         // test delete using blank
231         try {
232             ruleManagementService.deleteNaturalLanguageTemplate("    ");
233             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was blank");
234         } catch (IllegalArgumentException e) {
235             // throws IllegalArgumentException: naturalLanguageTemplateId was blank
236         }
237 
238         // test delete using bad value
239         try {
240             ruleManagementService.deleteNaturalLanguageTemplate("badValue");
241             fail("Should have thrown IllegalStateException: the NaturalLanguageTemplate to delete does not exists: badValue");
242         } catch (IllegalStateException e) {
243             // throws IllegalStateException: the NaturalLanguageTemplate to delete does not exists: badValue
244         }
245     }
246 
247 
248     /**
249      *  Test testFindNaturalLanguageTemplatesByLanguageCode()
250      *
251      *  This test focuses specifically on the RuleManagementServiceImpl .findNaturalLanguageTemplatesByLanguageCode("languageCode") method
252      */
253     @Test
254     public void testFindNaturalLanguageTemplatesByLanguageCode() {
255         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
256         RuleManagementBaseTestObjectNames t4 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t4");
257 
258         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t4.namespaceName, "ro", "reqActive",
259                 "Acest obiect nu trebuie sa fie inactiv");
260         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("ro-reqActive"));
261 
262         List<NaturalLanguageTemplate> nlTemplates = ruleManagementService.findNaturalLanguageTemplatesByLanguageCode("ro");
263         assertEquals("Unexpected number of templates returned ",1,nlTemplates.size());
264         assertEquals("Unexpected template id returned","ro-reqActive",nlTemplates.get(0).getId());
265 
266         // test find with null LanguageCode
267         try {
268             ruleManagementService.findNaturalLanguageTemplatesByLanguageCode(null);
269             fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
270         } catch (IllegalArgumentException e) {
271             // throws IllegalArgumentException: languageCode is null or blank
272         }
273 
274         // test find with blank LanguageCode
275         try {
276             ruleManagementService.findNaturalLanguageTemplatesByLanguageCode("  ");
277             fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
278         } catch (IllegalArgumentException e) {
279             // throws IllegalArgumentException: languageCode is null or blank
280         }
281 
282         // test find with non-existing LanguageCode
283         assertEquals("Unexpected number of templates returned ",0,
284                 ruleManagementService.findNaturalLanguageTemplatesByLanguageCode("badValue").size());
285     }
286 
287 
288     /**
289      *  Test testFindNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId()
290      *
291      *  This test focuses specifically on the RuleManagementServiceImpl
292      *     .findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(String languageCode, String typeId, String naturalLanguageUsageId) method
293      */
294     @Test
295     public void testFindNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId() {
296         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
297         RuleManagementBaseTestObjectNames t5 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t5");
298 
299         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t5.namespaceName, "sk", "reqActive",
300                 "Tento objekt nesmie byt neaktívne");
301         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("sk-reqActive"));
302 
303         // test find
304         template = ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
305                 template.getLanguageCode(),template.getTypeId(),template.getNaturalLanguageUsageId());
306 
307         // validate the returned object
308         assertEquals("Unexpected template id returned","sk-reqActive",template.getId());
309         assertEquals("Unexpected language code found", "sk", template.getLanguageCode());
310         assertEquals("Unexpected template found", "Tento objekt nesmie byt neaktívne", template.getTemplate());
311         assertEquals("Unexpected TypeId value",  krmsTypeRepository.getTypeByName(t5.namespaceName, "reqActive").getId(), template.getTypeId());
312         // change test to true after isActive is functional KULRICE-10653
313         assertEquals("Unexpected Active value", false, template.isActive());
314 
315         // test find with null language code
316         try {
317              ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
318                 null,template.getTypeId(),template.getNaturalLanguageUsageId());
319              fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
320         } catch (IllegalArgumentException e) {
321             // throws IllegalArgumentException: languageCode is null or blank
322         }
323 
324         // test find with null TypeId
325         ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
326                 template.getLanguageCode(),null,template.getNaturalLanguageUsageId());
327 
328         // test find with null NaturalLanguageUsageId
329         ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
330                 template.getLanguageCode(),template.getTypeId(),null);
331 
332         // test find with blank language code
333         try {
334             ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
335                     "  ",template.getTypeId(),template.getNaturalLanguageUsageId());
336             fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
337         } catch (IllegalArgumentException e) {
338             // throws IllegalArgumentException: languageCode is null or blank
339         }
340     }
341 
342 
343     /**
344      *  Test testFindNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId()
345      *
346      *  This test focuses specifically on the RuleManagementServiceImpl
347      *     .findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(String languageCode, String typeId, String naturalLanguageUsageId) method
348      */
349     @Test
350     public void testFindNaturalLanguageTemplatesByNaturalLanguageUsage() {
351         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
352         RuleManagementBaseTestObjectNames t6 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t6");
353 
354         // build test template (change seed value reqActive to reqActive-SL to discriminate nl usage from other tests
355         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t6.namespaceName, "sl", "reqActive-SL",
356                 "Ta predmet ne sme biti neaktiven");
357         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("sl-reqActive-SL"));
358 
359         // test find
360         List<NaturalLanguageTemplate> templates = ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage(template.getNaturalLanguageUsageId());
361         assertEquals("Unexpected number of templates returned ",1,templates.size());
362         template = templates.get(0);
363 
364         // validate the returned object
365         assertEquals("Unexpected template id returned","sl-reqActive-SL",template.getId());
366         assertEquals("Unexpected language code found", "sl", template.getLanguageCode());
367         assertEquals("Unexpected template found", "Ta predmet ne sme biti neaktiven", template.getTemplate());
368         assertEquals("Unexpected TypeId value",  krmsTypeRepository.getTypeByName(t6.namespaceName, "reqActive-SL").getId(), template.getTypeId());
369         // change test to true after isActive is functional KULRICE-10653
370         assertEquals("Unexpected Active value", false, template.isActive());
371 
372         // test find with null NaturalLanguageUsage
373         try {
374             ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage(null);
375             fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
376         } catch (IllegalArgumentException e) {
377             // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
378         }
379 
380         // test find with blank NaturalLanguageUsage
381         try {
382             ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage("   ");
383             fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
384         } catch (IllegalArgumentException e) {
385             // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
386         }
387 
388         // test find with nonexistant NaturalLanguageUsage code
389         assertEquals("Unexpected number of templates returned ",0,
390                 ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage("badValue").size());
391     }
392 
393 
394     /**
395      *  Test testFindNaturalLanguageTemplatesByType()
396      *
397      *  This test focuses specifically on the RuleManagementServiceImpl
398      *     .findNaturalLanguageTemplatesByType(String typeId) method
399      */
400     @Test
401     public void testFindNaturalLanguageTemplatesByType() {
402         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
403         RuleManagementBaseTestObjectNames t7 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t7");
404 
405         // build test template (change seed value reqActive to reqActive-SL to discriminate "Type" from other tests
406         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t7.namespaceName, "es", "reqActive-ES",
407                 "Este objeto no debe estar inactivo");
408         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("es-reqActive-ES"));
409 
410         // test find
411         List<NaturalLanguageTemplate> templates = ruleManagementService.findNaturalLanguageTemplatesByType(template.getTypeId());
412         assertEquals("Unexpected number of templates returned ",1,templates.size());
413 
414         // test find with null typeId
415         try {
416             ruleManagementService.findNaturalLanguageTemplatesByType(null);
417             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
418         } catch (IllegalArgumentException e) {
419             // throws IllegalArgumentException: typeId is null or blank
420         }
421 
422         // test find with null typeId
423         try {
424             ruleManagementService.findNaturalLanguageTemplatesByType("   ");
425             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
426         } catch (IllegalArgumentException e) {
427             // throws IllegalArgumentException: typeId is null or blank
428         }
429 
430         // test find non-existent  value for typeId
431         assertEquals("Unexpected number of templates returned ",0,
432                 ruleManagementService.findNaturalLanguageTemplatesByType("badValue").size());
433     }
434 
435 
436     /**
437      *  Test testFindNaturalLanguageTemplatesByTemplate()
438      *
439      *  This test focuses specifically on the RuleManagementServiceImpl
440      *     .findNaturalLanguageTemplatesByTemplate(String template) method
441      */
442     @Test
443     public void testFindNaturalLanguageTemplatesByTemplate() {
444         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
445         RuleManagementBaseTestObjectNames t8 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t8");
446 
447         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t8.namespaceName, "sv", "reqActive",
448                 "Detta ändamal far inte vara inaktiv");
449         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("sv-reqActive"));
450 
451         // test find
452         List<NaturalLanguageTemplate> templates =
453                 ruleManagementService.findNaturalLanguageTemplatesByTemplate("Detta ändamal far inte vara inaktiv");
454         assertEquals("Unexpected number of templates returned ",1,templates.size());
455 
456         // test find with null Template
457         try {
458             ruleManagementService.findNaturalLanguageTemplatesByTemplate(null);
459             fail("Should have thrown IllegalArgumentException: template is null or blank");
460         } catch (IllegalArgumentException e) {
461             // throws IllegalArgumentException: template is null or blank
462         }
463 
464         // test find with null Template
465         try {
466             ruleManagementService.findNaturalLanguageTemplatesByTemplate("   ");
467             fail("Should have thrown IllegalArgumentException: template is null or blank");
468         } catch (IllegalArgumentException e) {
469             // throws IllegalArgumentException: template is null or blank
470         }
471 
472         // test find non-existent value for Template
473         assertEquals("Unexpected number of templates returned ",0,
474                 ruleManagementService.findNaturalLanguageTemplatesByTemplate("badValue").size());
475     }
476 }