当前位置: 首页>>代码示例>>Java>>正文


Java DarcyException类代码示例

本文整理汇总了Java中com.redhat.darcy.ui.DarcyException的典型用法代码示例。如果您正苦于以下问题:Java DarcyException类的具体用法?Java DarcyException怎么用?Java DarcyException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DarcyException类属于com.redhat.darcy.ui包,在下文中一共展示了DarcyException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setContext

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
/**
 * Filters element or list fields, and if their associated objects implement
 * {@link com.redhat.darcy.ui.api.HasElementContext}, calls
 * {@link com.redhat.darcy.ui.api.HasElementContext#setContext(com.redhat.darcy.ui.api.ElementContext)}
 * on those objects with the specified context.
 */
private void setContext(ElementContext context) {
    fields.stream()
            .filter(f -> HasElementContext.class.isAssignableFrom(f.getType())
                    || Element.class.isAssignableFrom(f.getType())
                    || List.class.isAssignableFrom(f.getType()))
            // TODO: .filter(f -> f.getAnnotation(IndependentContext.class) == null)
            .map(f -> {
                try {
                    return f.get(view);
                } catch (IllegalAccessException e) {
                    throw new DarcyException(String.format("Couldn't retrieve get object " +
                            "from field, %s, in view, %s", f, view), e);
                }
            })
            .filter(o -> o instanceof HasElementContext)
            .map(e -> (HasElementContext) e)
            .forEach(e -> e.setContext(context));
}
 
开发者ID:darcy-framework,项目名称:darcy-ui,代码行数:25,代码来源:Initializer.java

示例2: shouldThrowDarcyExceptionWhenAnIOExceptionOccurs

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@Test
public void shouldThrowDarcyExceptionWhenAnIOExceptionOccurs() throws IOException {
    TargetedWebDriver driver = mock(TargetedWebDriver.class);
    Browser browser = new WebDriverBrowser(driver,
            new StubWebDriverParentContext(),
            new StubWebDriverElementContext());

    OutputStream outputStream = mock(OutputStream.class);
    doThrow(new IOException()).when(outputStream).close();

    try {
        browser.takeScreenshot(outputStream);
        fail("Expected DarcyException to be thrown");
    } catch (Exception e) {
        assertThat("Expected DarcyException to be thrown" ,
                e.getClass(), equalTo(DarcyException.class));
    }

    verify(outputStream).close();
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:21,代码来源:TakeScreenshotTest.java

示例3: IdOfHandler

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
public IdOfHandler(Locator locator, Class type, Context context) {
    this.context = context;
    this.type = type;

    original = locator.find(type, context);

    if (!(original instanceof HasAttributes)) {
        throw new DarcyException("Cannot lookup an id for a Findable if it does not implement "
                + "HasAttributes. Findable was, " + original);
    }
}
 
开发者ID:darcy-framework,项目名称:darcy-ui,代码行数:12,代码来源:IdOfHandler.java

示例4: assignContext

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
/**
 * Sets fields annotated with {@link com.redhat.darcy.ui.annotations.Context @Context} with the
 * specified context.
 */
private void assignContext(ElementContext context) {
    fields.stream()
            .filter(f -> f.getAnnotation(Context.class) != null)
            .forEach(f -> {
                try {
                    f.set(view, context);
                } catch (IllegalAccessException | IllegalArgumentException e) {
                    throw new DarcyException("Couldn't assign context to field," + f, e);
                }
            });
}
 
开发者ID:darcy-framework,项目名称:darcy-ui,代码行数:16,代码来源:Initializer.java

示例5: fieldToObject

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
private Object fieldToObject(Field f) {
    try {
        return f.get(view);
    } catch (IllegalAccessException e) {
        throw new DarcyException("Couldn't analyze required fields.", e);
    }
}
 
开发者ID:darcy-framework,项目名称:darcy-ui,代码行数:8,代码来源:Analyzer.java

示例6: RequiredList

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public RequiredList(Field field, Object in) {
    this.genericType = ReflectionUtil.getGenericTypeOfCollectionField(field);
    this.bounds = new RequiredListBounds(field);

    try {
        this.list = (List<T>) field.get(in);
    } catch (IllegalAccessException iae) {
        throw new DarcyException("Couldn't access value of object", iae);
    } catch (ClassCastException cce) {
        throw new IllegalArgumentException("Can not cast field of object to List");
    }
}
 
开发者ID:darcy-framework,项目名称:darcy-ui,代码行数:14,代码来源:RequiredList.java

示例7: get

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
/**
 * Returns something that can create real element implementations of the desired type (that is,
 * an {@link com.redhat.darcy.webdriver.ElementConstructor}), given certain required inputs as
 * defined in
 * {@link ElementConstructor#newElement(com.redhat.darcy.webdriver.internal.ElementLookup, com.redhat.darcy.ui.api.ElementContext)}.
 */
@SuppressWarnings("unchecked")
public <E extends Element> ElementConstructor<E> get(Class<E> type) {
    ElementConstructor<? extends Element> factory = classMap.get(type);
    
    if (factory == null) {
        throw new DarcyException("No element factory registered for " + type);
    }
    
    return (ElementConstructor<E>) factory;
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:17,代码来源:ElementConstructorMap.java

示例8: findByNameOrId

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T findByNameOrId(Class<T> type, String nameOrId) {
    if (!type.isAssignableFrom(WebDriverBrowser.class)) {
        throw new DarcyException("Cannot find contexts of type: " + type);
    }

    WebDriverTarget newTarget = Frame.class.equals(type)
            ? WebDriverTargets.frame(myTarget, nameOrId)
            : WebDriverTargets.window(nameOrId);

    return (T) newBrowser(newTarget);
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:13,代码来源:TargetedWebDriverParentContext.java

示例9: findAllByView

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> List<T> findAllByView(Class<T> type, View view) {
    if (!type.isAssignableFrom(WebDriverBrowser.class)) {
        throw new DarcyException("Cannot find contexts of type: " + type);
    }

    if (Frame.class.equals(type)) {
        throw new DarcyException("Cannot find Frames by view. Unable to iterate through all "
                + "available frames.");
    }

    return (List<T>) new LazyList<>(new FoundByViewSupplier(view));
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:15,代码来源:TargetedWebDriverParentContext.java

示例10: findByView

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T findByView(Class<T> type, View view) {
    if (!type.isAssignableFrom(WebDriverBrowser.class)) {
        throw new DarcyException("Cannot find contexts of type: " + type);
    }

    if (Frame.class.equals(type)) {
        throw new DarcyException("Cannot find Frames by view. Unable to iterate through all "
                + "available frames.");
    }

    return (T) newBrowser(WebDriverTargets.withViewLoaded(view, this));
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:15,代码来源:TargetedWebDriverParentContext.java

示例11: findAllByTitle

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> List<T> findAllByTitle(Class<T> type, String title) {
    if (!type.isAssignableFrom(WebDriverBrowser.class)) {
        throw new DarcyException("Cannot find contexts of type: " + type);
    }

    if (Frame.class.equals(type)) {
        throw new DarcyException("Cannot find Frames by title. Unable to iterate through all "
                + "available frames.");
    }

    return (List<T>) new LazyList<>(new FoundByTitleSupplier(title));
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:15,代码来源:TargetedWebDriverParentContext.java

示例12: findByTitle

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T findByTitle(Class<T> type, String title) {
    if (!type.isAssignableFrom(WebDriverBrowser.class)) {
        throw new DarcyException("Cannot find contexts of type: " + type);
    }

    if (Frame.class.equals(type)) {
        throw new DarcyException("Cannot find Frames by title. Unable to iterate through all "
                + "available frames.");
    }

    return (T) newBrowser(WebDriverTargets.windowByTitle(title));
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:15,代码来源:TargetedWebDriverParentContext.java

示例13: findAllByUrl

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@Override
public <T> List<T> findAllByUrl(Class<T> type, Matcher<? super String> urlMatcher) {
    if (!type.isAssignableFrom(WebDriverBrowser.class)) {
        throw new DarcyException("Cannot find contexts of type: " + type);
    }

    if (Frame.class.equals(type)) {
        throw new DarcyException("Cannot find Frames by url. Unable to iterate through all "
                + "available frames.");
    }

    return (List<T>) new LazyList<>(new FoundByUrlSupplier(urlMatcher));
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:14,代码来源:TargetedWebDriverParentContext.java

示例14: findByUrl

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@Override
public <T> T findByUrl(Class<T> type, Matcher<? super String> urlMatcher) {
    if (!type.isAssignableFrom(WebDriverBrowser.class)) {
        throw new DarcyException("Cannot find contexts of type: " + type);
    }

    if (Frame.class.equals(type)) {
        throw new DarcyException("Cannot find Frames by url. Unable to iterate through all "
                + "available frames.");
    }

    return (T) newBrowser(WebDriverTargets.windowByUrl(urlMatcher));
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:14,代码来源:TargetedWebDriverParentContext.java

示例15: findAllByNested

import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@Override
public <T> List<T> findAllByNested(Class<T> type, Element parent, Locator child) {
    if (!(parent instanceof WebDriverElement)) {
        throw new DarcyException("Parent element is not a WebDriverElement. Can only find " +
                "by nested for fundamental UI element types found by darcy-webdriver.");
    }

    return newElementList(type, new NestedElementListLookup((WebDriverElement) parent, child));
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:10,代码来源:DefaultWebDriverElementContext.java


注:本文中的com.redhat.darcy.ui.DarcyException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。