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", true);
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          assertEquals("Unexpected Active value", true, template.isActive());
69  
70          // try to create a NaturalLanguageTemplate with null languageCode
71          try {
72              NaturalLanguageTemplate.Builder.create(null,template.getNaturalLanguageUsageId(),"Ky objekt nuk duhet të jetë joaktive",template.getTypeId());
73              fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
74          } catch (IllegalArgumentException e ) {
75              // throws IllegalArgumentException: languageCode is null or blank
76          }
77  
78          // try to create a NaturalLanguageTemplate with blank languageCode
79          try {
80              NaturalLanguageTemplate.Builder.create("  ",template.getNaturalLanguageUsageId(),"Objektu hau ezin da ez-aktiboak",template.getTypeId());
81              fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
82          } catch (IllegalArgumentException e ) {
83              // throws IllegalArgumentException: languageCode is null or blank
84          }
85  
86          // try to create a NaturalLanguageTemplate with null  naturalLanguageUsageId
87          try {
88              NaturalLanguageTemplate.Builder.create("it",null,"Questo oggetto non deve essere inattivo",template.getTypeId());
89              fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
90          } catch (IllegalArgumentException e ) {
91              // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
92          }
93  
94          // try to create a NaturalLanguageTemplate with blank naturalLanguageUsageId
95          try {
96              NaturalLanguageTemplate.Builder.create("ja","  ","このオブジェクトは、非アクティブにすることはできません",template.getTypeId());
97              fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
98          } catch (IllegalArgumentException e ) {
99              // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
100         }
101 
102         // try to create a NaturalLanguageTemplate with null template
103         try {
104             NaturalLanguageTemplate.Builder.create("az",template.getNaturalLanguageUsageId(),null,template.getTypeId());
105             fail("Should have thrown IllegalArgumentException: template is null or blank");
106         } catch (IllegalArgumentException e ) {
107             // throws IllegalArgumentException: template is null or blank
108         }
109 
110         // try to create a NaturalLanguageTemplate with blank template
111         try {
112             NaturalLanguageTemplate.Builder.create("bg",template.getNaturalLanguageUsageId(),"   ",template.getTypeId());
113             fail("Should have thrown IllegalArgumentException: template is null or blank");
114         } catch (IllegalArgumentException e ) {
115             // throws IllegalArgumentException: template is null or blank
116         }
117 
118         // try to create a NaturalLanguageTemplate with null typeId
119         try {
120             NaturalLanguageTemplate.Builder.create("hr",template.getNaturalLanguageUsageId(),"Ovaj objekt ne smije biti neaktivna",null);
121             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
122         } catch (IllegalArgumentException e ) {
123             // throws IllegalArgumentException: typeId is null or blank
124         }
125 
126         // try to create a NaturalLanguageTemplate with blank typeId
127         try {
128             NaturalLanguageTemplate.Builder.create("cs",template.getNaturalLanguageUsageId(),"Tento objekt nesmí být neaktivní","  ");
129             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
130         } catch (IllegalArgumentException e ) {
131             // throws IllegalArgumentException: typeId is null or blank
132         }
133 
134         // try to create a NaturalLanguageTemplate with invalid typeId
135         NaturalLanguageTemplate.Builder naturalLanguageTemplateBuilder = NaturalLanguageTemplate.Builder.create("da",template.getNaturalLanguageUsageId(),"Dette formål må ikke være inaktiv","badId");
136         naturalLanguageTemplateBuilder.setId("da" + "-" + "reqActive");
137         try {
138             ruleManagementService.createNaturalLanguageTemplate(naturalLanguageTemplateBuilder.build());
139             fail("Should have thrown PersistenceException");
140         } catch (DataAccessException e) {
141             // Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot
142             // add or update a child row: a foreign key constraint fails (`rice24test`.`krms_nl_tmpl_t`, CONSTRAINT
143             // `KRMS_TYP_T` FOREIGN KEY (`TYP_ID`) REFERENCES `krms_typ_t` (`TYP_ID`))
144         }
145     }
146 
147     /**
148      *  Test testGetNaturalLanguageTemplate()
149      *
150      *  This test focuses specifically on the RuleManagementServiceImpl .getNaturalLanguageTemplate("naturalLanguageTemplateId") method
151      */
152     @Test
153     public void testGetNaturalLanguageTemplate() {
154         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
155         RuleManagementBaseTestObjectNames t1 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t1");
156 
157         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t1.namespaceName, "sw", "reqActive",
158                 "Detta ändamål får inte vara inaktiv", true);
159         assertNotNull(ruleManagementService.getNaturalLanguageTemplate("sw-reqActive"));
160         assertEquals("Unexpected language code found", "sw", template.getLanguageCode());
161         // try to getNaturalLanguageTemplate with null value
162         try {
163             ruleManagementService.getNaturalLanguageTemplate(null);
164             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was null");
165         } catch (IllegalArgumentException e) {
166             //throws g.IllegalArgumentException: naturalLanguageTemplateId was null
167         }
168 
169         // try to getNaturalLanguageTemplate with blank value
170         try {
171             ruleManagementService.getNaturalLanguageTemplate("  ");
172             fail("Should have thrown IllegalArgumentException: naturalLanguageTemplateId was blank");
173         } catch (IllegalArgumentException e) {
174             //throws IllegalArgumentException: naturalLanguageTemplateId was blank
175         }
176 
177         assertNull(ruleManagementService.getNaturalLanguageTemplate("badId"));
178     }
179 
180     /**
181      *  Test testUpdateNaturalLanguageTemplate()
182      *
183      *  This test focuses specifically on the RuleManagementServiceImpl .updateNaturalLanguageTemplate(NaturalLanguageTemplate) method
184      */
185     @Test
186     public void testUpdateNaturalLanguageTemplate() {
187         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
188         RuleManagementBaseTestObjectNames t2 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t2");
189 
190         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t2.namespaceName, "pl", "reqActive",
191                 "Isthay Objectway ustmay otnay ebay inActiveway", true);
192         NaturalLanguageTemplate.Builder naturalLanguageTemplateBuilder = NaturalLanguageTemplate.Builder.create(
193                 ruleManagementService.getNaturalLanguageTemplate("pl-reqActive"));
194         // update the template value  (pl is the lang_cd for polish not pig-latin so update template)
195         naturalLanguageTemplateBuilder.setTemplate("Ten obiekt nie moze byc nieaktywne");
196         naturalLanguageTemplateBuilder.setActive(true);
197         ruleManagementService.updateNaturalLanguageTemplate(naturalLanguageTemplateBuilder.build());
198 
199         assertEquals("Unexpected template value found", "Ten obiekt nie moze byc nieaktywne", ruleManagementService.getNaturalLanguageTemplate("pl-reqActive").getTemplate());
200         assertEquals("Unexpected isActive value found", true, 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", true);
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", true);
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", true);
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         assertEquals("Unexpected Active value", true, template.isActive());
313 
314         // test find with null language code
315         try {
316              ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
317                 null,template.getTypeId(),template.getNaturalLanguageUsageId());
318              fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
319         } catch (IllegalArgumentException e) {
320             // throws IllegalArgumentException: languageCode is null or blank
321         }
322 
323         // test find with null TypeId
324         ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
325                 template.getLanguageCode(),null,template.getNaturalLanguageUsageId());
326 
327         // test find with null NaturalLanguageUsageId
328         ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
329                 template.getLanguageCode(),template.getTypeId(),null);
330 
331         // test find with blank language code
332         try {
333             ruleManagementService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(
334                     "  ",template.getTypeId(),template.getNaturalLanguageUsageId());
335             fail("Should have thrown IllegalArgumentException: languageCode is null or blank");
336         } catch (IllegalArgumentException e) {
337             // throws IllegalArgumentException: languageCode is null or blank
338         }
339     }
340 
341 
342     /**
343      *  Test testFindNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId()
344      *
345      *  This test focuses specifically on the RuleManagementServiceImpl
346      *     .findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(String languageCode, String typeId, String naturalLanguageUsageId) method
347      */
348     @Test
349     public void testFindNaturalLanguageTemplatesByNaturalLanguageUsage() {
350         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
351         RuleManagementBaseTestObjectNames t6 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t6");
352 
353         // build test template (change seed value reqActive to reqActive-SL to discriminate nl usage from other tests
354         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t6.namespaceName, "sl", "reqActive-SL",
355                 "Ta predmet ne sme biti neaktiven", true);
356         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("sl-reqActive-SL"));
357 
358         // test find
359         List<NaturalLanguageTemplate> templates = ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage(template.getNaturalLanguageUsageId());
360         assertEquals("Unexpected number of templates returned ",1,templates.size());
361         template = templates.get(0);
362 
363         // validate the returned object
364         assertEquals("Unexpected template id returned","sl-reqActive-SL",template.getId());
365         assertEquals("Unexpected language code found", "sl", template.getLanguageCode());
366         assertEquals("Unexpected template found", "Ta predmet ne sme biti neaktiven", template.getTemplate());
367         assertEquals("Unexpected TypeId value",  krmsTypeRepository.getTypeByName(t6.namespaceName, "reqActive-SL").getId(), template.getTypeId());
368         assertEquals("Unexpected Active value", true, template.isActive());
369 
370         // test find with null NaturalLanguageUsage
371         try {
372             ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage(null);
373             fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
374         } catch (IllegalArgumentException e) {
375             // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
376         }
377 
378         // test find with blank NaturalLanguageUsage
379         try {
380             ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage("   ");
381             fail("Should have thrown IllegalArgumentException: naturalLanguageUsageId is null or blank");
382         } catch (IllegalArgumentException e) {
383             // throws IllegalArgumentException: naturalLanguageUsageId is null or blank
384         }
385 
386         // test find with nonexistant NaturalLanguageUsage code
387         assertEquals("Unexpected number of templates returned ",0,
388                 ruleManagementService.findNaturalLanguageTemplatesByNaturalLanguageUsage("badValue").size());
389     }
390 
391 
392     /**
393      *  Test testFindNaturalLanguageTemplatesByType()
394      *
395      *  This test focuses specifically on the RuleManagementServiceImpl
396      *     .findNaturalLanguageTemplatesByType(String typeId) method
397      */
398     @Test
399     public void testFindNaturalLanguageTemplatesByType() {
400         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
401         RuleManagementBaseTestObjectNames t7 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t7");
402 
403         // build test template (change seed value reqActive to reqActive-SL to discriminate "Type" from other tests
404         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t7.namespaceName, "es", "reqActive-ES",
405                 "Este objeto no debe estar inactivo", true);
406         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("es-reqActive-ES"));
407 
408         // test find
409         List<NaturalLanguageTemplate> templates = ruleManagementService.findNaturalLanguageTemplatesByType(template.getTypeId());
410         assertEquals("Unexpected number of templates returned ",1,templates.size());
411 
412         // test find with null typeId
413         try {
414             ruleManagementService.findNaturalLanguageTemplatesByType(null);
415             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
416         } catch (IllegalArgumentException e) {
417             // throws IllegalArgumentException: typeId is null or blank
418         }
419 
420         // test find with null typeId
421         try {
422             ruleManagementService.findNaturalLanguageTemplatesByType("   ");
423             fail("Should have thrown IllegalArgumentException: typeId is null or blank");
424         } catch (IllegalArgumentException e) {
425             // throws IllegalArgumentException: typeId is null or blank
426         }
427 
428         // test find non-existent  value for typeId
429         assertEquals("Unexpected number of templates returned ",0,
430                 ruleManagementService.findNaturalLanguageTemplatesByType("badValue").size());
431     }
432 
433 
434     /**
435      *  Test testFindNaturalLanguageTemplatesByTemplate()
436      *
437      *  This test focuses specifically on the RuleManagementServiceImpl
438      *     .findNaturalLanguageTemplatesByTemplate(String template) method
439      */
440     @Test
441     public void testFindNaturalLanguageTemplatesByTemplate() {
442         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
443         RuleManagementBaseTestObjectNames t8 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t8");
444 
445         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t8.namespaceName, "sv", "reqActive",
446                 "Detta ändamal far inte vara inaktiv", true);
447         assertNotNull("Should have found NaturalLanguageTemplate", ruleManagementService.getNaturalLanguageTemplate("sv-reqActive"));
448 
449         // test find
450         List<NaturalLanguageTemplate> templates =
451                 ruleManagementService.findNaturalLanguageTemplatesByTemplate("Detta ändamal far inte vara inaktiv");
452         assertEquals("Unexpected number of templates returned ",1,templates.size());
453 
454         // test find with null Template
455         try {
456             ruleManagementService.findNaturalLanguageTemplatesByTemplate(null);
457             fail("Should have thrown IllegalArgumentException: template is null or blank");
458         } catch (IllegalArgumentException e) {
459             // throws IllegalArgumentException: template is null or blank
460         }
461 
462         // test find with null Template
463         try {
464             ruleManagementService.findNaturalLanguageTemplatesByTemplate("   ");
465             fail("Should have thrown IllegalArgumentException: template is null or blank");
466         } catch (IllegalArgumentException e) {
467             // throws IllegalArgumentException: template is null or blank
468         }
469 
470         // test find non-existent value for Template
471         assertEquals("Unexpected number of templates returned ",0,
472                 ruleManagementService.findNaturalLanguageTemplatesByTemplate("badValue").size());
473     }
474 
475     /**
476      *  Test testCreateNaturalLanguageTemplate()
477      *
478      *  This test focuses specifically on the RuleManagementServiceImpl.
479      *  createNaturalLanguageTemplate(NaturalLanguageTemplate) method, but
480      *  creates the language template and associated attributes using a generated ID
481      */
482     @Test
483     public void testCreateNaturalLanguageTemplateWithGeneratedId() {
484         // get a set of unique object names for use by this test (discriminator passed can be any unique value within this class)
485         RuleManagementBaseTestObjectNames t9 =  new RuleManagementBaseTestObjectNames( CLASS_DISCRIMINATOR, "t9");
486 
487         // build a NaturalLanguageTemplate with a generated id
488         NaturalLanguageTemplate template = createTestNaturalLanguageTemplate(t9.namespaceName, "XX", "reqActive-XX",
489                 "Template name", false);
490 
491         assertNotNull(ruleManagementService.getNaturalLanguageTemplate(template.getId()));
492         assertEquals("Unexpected number of attributes created ",2, template.getAttributes().size());
493     }
494 }