|
| 1 | +/* |
| 2 | + * Copyright (c) 2016 seleniumQuery authors |
| 3 | + * |
| 4 | + * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 |
| 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 | + |
| 17 | +package testinfrastructure.testdouble.io.github.seleniumquery; |
| 18 | + |
| 19 | +import com.google.common.base.Predicate; |
| 20 | +import io.github.seleniumquery.SeleniumQueryObject; |
| 21 | +import io.github.seleniumquery.functions.SeleniumQueryFunctions; |
| 22 | +import io.github.seleniumquery.functions.as.SeleniumQueryPlugin; |
| 23 | +import io.github.seleniumquery.functions.as.StandardPlugins; |
| 24 | +import org.openqa.selenium.By; |
| 25 | +import org.openqa.selenium.WebDriver; |
| 26 | +import org.openqa.selenium.WebElement; |
| 27 | +import testinfrastructure.testdouble.PseudoTestDoubleException; |
| 28 | + |
| 29 | +import java.util.Collections; |
| 30 | +import java.util.Iterator; |
| 31 | +import java.util.List; |
| 32 | + |
| 33 | +/** |
| 34 | + * Creates a "smart" dummy {@link SeleniumQueryObject}. It's goal is to be a mere placeholder in a test |
| 35 | + * fixture. It is "smart" because any method call to it will throw an exception (which indicates the dummy |
| 36 | + * is actually not a simple placeholder - since it is being used by the SUT when it shouldn't). |
| 37 | + */ |
| 38 | +public class SeleniumQueryObjectDummy extends SeleniumQueryObject { |
| 39 | + |
| 40 | + public static SeleniumQueryObject createSeleniumQueryObjectDummy() { |
| 41 | + return new SeleniumQueryObjectDummy(); |
| 42 | + } |
| 43 | + |
| 44 | + private SeleniumQueryObjectDummy() { |
| 45 | + super(null, null, null, Collections.<WebElement>emptyList(), null); |
| 46 | + } |
| 47 | + |
| 48 | + @Override public StandardPlugins as() { throw new PseudoTestDoubleException(); } |
| 49 | + @Override public <PLUGIN> PLUGIN as(SeleniumQueryPlugin<PLUGIN> pluginFunction) { throw new PseudoTestDoubleException(); } |
| 50 | + @Override public Iterator<WebElement> iterator() { throw new PseudoTestDoubleException(); } |
| 51 | + @Override public WebDriver getWebDriver() { throw new PseudoTestDoubleException(); } |
| 52 | + @Override public By getBy() { throw new PseudoTestDoubleException(); } |
| 53 | + @Override public SeleniumQueryFunctions getSeleniumQueryFunctions() { throw new PseudoTestDoubleException(); } |
| 54 | + @Override public int size() { throw new PseudoTestDoubleException(); } |
| 55 | + @Override public SeleniumQueryObject not(String selector) { throw new PseudoTestDoubleException(); } |
| 56 | + @Override public SeleniumQueryObject first() { throw new PseudoTestDoubleException(); } |
| 57 | + @Override public SeleniumQueryObject last() { throw new PseudoTestDoubleException(); } |
| 58 | + @Override public SeleniumQueryObject eq(int index) { throw new PseudoTestDoubleException(); } |
| 59 | + @Override public String text() { throw new PseudoTestDoubleException(); } |
| 60 | + @Override public SeleniumQueryObject click() { throw new PseudoTestDoubleException(); } |
| 61 | + @Override public SeleniumQueryObject val(String value) { throw new PseudoTestDoubleException(); } |
| 62 | + @Override public SeleniumQueryObject val(Number value) { throw new PseudoTestDoubleException(); } |
| 63 | + @Override public String val() { throw new PseudoTestDoubleException(); } |
| 64 | + @Override public SeleniumQueryObject end() { throw new PseudoTestDoubleException(); } |
| 65 | + @Override public SeleniumQueryObject find(String selector) { throw new PseudoTestDoubleException(); } |
| 66 | + @Override public String attr(String attributeName) { throw new PseudoTestDoubleException(); } |
| 67 | + @Override public SeleniumQueryObject attr(String attributeName, Object value) { throw new PseudoTestDoubleException(); } |
| 68 | + @Override public <T> T prop(String propertyName) { throw new PseudoTestDoubleException(); } |
| 69 | + @Override public SeleniumQueryObject prop(String propertyName, Object value) { throw new PseudoTestDoubleException(); } |
| 70 | + @Override public WebElement get(int index) { throw new PseudoTestDoubleException(); } |
| 71 | + @Override public List<WebElement> get() { throw new PseudoTestDoubleException(); } |
| 72 | + @Override public SeleniumQueryObject removeAttr(String attributeNames) { throw new PseudoTestDoubleException(); } |
| 73 | + @Override public String html() { throw new PseudoTestDoubleException(); } |
| 74 | + @Override public boolean is(String selector) { throw new PseudoTestDoubleException(); } |
| 75 | + @Override public boolean hasClass(String className) { throw new PseudoTestDoubleException(); } |
| 76 | + @Override public WebElement[] toArray() { throw new PseudoTestDoubleException(); } |
| 77 | + @Override public SeleniumQueryObject closest(String selector) { throw new PseudoTestDoubleException(); } |
| 78 | + @Override public SeleniumQueryObject focus() { throw new PseudoTestDoubleException(); } |
| 79 | + @Override public SeleniumQueryObject children() { throw new PseudoTestDoubleException(); } |
| 80 | + @Override public SeleniumQueryObject children(String selector) { throw new PseudoTestDoubleException(); } |
| 81 | + @Override public SeleniumQueryObject parent() { throw new PseudoTestDoubleException(); } |
| 82 | + @Override public SeleniumQueryObject parent(String selector) { throw new PseudoTestDoubleException(); } |
| 83 | + @Override public SeleniumQueryObject submit() { throw new PseudoTestDoubleException(); } |
| 84 | + @SuppressWarnings("deprecation") @Override public SeleniumQueryObject selectOptionByVisibleText(String text) { throw new PseudoTestDoubleException(); } |
| 85 | + @SuppressWarnings("deprecation") @Override public SeleniumQueryObject selectOptionByValue(String value) { throw new PseudoTestDoubleException(); } |
| 86 | + @Override public String toString() { throw new PseudoTestDoubleException(); } |
| 87 | + @Override public SeleniumQueryObject filter(Predicate<WebElement> filterFunction) { throw new PseudoTestDoubleException(); } |
| 88 | + |
| 89 | +} |
0 commit comments