001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krms.impl.repository;
017    
018    import org.junit.Before;
019    import org.junit.Test;
020    import org.kuali.rice.krms.api.repository.language.NaturalLanguageTemplate;
021    import org.kuali.rice.krms.test.AbstractBoTest;
022    import org.kuali.rice.test.BaselineTestCase;
023    
024    import java.util.HashMap;
025    import java.util.Map;
026    
027    /**
028     * @author Kuali Rice Team (rice.collab@kuali.org)
029     */
030    @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.CLEAR_DB)
031    public class RuleManagementIntegrationTest extends AbstractBoTest {
032    
033        RuleManagementServiceImpl ruleManagementServiceImpl;
034    
035        @Before
036        public void setup() {
037            ruleManagementServiceImpl = new RuleManagementServiceImpl();
038            NaturalLanguageTemplateBoServiceImpl naturalLanguageTemplateBoServiceImpl = new NaturalLanguageTemplateBoServiceImpl();
039            naturalLanguageTemplateBoServiceImpl.setNaturalLanguageTemplater(NaturalLanguageTemplateIntegrationGenTest.newStringReplaceTemplater());
040            ruleManagementServiceImpl.setNaturalLanguageTemplateBoService(naturalLanguageTemplateBoServiceImpl);
041            ruleManagementServiceImpl.setBusinessObjectService(getBoService()); // Business Object Service gets set to other Services
042        }
043    
044        @Test
045        public void naturalLanguage() {
046            // create a new nlt, which we will use to get a created def, that we will add attributes to.
047            NaturalLanguageTemplateIntegrationGenTest nltTest = new NaturalLanguageTemplateIntegrationGenTest();
048            nltTest.setup();
049            nltTest.test_createNaturalLanguageTemplate();
050            NaturalLanguageTemplate nlt = nltTest.getNaturalLanguageTemplate();
051    
052            // get a def from the default test.
053            NaturalLanguageTemplateBo nltBo = NaturalLanguageTemplateBo.from(nlt);
054            // add the attributes for templating
055            Map<String, String> attributes = new HashMap<String, String>();
056            attributes.put("TEMPLATE", "template");
057            nltBo.setAttributes(attributes);
058    
059            String krmsObjectId = "ID";
060    // TODO when attributes are working correctly, the getNaturalLanguageForType should not through an exception, and the two asserts after it should pass.
061    //        String result = ruleManagementServiceImpl.getNaturalLanguageForType(nlt.getNaturalLanguageUsageId(), nlt.getTypeId(), krmsObjectId, nlt.getLanguageCode());
062    //        assertNotNull(result);
063    //        assertEquals("template", result);
064        }
065    }
066