View Javadoc

1   /**
2    * Copyright 2005-2011 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.samplu.admin.test;
17  
18  import static org.junit.Assert.assertEquals;
19  
20  import org.apache.commons.lang.RandomStringUtils;
21  import org.junit.Test;
22  
23  import edu.samplu.common.AdminMenuLegacyITBase;
24  import edu.samplu.common.ITUtil;
25  
26  /**
27   * tests the Parameter Type section in Rice.
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class ParameterTypeLegacyIT extends AdminMenuLegacyITBase {
32      /**
33       * This overridden method ...
34       * 
35       * @see edu.samplu.common.MenuLegacyITBase#getLinkLocator()
36       */
37      String docId;
38      String parameterType;
39      String parameterCode;
40      @Override
41      protected String getLinkLocator() {
42          return "Parameter Type";
43      }
44      @Test
45      public void testParameterType() throws Exception {
46          
47          super.gotoCreateNew();
48          waitForPageToLoad();
49          docId = getTextByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
50          //Enter details for Parameter.
51          waitAndTypeByName("document.documentHeader.documentDescription", "Adding Test Parameter Type");
52          parameterCode = RandomStringUtils.randomAlphabetic(4).toLowerCase();
53          waitAndTypeByName("document.newMaintainableObject.code", parameterCode);
54          parameterType = "testing " + ITUtil.DTS_TWO;
55          waitAndTypeByName("document.newMaintainableObject.name", parameterType);
56      
57          waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
58          waitAndClickByXpath("//input[@name='methodToCall.route' and @alt='submit']");
59          waitForPageToLoad();
60          assertElementPresentByXpath("//div[contains(div,'Document was successfully submitted.')]", "Document is not submitted successfully");
61          selectTopFrame();
62          waitAndClickByXpath("//a[@title='Document Search']");
63          waitForPageToLoad();
64          selectFrame("iframeportlet");
65          waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
66          Thread.sleep(2000);
67          assertEquals(docId, getTextByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a"));
68          assertEquals("FINAL", getTextByXpath("//table[@id='row']/tbody/tr[1]/td[4]"));
69          selectTopFrame();
70          System.out.println("--------------------------------New Parameter Type Created-------------------------");
71          
72          //Lookup
73          super.gotoMenuLinkLocator();
74          waitAndTypeByName("name", parameterType);
75          waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
76          isElementPresentByLinkText(parameterType);
77          waitAndClickByLinkText(parameterType);
78          waitForPageToLoad();
79          Thread.sleep(2000);
80          switchToWindow("Kuali :: Inquiry");        
81          Thread.sleep(2000);
82          assertEquals(parameterCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim().toLowerCase());
83          assertEquals(parameterType, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim().toLowerCase());
84          waitAndClickByXpath("//*[@title='close this window']");
85          switchToWindow("null");
86          System.out.println("--------------------------------Lookup And View Successful-------------------------");
87          
88          //edit
89          selectFrame("iframeportlet");
90          waitAndClickByLinkText("edit");
91          waitForPageToLoad();
92          docId = getTextByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
93          waitAndTypeByName("document.documentHeader.documentDescription", "Editing Test Parameter");
94          clearTextByName("document.newMaintainableObject.name");
95          parameterType = "testing " + ITUtil.DTS_TWO;
96          waitAndTypeByName("document.newMaintainableObject.name", parameterType);
97          waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
98          waitAndClickByXpath("//input[@name='methodToCall.route' and @alt='submit']");
99          waitForPageToLoad();
100         assertElementPresentByXpath("//div[contains(div,'Document was successfully submitted.')]", "Document is not submitted successfully");
101         selectTopFrame();
102         waitAndClickByXpath("//a[@title='Document Search']");
103         waitForPageToLoad();
104         selectFrame("iframeportlet");
105         waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
106         Thread.sleep(2000);
107         assertEquals(docId, getTextByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a"));
108         assertEquals("FINAL", getTextByXpath("//table[@id='row']/tbody/tr[1]/td[4]"));
109         selectTopFrame();
110         System.out.println("-----------------------------------Parameter Type Edited-------------------------");
111         
112         //Verify if its edited
113         super.gotoMenuLinkLocator();
114         waitAndTypeByName("name", parameterType);
115         waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
116         isElementPresentByLinkText(parameterType);
117         waitAndClickByLinkText(parameterType);
118         waitForPageToLoad();
119         Thread.sleep(2000);
120         switchToWindow("Kuali :: Inquiry");
121         Thread.sleep(2000);
122         assertEquals(parameterCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim().toLowerCase());
123         assertEquals(parameterType, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim().toLowerCase());
124         waitAndClickByXpath("//*[@title='close this window']");
125         switchToWindow("null");
126         
127         
128         //copy
129         selectFrame("iframeportlet");
130         waitAndClickByLinkText("copy");
131         waitForPageToLoad();
132         docId = getTextByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
133         waitAndTypeByName("document.documentHeader.documentDescription", "Copying Test Parameter");
134         parameterCode = RandomStringUtils.randomAlphabetic(4).toLowerCase();
135         waitAndTypeByName("document.newMaintainableObject.code", parameterCode);
136         clearTextByName("document.newMaintainableObject.name");
137         parameterType = "testing " + ITUtil.DTS_TWO;
138         waitAndTypeByName("document.newMaintainableObject.name", parameterType);
139         waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
140         waitAndClickByXpath("//input[@name='methodToCall.route' and @alt='submit']");
141         waitForPageToLoad();
142         assertElementPresentByXpath("//div[contains(div,'Document was successfully submitted.')]", "Document is not submitted successfully");
143         selectTopFrame();
144         waitAndClickByXpath("//a[@title='Document Search']");
145         waitForPageToLoad();
146         selectFrame("iframeportlet");
147         waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
148         Thread.sleep(2000);
149         assertEquals(docId, getTextByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a"));
150         assertEquals("FINAL", getTextByXpath("//table[@id='row']/tbody/tr[1]/td[4]"));
151         selectTopFrame();
152         System.out.println("-----------------------------------Parameter Type Edited-------------------------");
153         
154         //Verify if its copied
155         super.gotoMenuLinkLocator();
156         waitAndTypeByName("name", parameterType);
157         waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
158         isElementPresentByLinkText(parameterType);
159         waitAndClickByLinkText(parameterType);
160         waitForPageToLoad();
161         Thread.sleep(2000);
162         switchToWindow("Kuali :: Inquiry");
163         Thread.sleep(2000);
164         assertEquals(parameterCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim().toLowerCase());
165         assertEquals(parameterType, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim().toLowerCase());
166         waitAndClickByXpath("//*[@title='close this window']");
167         switchToWindow("null");
168     }
169 
170     
171 }