當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。