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 edu.samplu.common.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("Fixed Point Constraint"); 042 } 043 044 protected void testValidationRegexBasedConstraintsPhone() throws Exception { 045 //Scenario-1 046 waitAndTypeByName("inputField1","1234567890"); 047 waitAndClickByLinkText("Usage"); 048 assertElementPresentByXpath("//input[@name='inputField1' and @class='uif-textControl validChar-inputField10 dirty error']"); 049 } 050 051 protected void testValidationRegexBasedConstraintsEmail() throws Exception { 052 waitAndClickByLinkText("Email"); 053 054 //Scenario-1 055 waitAndTypeByName("inputField2","s1!@f.xoh"); 056 waitAndClickByLinkText("Usage"); 057 assertElementPresentByXpath("//input[@name='inputField2' and @class='uif-textControl validChar-inputField20 dirty error']"); 058 } 059 060 protected void testValidationRegexBasedConstraintsUrl() throws Exception { 061 waitAndClickByLinkText("Url"); 062 063 //Scenario-1 064 waitAndTypeByName("inputField3","www.google.com"); 065 waitAndClickByLinkText("Usage"); 066 assertElementPresentByXpath("//input[@name='inputField3' and @class='uif-textControl validChar-inputField30 dirty error']"); 067 } 068 069 protected void testValidationRegexBasedConstraintsNowhitespace() throws Exception { 070 waitAndClickByLinkText("No whitespace"); 071 072 //Scenario-1 073 waitAndTypeByName("inputField4","aw e"); 074 waitAndClickByLinkText("Usage"); 075 assertElementPresentByXpath("//input[@name='inputField4' and @class='uif-textControl validChar-inputField40 dirty error']"); 076 } 077 078 protected void testValidationRegexBasedConstraints12hTime() throws Exception { 079 waitAndClickByLinkText("12h Time"); 080 081 //Scenario-1 082 waitAndTypeByName("inputField5","22:00"); 083 waitAndClickByLinkText("Usage"); 084 085 //Currently this field is not working 086 //assertElementPresentByXpath("//input[@name='inputField5' and @class='uif-textControl validChar-inputField50 dirty error']"); 087 } 088 089 protected void testValidationRegexBasedConstraints24hTime() throws Exception { 090 waitAndClickByLinkText("24h Time"); 091 092 //Scenario-1 093 waitAndTypeByName("inputField6","01:00AM"); 094 waitAndClickByLinkText("Usage"); 095 096 //Currently this field is not working 097 //assertElementPresentByXpath("//input[@name='inputField6' and @class='uif-textControl validChar-inputField60 dirty error']"); 098 } 099 100 protected void testValidationRegexBasedConstraintsTimestamp() throws Exception { 101 waitAndClickByLinkText("Timestamp"); 102 103 //Scenario-1 104 waitAndTypeByName("inputField7","1234-12-30 23:23:23.23"); 105 waitAndClickByLinkText("Usage"); 106 assertElementPresentByXpath("//input[@name='inputField7' and @class='uif-textControl validChar-inputField70 dirty error']"); 107 } 108 109 protected void testValidationRegexBasedConstraintsYear() throws Exception { 110 waitAndClickByLinkText("Year"); 111 112 //Scenario-1 113 waitAndTypeByName("inputField8","1599"); 114 waitAndClickByLinkText("Usage"); 115 assertElementPresentByXpath("//input[@name='inputField8' and @class='uif-textControl validChar-inputField80 dirty error']"); 116 } 117 118 protected void testValidationRegexBasedConstraintsMonth() throws Exception { 119 waitAndClickByLinkText("Month"); 120 121 //Scenario-1 122 waitAndTypeByName("inputField9","13"); 123 waitAndClickByLinkText("Usage"); 124 assertElementPresentByXpath("//input[@name='inputField9' and @class='uif-textControl validChar-inputField90 dirty error']"); 125 } 126 127 protected void testValidationRegexBasedConstraintsZipcode() throws Exception { 128 waitAndClickByLinkText("Zipcode"); 129 130 //Scenario-1 131 waitAndTypeByName("inputField10","94101"); 132 waitAndClickByLinkText("Usage"); 133 134 //Currently not working 135 //assertElementPresentByXpath("//input[@name='inputField10' and @class='uif-textControl validChar-inputField100 dirty error']"); 136 } 137 138 protected void testValidationRegexBasedConstraintsJavaclassname() throws Exception { 139 waitAndClickByLinkText("Java classname"); 140 141 //Scenario-1 142 waitAndTypeByName("inputField11","asdf"); 143 waitAndClickByLinkText("Usage"); 144 145 //Currently not working 146 //assertElementPresentByXpath("//input[@name='inputField11' and @class='uif-textControl validChar-inputField110 dirty error']"); 147 } 148 149 protected void testValidationRegexBasedConstraintsCustom() throws Exception { 150 waitAndClickByLinkText("Custom"); 151 152 //Scenario-1 153 waitAndTypeByName("inputField12","ab.9"); 154 waitAndTypeByName("inputField13","Demo-hi hello"); 155 waitAndClickByLinkText("Usage"); 156 assertElementPresentByXpath("//input[@name='inputField12' and @class='uif-textControl validChar-inputField120 dirty error']"); 157 assertElementPresentByXpath("//input[@name='inputField13' and @class='uif-textControl validChar-inputField130 dirty error']"); 158 } 159 160 @Test 161 public void testValidationRegexBasedConstraintsBookmark() throws Exception { 162 testValidationRegexBasedConstraintsPhone(); 163 testValidationRegexBasedConstraintsEmail(); 164 testValidationRegexBasedConstraintsUrl(); 165 testValidationRegexBasedConstraintsNowhitespace(); 166 testValidationRegexBasedConstraints12hTime(); 167 testValidationRegexBasedConstraints24hTime(); 168 testValidationRegexBasedConstraintsTimestamp(); 169 testValidationRegexBasedConstraintsYear(); 170 testValidationRegexBasedConstraintsMonth(); 171 testValidationRegexBasedConstraintsZipcode(); 172 testValidationRegexBasedConstraintsJavaclassname(); 173 testValidationRegexBasedConstraintsCustom(); 174 passed(); 175 } 176 177 @Test 178 public void testValidationRegexBasedConstraintsNav() throws Exception { 179 testValidationRegexBasedConstraintsPhone(); 180 testValidationRegexBasedConstraintsEmail(); 181 testValidationRegexBasedConstraintsUrl(); 182 testValidationRegexBasedConstraintsNowhitespace(); 183 testValidationRegexBasedConstraints12hTime(); 184 testValidationRegexBasedConstraints24hTime(); 185 testValidationRegexBasedConstraintsTimestamp(); 186 testValidationRegexBasedConstraintsYear(); 187 testValidationRegexBasedConstraintsMonth(); 188 testValidationRegexBasedConstraintsZipcode(); 189 testValidationRegexBasedConstraintsJavaclassname(); 190 testValidationRegexBasedConstraintsCustom(); 191 passed(); 192 } 193 }