View Javadoc
1   package org.kuali.ole.deliver.drools.rules;
2   
3   import org.apache.commons.io.FileUtils;
4   import org.junit.Test;
5   import org.kuali.ole.deliver.bo.drools.DroolsRuleBo;
6   import org.kuali.ole.deliver.drools.DroolsConstants;
7   
8   import java.io.File;
9   import java.util.ArrayList;
10  import java.util.List;
11  
12  import static junit.framework.TestCase.assertNotNull;
13  import static org.junit.Assert.*;
14  
15  /**
16   * Created by pvsubrah on 7/15/15.
17   */
18  public class CheckoutDroolsFileGenerator_UT {
19      @Test
20      public void generateCheckoutDroolsFile() throws Exception {
21          CheckoutDroolsFileGenerator droolFileGenerator = new CheckoutDroolsFileGenerator();
22          droolFileGenerator.setFileDir(System.getProperty("java.io.tmpdir") + "/2-H.drl");
23  
24          List<DroolsRuleBo> droolsRuleBoList = new ArrayList<>();
25  
26          DroolsRuleBo droolsRuleBo = new DroolsRuleBo();
27          droolsRuleBo.setAgendaGroup("checkout-validation");
28          droolsRuleBo.setActivationGroup("checkout-validation");
29          droolsRuleBo.setRuleName("Check out Circ Policy Set 2-H for Max Loaned Items less than 3");
30          droolsRuleBo.setRuleType(DroolsConstants.CHECKOUT_RULE_TYPE.CHECKOUT);
31          droolsRuleBo.setLoanType(DroolsConstants.SHORT_TERM_LOANS_NOTICE_CONFIG);
32          droolsRuleBo.setCirculationPolicyId("Check out Circ Policy Set 2-H");
33          droolsRuleBo.setLoanPeriod("2-H");
34          droolsRuleBo.setDefaultRecallPeriod(null);
35          droolsRuleBo.setItemTypes("stks-regular,book,cd,audio");
36          droolsRuleBo.setItemTypesOperator("not in");
37          droolsRuleBo.setInstitutionLocations("UC");
38          droolsRuleBo.setInstitutionLocationsOperator("in");
39          droolsRuleBo.setLibraryLocations("JRL,JCL");
40          droolsRuleBo.setLibraryLocationsOperator("in");
41          droolsRuleBo.setShelvingLocations("GEN,MAIN");
42          droolsRuleBo.setShelvingLocationsOperator("in");
43          droolsRuleBo.setCollectionLocations("GEN,MAIN");
44          droolsRuleBo.setCollectionLocationsOperator("in");
45          droolsRuleBo.setBorrowerTypes("QGRAD,UGRAD");
46          droolsRuleBo.setBorrowerTypesOperator("in");
47          droolsRuleBo.setItemTypeCountOperator(">");
48          droolsRuleBo.setItemTypeCount("5");
49          droolsRuleBo.setCirculationPolicyId("Check out Circ Policy Set 2-H");
50          droolsRuleBo.setLoanPeriod("2-H");
51          droolsRuleBo.setDefaultRecallPeriod("null");
52          droolsRuleBo.setLoanType(DroolsConstants.SHORT_TERM_LOANS_NOTICE_CONFIG);
53  
54          droolsRuleBoList.add(droolsRuleBo);
55  
56          File generateFile = droolFileGenerator.generateFile(droolsRuleBoList,"2-H");
57  
58          assertNotNull(generateFile);
59          String readFileToString = FileUtils.readFileToString(generateFile);
60          System.out.println(readFileToString);
61  
62      }
63  
64  }