Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SmartCollectionFoundByConditionElement extends AbstractSmartElement {
- @Override
- public WebElement fetchWrappedEntity() {
- SmartElement element = null;
- /*
- зачем переменная
- */
- *********************************
- @Override
- public WebElement fetchWrappedEntity() {
- WebElement element = null;
- try {
- element = parentCollection.getWrappedEntity().get(index);
- } catch (SmartСollectionIndexOutOfBoundsException e) {
- /*
- что тут за эксепшен надо ловить
- вместо какого эксепшена мы собрались кидать SmartСollectionIndexOutOfBoundsException?
- */
- }
- throw new SmartСollectionIndexOutOfBoundsException(element.toString());
- /*
- стоп-стоп
- что мы ищем - описывается - самим лейзи-элементом = this
- как думаешь - в чем разница -
- this.toString() или element.toString()
- ?
- */
- }
- return element;
- }
- ********************************************
- public abstract class AbstractCondition<V> implements Condition<V>, DescribesResult {
- ....
- public V apply(SmartEntity<V> smartEntity) {
- this.smartEntity = smartEntity;
- V wrappedEntity = smartEntity.getWrappedEntity();
- if (check(wrappedEntity)) {
- return wrappedEntity;
- } else {
- throw new WebDriverAssertionException(getClass().getSimpleName());
- }
- /*
- а если после if-блока
- сразу без всяких else
- кидать исключение
- будет хуже?
- мы же вели попали в if-блок
- мы по return выйдем
- соответственно - можно обойтись без else
- */
- }
- ***********************************
- public class SmartFilteredByConditionCollection extends AbstractSmartCollection {
- ...
- @Override
- public List<WebElement> getWrappedEntity() {
- List<WebElement> innerCollection = new ArrayList<>();
- for (SmartElement smartElement:collection) {
- try {
- if (condition.apply(smartElement) != null) {
- innerCollection.add(smartElement);
- }
- } catch (IndexOutOfBoundsException | WebDriverException e) {
- }
- /*
- зато тут ловишь IndexOutOfBoundsException )
- странно)
- */
- }
- return innerCollection;
- }
- }
- ********************************************
- public V until(Condition<V> condition, long timeout) {
- ...
- } catch (IndexOutOfBoundsException | WebDriverException e) {
- lastError = e;
- }
- /*
- и тут ловишь IndexOutOfBoundsException )
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment