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.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
19  import org.kuali.rice.testtools.selenium.WebDriverUtils;
20  import org.openqa.selenium.By;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class EditRuleAftBase extends MainTmplMthdSTNavBase{
26  
27      /**
28       * ITUtil.PORTAL + "?channelTitle=Create%20New%20Agenda&channelUrl=" + WebDriverUtils.getBaseUrlString() +
29       *  "/kr-krad/krmsAgendaEditor?methodToCall=start&dataObjectClassName=org.kuali.rice.krms.impl.ui.AgendaEditor&returnLocation=" +
30       *  ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK;
31       */
32      public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Create%20New%20Agenda&channelUrl=" + WebDriverUtils
33              .getBaseUrlString() +"/kr-krad/krmsAgendaEditor?methodToCall=start&dataObjectClassName=org.kuali.rice.krms.impl.ui.AgendaEditor&returnLocation=" +
34              AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
35  
36      @Override
37      protected String getBookmarkUrl() {
38          return BOOKMARK_URL;
39      }
40  
41      /**
42       * {@inheritDoc}
43       * Create New Agenda
44       * @return
45       */
46      @Override
47      protected String getLinkLocator() {
48          return "Create New Agenda";
49      }
50  
51      protected void testEditRuleSaveSubmit() throws Exception {
52          selectFrameIframePortlet();
53          String desc = getDescriptionUnique();
54          String docId = waitForAgendaDocId();
55          waitAndSelectLabeled("Namespace:", "Kuali Rules Test");
56          waitAndTypeLabeledInput("Name:", desc);
57          waitAndTypeLabeledInput("Context:", "Context1");
58          addAndEditRule();
59          waitAndClickButtonByExactText("Add Rule");
60          saveSuccessfully();
61          submitSuccessfully();
62  //        waitAndClickButtonByExactText("Save");
63  //        waitAndClickButtonByExactText("Submit");
64  //        waitAndClickConfirmSubmitOk();
65      }
66  
67      protected void testEditRuleBlanketApprove() throws Exception {
68          selectFrameIframePortlet();
69          String desc = getDescriptionUnique();
70          String docId = waitForAgendaDocId();
71          waitAndSelectLabeled("Namespace:", "Kuali Rules Test");
72          waitAndTypeLabeledInput("Name:", desc);
73          waitAndTypeLabeledInput("Context:", "Context1");
74          addAndEditRule();
75          waitAndClickButtonByExactText("Add Rule");
76          waitAndClickButtonByExactText("Blanket Approve");
77          waitAndClickConfirmBlanketApproveOk();
78      }
79  
80      private void addAndEditRule() throws Exception {
81          //Adding Rules so we do not need to rely on the existing data.
82          waitAndClickButtonByExactText("Add Rule");
83          String desc = getDescriptionUnique();
84          waitAndTypeByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.name", "Rule Name " + desc);
85          waitAndClickButtonByExactText("Add");
86          waitAndTypeByName(
87                  "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].data.proposition.description",
88                  "Rule 1");
89          selectByName(
90                  "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].data.proposition.parameters[0].value",
91                  "Account");
92          waitAndTypeByName(
93                  "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].data.proposition.parameters[1].value",
94                  "12345");
95          selectByName(
96                  "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].data.proposition.parameters[2].value",
97                  "=");
98          waitAndClickByXpath("//input[@type='image' and @alt='Add Parent']");
99          waitAndClickButtonByExactText("Add");
100         waitForElementPresentByXpath(
101                 "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[2].data.proposition.description");
102         waitAndTypeByName(
103                 "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[2].data.proposition.description",
104                 "Rule 2");
105         selectByName(
106                 "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[2].data.proposition.parameters[0].value",
107                 "Account");
108         selectByName(
109                 "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[2].data.proposition.parameters[2].value",
110                 "=");
111         waitAndTypeByName(
112                 "document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[2].data.proposition.parameters[1].value",
113                 "12345");
114         waitAndClickByXpath("//div[4]/fieldset/div/input[@type='image' and @alt='Edit']");
115         waitForTextPresent("Rule 2");
116 
117         //Moving Rules Up, Down, Right and Left & Add Parent
118         waitAndClickButtonByExactText("Up");
119         waitAndClickButtonByExactText("Down");
120         waitAndClickButtonByExactText("Add Parent");
121         waitAndClickButtonByExactText("Left");
122         waitAndClickButtonByExactText("Up");
123         waitAndClickButtonByExactText("Right");
124 
125         //Checking Cut & Paste with Refresh
126         waitAndClickButtonByExactText("Cut");
127         waitAndClickByXpath("//a[@class='ruleTreeNode compoundNode']");
128         waitAndClickButtonByExactText("Paste");
129         waitAndClickButtonByExactText("refresh");
130     }
131 
132 }