001 /** 002 * Copyright 2005-2013 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 edu.samplu.krad.library.validation; 017 018 import org.junit.Test; 019 020 import org.kuali.rice.testtools.selenium.SmokeTestBase; 021 022 /** 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025 public class DemoLibraryValidationRegexBasedConstraintsSmokeTest extends SmokeTestBase { 026 027 /** 028 * /kr-krad/kradsampleapp?viewId=Demo-ConfigurationBasedRegexPatternConstraint-View&methodToCall=start 029 */ 030 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-ConfigurationBasedRegexPatternConstraint-View&methodToCall=start"; 031 032 @Override 033 protected String getBookmarkUrl() { 034 return BOOKMARK_URL; 035 } 036 037 @Override 038 protected void navigate() throws Exception { 039 waitAndClickById("Demo-LibraryLink", ""); 040 waitAndClickByLinkText("Validation"); 041 waitAndClickByLinkText("Regex Based Constraints"); 042 } 043 044 protected void testValidationRegexBasedConstraintsPhone() throws Exception { 045 //Scenario-1 046 waitAndTypeByName("inputField1","1234567890"); 047 waitAndClickByLinkText("Usage"); 048 fireEvent("inputField1", "focus"); 049 Thread.sleep(200); 050 assertElementPresentByXpath("//input[@name='inputField1' and @class='uif-textControl validChar-inputField10 dirty error']"); 051 } 052 053 protected void testValidationRegexBasedConstraintsEmail() throws Exception { 054 waitAndClickByLinkText("Email"); 055 056 //Scenario-1 057 waitAndTypeByName("inputField2","s1!@f.xoh"); 058 waitAndClickByLinkText("Usage"); 059 assertElementPresentByXpath("//input[@name='inputField2' and @class='uif-textControl validChar-inputField20 dirty error']"); 060 } 061 062 protected void testValidationRegexBasedConstraintsUrl() throws Exception { 063 waitAndClickByLinkText("Url"); 064 065 //Scenario-1 066 waitAndTypeByName("inputField3","www.google.com"); 067 waitAndClickByLinkText("Usage"); 068 assertElementPresentByXpath("//input[@name='inputField3' and @class='uif-textControl validChar-inputField30 dirty error']"); 069 } 070 071 protected void testValidationRegexBasedConstraintsNowhitespace() throws Exception { 072 waitAndClickByLinkText("No whitespace"); 073 074 //Scenario-1 075 waitAndTypeByName("inputField4","aw e"); 076 waitAndClickByLinkText("Usage"); 077 assertElementPresentByXpath("//input[@name='inputField4' and @class='uif-textControl validChar-inputField40 dirty error']"); 078 } 079 080 protected void testValidationRegexBasedConstraints12hTime() throws Exception { 081 waitAndClickByLinkText("12h Time"); 082 083 //Scenario-1 084 waitAndTypeByName("inputField5","22:00"); 085 waitAndClickByLinkText("Usage"); 086 087 //Currently this field is not working 088 //assertElementPresentByXpath("//input[@name='inputField5' and @class='uif-textControl validChar-inputField50 dirty error']"); 089 } 090 091 protected void testValidationRegexBasedConstraints24hTime() throws Exception { 092 waitAndClickByLinkText("24h Time"); 093 094 //Scenario-1 095 waitAndTypeByName("inputField6","01:00AM"); 096 waitAndClickByLinkText("Usage"); 097 098 //Currently this field is not working 099 //assertElementPresentByXpath("//input[@name='inputField6' and @class='uif-textControl validChar-inputField60 dirty error']"); 100 } 101 102 protected void testValidationRegexBasedConstraintsTimestamp() throws Exception { 103 waitAndClickByLinkText("Timestamp"); 104 105 //Scenario-1 106 waitAndTypeByName("inputField7","1234-12-30 23:23:23.23"); 107 waitAndClickByLinkText("Usage"); 108 assertElementPresentByXpath("//input[@name='inputField7' and @class='uif-textControl validChar-inputField70 dirty error']"); 109 } 110 111 protected void testValidationRegexBasedConstraintsYear() throws Exception { 112 waitAndClickByLinkText("Year"); 113 114 //Scenario-1 115 waitAndTypeByName("inputField8","1599"); 116 waitAndClickByLinkText("Usage"); 117 assertElementPresentByXpath("//input[@name='inputField8' and @class='uif-textControl validChar-inputField80 dirty error']"); 118 } 119 120 protected void testValidationRegexBasedConstraintsMonth() throws Exception { 121 waitAndClickByLinkText("Month"); 122 123 //Scenario-1 124 waitAndTypeByName("inputField9","13"); 125 waitAndClickByLinkText("Usage"); 126 assertElementPresentByXpath("//input[@name='inputField9' and @class='uif-textControl validChar-inputField90 dirty error']"); 127 } 128 129 protected void testValidationRegexBasedConstraintsZipcode() throws Exception { 130 waitAndClickByLinkText("Zipcode"); 131 132 //Scenario-1 133 waitAndTypeByName("inputField10","94101"); 134 waitAndClickByLinkText("Usage"); 135 136 //Currently not working 137 //assertElementPresentByXpath("//input[@name='inputField10' and @class='uif-textControl validChar-inputField100 dirty error']"); 138 } 139 140 protected void testValidationRegexBasedConstraintsJavaclassname() throws Exception { 141 waitAndClickByLinkText("Java classname"); 142 143 //Scenario-1 144 waitAndTypeByName("inputField11","asdf"); 145 waitAndClickByLinkText("Usage"); 146 147 //Currently not working 148 //assertElementPresentByXpath("//input[@name='inputField11' and @class='uif-textControl validChar-inputField110 dirty error']"); 149 } 150 151 protected void testValidationRegexBasedConstraintsCustom() throws Exception { 152 waitAndClickByLinkText("Custom"); 153 154 //Scenario-1 155 waitAndTypeByName("inputField12","ab.9"); 156 waitAndTypeByName("inputField13","Demo-hi hello"); 157 waitAndClickByLinkText("Usage"); 158 assertElementPresentByXpath("//input[@name='inputField12' and @class='uif-textControl validChar-inputField120 dirty error']"); 159 assertElementPresentByXpath("//input[@name='inputField13' and @class='uif-textControl validChar-inputField130 dirty error']"); 160 } 161 162 @Test 163 public void testValidationRegexBasedConstraintsBookmark() throws Exception { 164 testValidationRegexBasedConstraintsPhone(); 165 testValidationRegexBasedConstraintsEmail(); 166 testValidationRegexBasedConstraintsUrl(); 167 testValidationRegexBasedConstraintsNowhitespace(); 168 testValidationRegexBasedConstraints12hTime(); 169 testValidationRegexBasedConstraints24hTime(); 170 testValidationRegexBasedConstraintsTimestamp(); 171 testValidationRegexBasedConstraintsYear(); 172 testValidationRegexBasedConstraintsMonth(); 173 testValidationRegexBasedConstraintsZipcode(); 174 testValidationRegexBasedConstraintsJavaclassname(); 175 testValidationRegexBasedConstraintsCustom(); 176 passed(); 177 } 178 179 @Test 180 public void testValidationRegexBasedConstraintsNav() throws Exception { 181 testValidationRegexBasedConstraintsPhone(); 182 testValidationRegexBasedConstraintsEmail(); 183 testValidationRegexBasedConstraintsUrl(); 184 testValidationRegexBasedConstraintsNowhitespace(); 185 testValidationRegexBasedConstraints12hTime(); 186 testValidationRegexBasedConstraints24hTime(); 187 testValidationRegexBasedConstraintsTimestamp(); 188 testValidationRegexBasedConstraintsYear(); 189 testValidationRegexBasedConstraintsMonth(); 190 testValidationRegexBasedConstraintsZipcode(); 191 testValidationRegexBasedConstraintsJavaclassname(); 192 testValidationRegexBasedConstraintsCustom(); 193 passed(); 194 } 195 196 @Test 197 public void testValidationRegexBasedConstraintsEmailNav() throws Exception { 198 testValidationRegexBasedConstraintsEmail(); 199 passed(); 200 } 201 }