@JsonRpcErrors({@JsonRpcError(exception = CustomTestException.class, code = 1234)}) Object testMethod(); }
private JsonRpcError getResolverForException(Throwable thrownException, Method method) { JsonRpcErrors errors = ReflectionUtil.getAnnotation(method, JsonRpcErrors.class); if (hasAnnotations(errors)) { for (JsonRpcError errorDefined : errors.value()) { if (isExceptionInstanceOfError(thrownException, errorDefined)) { return errorDefined; } } } return null; }
@JsonRpcErrors({@JsonRpcError(exception = CustomTestException.class, code = -5678, message = "The message", data = "The data")}) Object testMethod(); }
/** * Get last block * @return the latest block */ @JsonRpcErrors({ @JsonRpcError(exception = NonExistObjectException.class, code = NonExistObjectException.code)}) BlockDto getLastBlock(@JsonRpcParam(value = BRANCH_ID) String branchId); }
/** * Creates new message call transaction or a contract creation, * if the data field contains code. * * @param tx The transaction */ @JsonRpcErrors({ @JsonRpcError(exception = FailedOperationException.class, code = FailedOperationException.code)}) String sendTransaction(@JsonRpcParam(value = "tx") TransactionDto tx);
/** * Client send a requestCommand message, node return a responseCommand message. * * @param command The command data */ @JsonRpcErrors({ @JsonRpcError(exception = FailedOperationException.class, code = FailedOperationException.code)}) String requestCommand(@JsonRpcParam(value = "command") AdminDto command);
/** * Simulates a short press using key name. * @param key possible key name is home, back, left, right, up, down, center, menu, search, enter, delete(or del), recent(recent apps), volume_up, volume_down, volume_mute, camera, power * @return true if successful, else return false * @throws RemoteException */ @JsonRpcErrors({@JsonRpcError(exception=RemoteException.class, code=ERROR_CODE_BASE-1)}) boolean pressKey(String key) throws RemoteException;
/** * Long clicks bottom and right corner of the UI element * @param obj the target ui object. * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means TopLeft, "center" means Center. * @return true if operation was successful * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean longClick(Selector obj, String corner) throws UiObjectNotFoundException;
/** * Scrolls to the beginning of a scrollable layout element. The beginning can be at the top-most edge in the case of vertical controls, or the left-most edge for horizontal controls. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew. * @param obj the selector of the scrollable object * @param isVertical vertical or horizontal * @param maxSwipes max swipes to be performed. * @param steps use steps to control the speed, so that it may be a scroll, or fling * @return true on scrolled else false * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean scrollToBeginning(Selector obj, boolean isVertical, int maxSwipes, int steps) throws UiObjectNotFoundException;
/** * Scrolls to the end of a scrollable layout element. The end can be at the bottom-most edge in the case of vertical controls, or the right-most edge for horizontal controls. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew. * @param obj the selector of the scrollable object * @param isVertical vertical or horizontal * @param maxSwipes max swipes to be performed. * @param steps use steps to control the speed, so that it may be a scroll, or fling * @return true on scrolled, else false * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean scrollToEnd(Selector obj, boolean isVertical, int maxSwipes, int steps) throws UiObjectNotFoundException;
/** * Reads the text property of the UI element * @param obj the id of the UiObject. * @return text value of the current node represented by this UiObject * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) String getText(String obj) throws UiObjectNotFoundException;
/** * Performs a click at the center of the visible bounds of the UI element represented by this UiObject. * @param obj the id of target ui object. * @return true id successful else false * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean click(String obj) throws UiObjectNotFoundException;
/** * Long clicks the center of the visible bounds of the UI element * @param obj the id of target ui object. * @return true if operation was successful * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean longClick(String obj) throws UiObjectNotFoundException;
/** * Performs a swipe from one coordinate to another coordinate. You can control the smoothness and speed of the swipe by specifying the number of steps. Each step execution is throttled to 5 milliseconds per step, so for a 100 steps, the swipe will take around 0.5 seconds to complete. * @param startX X-axis value for the starting coordinate * @param startY Y-axis value for the starting coordinate * @param endX X-axis value for the ending coordinate * @param endY Y-axis value for the ending coordinate * @param steps is the number of steps for the swipe action * @return true if swipe is performed, false if the operation fails or the coordinates are invalid * @throws NotImplementedException */ @JsonRpcErrors({@JsonRpcError(exception=NotImplementedException.class, code=ERROR_CODE_BASE-3)}) boolean drag(int startX, int startY, int endX, int endY, int steps) throws NotImplementedException;
/** * Helper method used for debugging to dump the current window's layout hierarchy. * @param compressed use compressed layout hierarchy or not using setCompressedLayoutHeirarchy method. Ignore the parameter in case the API level lt 18. * @return the absolute path name of dumped file. */ @JsonRpcErrors({@JsonRpcError(exception=UiAutomator2Exception.class, code=ERROR_CODE_BASE)}) String dumpWindowHierarchy(boolean compressed);
/** * Performs a fling gesture to reach the end of a scrollable layout element. The end can be at the bottom-most edge in the case of vertical controls, or the right-most edge for horizontal controls. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew. * @param obj the selector of the scrollable object * @param isVertical vertical or horizontal * @param maxSwipes max swipes to achieve end. * @return true on scrolled, else false * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean flingToEnd(Selector obj, boolean isVertical, int maxSwipes) throws UiObjectNotFoundException;
/** * Performs a forward scroll with the default number of scroll steps (55). If the swipe direction is set to vertical, then the swipes will be performed from bottom to top. If the swipe direction is set to horizontal, then the swipes will be performed from right to left. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew. * @param obj the selector of the scrollable object * @param isVertical vertical or horizontal * @param steps number of steps. Use this to control the speed of the scroll action. * @return true on scrolled, else false * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean scrollForward(Selector obj, boolean isVertical, int steps) throws UiObjectNotFoundException;
/** * Perform a scroll forward action to move through the scrollable layout element until a visible item that matches the selector is found. * @param obj the selector of the scrollable object * @param targetObj the item matches the selector to be found. * @param isVertical vertical or horizontal * @return true on scrolled, else false * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean scrollTo(Selector obj, Selector targetObj, boolean isVertical) throws UiObjectNotFoundException;
/** * Searches for child UI element within the constraints of this UiSelector. It looks for any child matching the childPattern argument that has a child UI element anywhere within its sub hierarchy that is at the instance specified. The operation is performed only on the visible items and no scrolling is performed in this case. * @param collection Selector of UiCollection or UiScrollable * @param child UiSelector selector of the child pattern to match and return * @param instance int the desired matched instance of this childPattern * @return A string ID represent the returned UiObject. */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) String childByInstance(Selector collection, Selector child, int instance) throws UiObjectNotFoundException;
/** * Sets the text in an editable field, after clearing the field's content. The UiSelector selector of this object must reference a UI element that is editable. When you call this method, the method first simulates a click() on editable field to set focus. The method then clears the field's contents and injects your specified text into the field. If you want to capture the original contents of the field, call getText() first. You can then modify the text and use this method to update the field. * @param obj the id of the UiObject. * @param text string to set * @return true if operation is successful * @throws UiObjectNotFoundException */ @JsonRpcErrors({@JsonRpcError(exception=UiObjectNotFoundException.class, code=ERROR_CODE_BASE-2)}) boolean setText(String obj, String text) throws UiObjectNotFoundException;