View Javadoc
1   /**
2    * Copyright 2005-2015 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 edu.sampleu.main;
17  
18  import org.apache.commons.lang.RandomStringUtils;
19  import org.junit.Test;
20  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
21  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
22  import org.kuali.rice.testtools.selenium.WebDriverUtils;
23  
24  /**
25   * test that checks that rules can be added to agendas
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class AgendaEditorActiveInactiveCheckAft extends WebDriverLegacyITBase {
30      public static final String BOOKMARK_URL =
31              AutomatedFunctionalTestUtils.PORTAL
32                      + "?channelTitle=Agenda%20Lookup&channelUrl="
33                      + WebDriverUtils.getBaseUrlString()
34                      + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
35                      + "org.kuali.rice.krms.impl.repository.AgendaBo"
36                      + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS
37                      + "&returnLocation="
38                      + AutomatedFunctionalTestUtils.PORTAL_URL
39                      + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
40  
41      @Override
42      protected String getBookmarkUrl() {
43          return BOOKMARK_URL;
44      }
45  
46      @Override
47      protected void navigate() throws Exception {
48          waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT);
49          waitForPageToLoad();
50      }
51  
52      protected void testAgendaEditorActiveInactiveCheck() throws Exception {
53          String uniqueText = RandomStringUtils.randomAlphabetic(9).toUpperCase();
54          String uniqueRuleText = RandomStringUtils.randomAlphabetic(9).toUpperCase();
55  
56          //Add Inactive & Verify
57          selectFrameIframePortlet();
58          waitAndClickByXpath("//a[contains(text(),'Create New')]");
59          selectFrameIframePortlet();
60          selectByName("document.newMaintainableObject.dataObject.namespace","Kuali Rules Test");
61          waitAndTypeByName("document.newMaintainableObject.dataObject.agenda.name",uniqueText+"Inactive");
62          waitAndTypeByName("document.newMaintainableObject.dataObject.contextName","Context1");
63          waitAndClickByName("document.newMaintainableObject.dataObject.agenda.active");
64          copyRuleFromExisting(uniqueText);
65          selectFrameIframePortlet();
66          waitAndClickByXpath("//button[contains(text(),'Submit')]");
67          waitAndClickConfirmSubmitOk();
68          waitForTextPresent("Document was successfully submitted.");
69          selectParentWindow();
70          waitAndClickMainMenu();
71          selectFrameIframePortlet();
72          navigate();
73          selectFrameIframePortlet();
74          waitAndTypeByName("lookupCriteria[name]",uniqueText+"Inactive");
75          waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='N']");
76          waitAndClickButtonByExactText("Search");
77          waitForTextPresent(uniqueText+"Inactive");
78  
79          // Add Active & Verify
80          waitAndClickByXpath("//a[contains(text(),'Create New')]");
81          selectFrameIframePortlet();
82          selectByName("document.newMaintainableObject.dataObject.namespace","Kuali Rules Test");
83          waitAndTypeByName("document.newMaintainableObject.dataObject.agenda.name",uniqueText+"Active");
84          waitAndTypeByName("document.newMaintainableObject.dataObject.contextName","Context1");
85          copyRuleFromExisting(uniqueRuleText);
86          selectFrameIframePortlet();
87          waitAndClickByXpath("//button[contains(text(),'Submit')]");
88          waitAndClickConfirmSubmitOk();
89          waitForTextPresent("Document was successfully submitted.");
90          selectParentWindow();
91          waitAndClickMainMenu();
92          selectFrameIframePortlet();
93          navigate();
94          selectFrameIframePortlet();
95          waitAndTypeByName("lookupCriteria[name]",uniqueText+"Active");
96          waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='Y']");
97          waitAndClickButtonByExactText("Search");
98          waitForTextPresent(uniqueText+"Active");
99  
100         //Verify Both
101         waitAndClickButtonByExactText("Clear Values");
102         waitAndTypeByName("lookupCriteria[name]",uniqueText+"Active");
103         waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='']");
104         waitAndClickButtonByExactText("Search");
105         waitForTextPresent(uniqueText+"Active");
106         waitAndClickButtonByExactText("Clear Values");
107         waitAndTypeByName("lookupCriteria[name]",uniqueText+"Inactive");
108         waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='']");
109         waitAndClickButtonByExactText("Search");
110         waitForTextPresent(uniqueText+"Inactive");
111     }
112 
113     protected void copyRuleFromExisting(String ruleName) throws Exception {
114         waitAndClickButtonByExactText("Add Rule");
115         selectFrameIframePortlet();
116         waitAndClickById("copyRuleName_quickfinder_act");
117         gotoLightBox();
118         waitAndClickButtonByText("Search");
119         waitAndClickLinkContainingText("return value");
120         selectFrameIframePortlet();
121         waitAndClickButtonByExactText("Copy Rule");
122         waitAndTypeByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.name",ruleName);
123         if(!isElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.agendaItemLine.rule.name' and @value='"+ruleName+"']")) {
124             waitAndTypeByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.name",ruleName);
125         }
126         waitAndClickButtonByExactText("Add Rule");
127         waitForElementPresentByXpath("//a[@class='ruleTreeNode simplePropositionNode']/p");
128     }
129 
130     /**
131      * test ActiveInactive Check
132      */
133     @Test
134     public void testAgendaEditorActiveInactiveCheckBookmark() throws Exception {
135         testAgendaEditorActiveInactiveCheck();
136     }
137 
138     /**
139      * test ActiveInactive Check
140      */
141     @Test
142     public void testAgendaEditorActiveInactiveCheckNav() throws Exception {
143         testAgendaEditorActiveInactiveCheck();
144     }
145 }