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.krms.api.repository.language.NaturalLanguageTemplate;
21  import org.kuali.rice.krms.test.AbstractBoTest;
22  import org.kuali.rice.test.BaselineTestCase;
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  /**
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.CLEAR_DB)
31  public class RuleManagementIntegrationTest extends AbstractBoTest {
32  
33      RuleManagementServiceImpl ruleManagementServiceImpl;
34  
35      @Before
36      public void setup() {
37          ruleManagementServiceImpl = new RuleManagementServiceImpl();
38          NaturalLanguageTemplateBoServiceImpl naturalLanguageTemplateBoServiceImpl = new NaturalLanguageTemplateBoServiceImpl();
39          naturalLanguageTemplateBoServiceImpl.setNaturalLanguageTemplater(NaturalLanguageTemplateIntegrationGenTest.newStringReplaceTemplater());
40          ruleManagementServiceImpl.setNaturalLanguageTemplateBoService(naturalLanguageTemplateBoServiceImpl);
41          ruleManagementServiceImpl.setBusinessObjectService(getBoService()); // Business Object Service gets set to other Services
42      }
43  
44      @Test
45      public void naturalLanguage() {
46          // create a new nlt, which we will use to get a created def, that we will add attributes to.
47          NaturalLanguageTemplateIntegrationGenTest nltTest = new NaturalLanguageTemplateIntegrationGenTest();
48          nltTest.setup();
49          nltTest.test_createNaturalLanguageTemplate();
50          NaturalLanguageTemplate nlt = nltTest.getNaturalLanguageTemplate();
51  
52          // get a def from the default test.
53          NaturalLanguageTemplateBo nltBo = NaturalLanguageTemplateBo.from(nlt);
54          // add the attributes for templating
55          Map<String, String> attributes = new HashMap<String, String>();
56          attributes.put("TEMPLATE", "template");
57          nltBo.setAttributes(attributes);
58  
59          String krmsObjectId = "ID";
60  // TODO when attributes are working correctly, the getNaturalLanguageForType should not through an exception, and the two asserts after it should pass.
61  //        String result = ruleManagementServiceImpl.getNaturalLanguageForType(nlt.getNaturalLanguageUsageId(), nlt.getTypeId(), krmsObjectId, nlt.getLanguageCode());
62  //        assertNotNull(result);
63  //        assertEquals("template", result);
64      }
65  }
66