• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UnexpectedPage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setTicketFieldValue

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
private void setTicketFieldValue(final GepardTestClass tc, final String ticket, final String fieldName, final String value) throws IOException {
    String jiraSetFieldPage = getIssueFieldSetValueUrl(ticket);
    WebRequest requestSettings = new WebRequest(new URL(jiraSetFieldPage), HttpMethod.PUT);
    requestSettings.setAdditionalHeader("Content-type", "application/json");
    requestSettings.setRequestBody("{ \"fields\": {\"" + fieldName + "\": \"" + value + "\"} }");
    try {
        UnexpectedPage infoPage = webClient.getPage(requestSettings);
        if (infoPage.getWebResponse().getStatusCode() == HTTP_RESPONSE_OK) {
            tc.logComment("Field: '" + fieldName + "' of Ticket: " + ticket + " was updated to value: '" + value + "' successfully.");
        } else {
            throw new SimpleGepardException("Ticket: " + ticket + " field: " + fieldName + " update failed, status code: " + infoPage.getWebResponse().getStatusCode());
        }
    } catch (FailingHttpStatusCodeException e) {
        throw new SimpleGepardException("Ticket: " + ticket + " field: " + fieldName + " update failed.", e);
    }
}
 
开发者ID:epam,项目名称:Gepard,代码行数:17,代码来源:JiraSiteHandler.java


示例2: collectIssues

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
/**
 * Get a Jira query result in a map form.
 *
 * @param query is the jira query
 * @return with the map of JIRA_ID - ticketInfo in JSONObject pairs as result of a Jira query.
 * @throws IOException   in case of problem
 * @throws JSONException in case of problem
 */
public ConcurrentHashMap<String, JSONObject> collectIssues(final String query) throws IOException, JSONException {
    String jqlURL = getListOfIssuesByQueryUrl(query);
    WebRequest requestSettings = new WebRequest(new URL(jqlURL), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-type", "application/json");
    UnexpectedPage infoPage = webClient.getPage(requestSettings);
    if (infoPage.getWebResponse().getStatusCode() == HTTP_RESPONSE_OK) {
        String ticketList = infoPage.getWebResponse().getContentAsString();
        JSONObject obj = new JSONObject(ticketList);
        String maxResults = obj.getString("maxResults");
        String total = obj.getString("total");
        if (Integer.valueOf(maxResults) < Integer.valueOf(total)) {
            throw new SimpleGepardException("ERROR: Too many issues belong to given query (" + total + "), please change the query to shorten the result list.");
        }
        JSONArray array = obj.getJSONArray("issues");
        ConcurrentHashMap<String, JSONObject> map = new ConcurrentHashMap<>();
        for (int i = 0; i < array.length(); i++) {
            JSONObject o = (JSONObject) array.get(i);
            map.put(o.getString("key"), o);
        }
        return map;
    }
    throw new SimpleGepardException("ERROR: Cannot fetch Issue list from JIRA, status code:" + infoPage.getWebResponse().getStatusCode());
}
 
开发者ID:epam,项目名称:Gepard,代码行数:32,代码来源:JiraSiteHandler.java


示例3: transferTicketToStatus

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
/**
 * Transition a ticket to next status in its workflow.
 * URL --> https://jira.xxxxxx.com/rest/api/2/issue/TEST-53/transitions?expand=transitions.fields
 * POST data --> {"transition":{"id":91}}
 * Returned HTTP response --> 204
 *
 * @param ticket             is the specific ticket
 * @param statusTransferId   is the id of the transaction that should be used to transfer the ticket
 * @param expectedStatusName is the name of the expected new status
 * @param comment            that will be attached to the ticket as comment of the transaction
 * @return with the new status
 */
private String transferTicketToStatus(final GepardTestClass tc, final String ticket, final String statusTransferId, final String expectedStatusName, final String comment)
        throws IOException, JSONException {
    String updateString = "{ \"update\": { \"comment\": [ { \"add\": { \"body\": \"" + comment + "\" } } ] }, \"transition\": { \"id\": \"" + statusTransferId + "\" } }";
    String oldStatus = detectActualStatus(ticket);
    String newStatus;
    String jiraSetFieldPage = getIssueSetTransitionsUrl(ticket);
    WebRequest requestSettings = new WebRequest(new URL(jiraSetFieldPage), HttpMethod.POST);
    requestSettings.setAdditionalHeader("Content-type", "application/json");
    requestSettings.setRequestBody(updateString);
    try {
        UnexpectedPage infoPage = webClient.getPage(requestSettings);
        if (infoPage.getWebResponse().getStatusCode() == HTTP_RESPONSE_OK) {
            newStatus = detectActualStatus(ticket);
            Assert.assertEquals("Transferring ticket: " + ticket + " to new status failed,", expectedStatusName, newStatus);
            tc.logComment("Ticket: " + ticket + " was transferred from status: \"" + oldStatus + "\" to status: \"" + newStatus + "\" successfully.");
        } else {
            throw new SimpleGepardException("ERROR: Status update failed for ticket: " + ticket + ", Status code:" + infoPage.getWebResponse().getStatusCode());
        }
    } catch (FailingHttpStatusCodeException e) {
        throw new SimpleGepardException("ERROR: Status update failed for ticket: " + ticket + ".", e);
    }
    return newStatus;
}
 
开发者ID:epam,项目名称:Gepard,代码行数:36,代码来源:JiraSiteHandler.java


示例4: getImage

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
public static byte[] getImage(Image image) throws Exception {
    Exception ex = null;

    for (int i = 0; i < NUMBER_OF_TRIES; i++) {
        try (WebClient webClient = createWebClient(image.getLink())) {
            webClient.addRequestHeader("Referer", image.getReferrer());

            UnexpectedPage page = webClient.getPage(image.getLink());

            JavaScriptJobManager manager = page.getEnclosingWindow().getJobManager();
            while (manager.getJobCount() > 0) {
                Thread.sleep(500);
            }

            return IOUtils.toByteArray(page.getWebResponse().getContentAsStream());
        } catch (Exception e) {
            System.err.println("Try " + (i + 1) + " of " + NUMBER_OF_TRIES
                    + ". Link: " + image.getLink() + ". Error: " + e.getMessage());

            ex = e;
        }
    }

    throw ex;
}
 
开发者ID:hurik,项目名称:MangaManagerAndDownloader,代码行数:26,代码来源:HTMLUnitHelper.java


示例5: getNotifications

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
public List<NotificationObject> getNotifications(String ID) throws InvaildCourseException {
	List<NotificationObject> list = new ArrayList<>();
	try {
		WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38);
		webClient.setCookieManager(cookieManager);

		UnexpectedPage page = webClient.getPage("https://pdsb.elearningontario.ca/d2l/MiniBar/" + ID + "/ActivityFeed/GetAlerts?Category=1&_d2l_prc%24headingLevel=2&_d2l_prc%24scope=&_d2l_prc%24hasActiveForm=false&isXhr=true&requestId=2");
		NotificationFormater notificationFormater = new NotificationFormater(page.getWebResponse().getContentAsString());
		
		webClient.close();
		
		for (Object object: notificationFormater.getNotifications()) {
			DomElement de = (DomElement) object;
			String[] split = de.asText().split("\\n");
			
			list.add(new NotificationObject(split[0].trim(), split[1].trim(), split[2].trim()));
		}
	} catch (Exception e) {
		throw new InvaildCourseException("Invaild Course ID");
	}
	
	return list;
}
 
开发者ID:zeshan321,项目名称:Project-D2L,代码行数:24,代码来源:D2LHook.java


示例6: getTicketHistory

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
private String getTicketHistory(final GepardTestClass tc, final String ticketID) throws IOException {
    tc.logComment("Get JIRA history info on ticket: " + ticketID);
    String jiraInfoPage = getIssueChangeLogUrl(ticketID);
    UnexpectedPage infoPage = webClient.getPage(jiraInfoPage);
    String ticketInfo = infoPage.getWebResponse().getContentAsString();
    return ticketInfo;
}
 
开发者ID:epam,项目名称:Gepard,代码行数:8,代码来源:JiraSiteHandler.java


示例7: getJiraServerInfo

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
/**
 * Gets the main Jira Server Information.
 *
 * @return with JSON object with Jira Server Information
 * @throws IOException   in case of problem
 * @throws JSONException in case of problem
 */
public JSONObject getJiraServerInfo() throws IOException, JSONException {
    String jiraServerInfoPage = getServerInfoUrl();
    UnexpectedPage infoPage = webClient.getPage(jiraServerInfoPage);
    String serverInfo = infoPage.getWebResponse().getContentAsString();
    JSONObject obj = new JSONObject(serverInfo);
    return obj;
}
 
开发者ID:epam,项目名称:Gepard,代码行数:15,代码来源:JiraSiteHandler.java


示例8: detectWorkflow

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
/**
 * Detect the actual workflow possibilities of the ticket, from its actual status.
 *
 * @param ticket is the id
 * @return with String representation of the list of possibilities, in form of statusTransferId;newStatusName strings
 * @throws IOException   in case of problem
 * @throws JSONException in case of problem
 */
public String detectWorkflow(final String ticket) throws IOException, JSONException {
    String jqlURL;

    //first detect status
    String ticketFields = getTicketFields(ticket);
    JSONObject fieldObj = new JSONObject(ticketFields);
    fieldObj = fieldObj.getJSONObject("fields");
    fieldObj = fieldObj.getJSONObject("status");
    String status = "@" + fieldObj.get("name").toString();

    //then collect possible transactions
    jqlURL = getIssueTransitionsUrl(ticket);
    WebRequest requestSettings = new WebRequest(new URL(jqlURL), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-type", "application/json");
    UnexpectedPage infoPage = webClient.getPage(requestSettings);
    if (infoPage.getWebResponse().getStatusCode() == HTTP_RESPONSE_OK) {
        String ticketList = infoPage.getWebResponse().getContentAsString();
        JSONObject obj = new JSONObject(ticketList);
        JSONArray array = obj.getJSONArray("transitions");
        List<String> toList = new ArrayList<>();
        toList.add(status);
        for (int i = 0; i < array.length(); i++) {
            JSONObject o = (JSONObject) array.get(i);
            JSONObject o2 = o.getJSONObject("to");
            String toPossibility = o2.get("name").toString();
            String toPossibilityID = o.get("id").toString(); //it is the transition id not the status id
            toList.add(toPossibilityID + ";" + toPossibility);
        }
        return toList.toString();
    }
    throw new SimpleGepardException("ERROR: Cannot fetch Issue transition possibilities from JIRA, for ticket: "
            + ticket + ", Status code:" + infoPage.getWebResponse().getStatusCode());
}
 
开发者ID:epam,项目名称:Gepard,代码行数:42,代码来源:JiraSiteHandler.java


示例9: getAttachmentAtEndOfLink

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
public static String getAttachmentAtEndOfLink(final HtmlAnchor link) throws IOException {
  UnexpectedPage attachment = (UnexpectedPage) link.click();
  BufferedReader in = new BufferedReader(new InputStreamReader(attachment.getInputStream()));
  try {
    return IOUtils.toString(in).trim();
  }
  finally {
    in.close();
  }
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:11,代码来源:TestAttachments.java


示例10: getPageSource

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
/**
 * Get source of any page type.
 */
public static String getPageSource(final Page page) {
  if (page instanceof HtmlPage) {
    return ((HtmlPage) page).asXml();
  } else if (page instanceof JavaScriptPage) {
    return ((JavaScriptPage) page).getContent();
  } else if (page instanceof TextPage) {
    return ((TextPage) page).getContent();
  } else {
    // page instanceof UnexpectedPage
    return ((UnexpectedPage) page).getWebResponse().getContentAsString();
  }
}
 
开发者ID:jpschewe,项目名称:fll-sw,代码行数:16,代码来源:WebTestUtils.java


示例11: getTicketFields

import com.gargoylesoftware.htmlunit.UnexpectedPage; //导入依赖的package包/类
private String getTicketFields(String ticket) throws IOException {
    String jiraInfoPage = getIssueFieldValueUrl(ticket);
    UnexpectedPage infoPage = webClient.getPage(jiraInfoPage);
    String ticketInfo = infoPage.getWebResponse().getContentAsString();
    return ticketInfo;
}
 
开发者ID:epam,项目名称:Gepard,代码行数:7,代码来源:JiraSiteHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContentFrameLayout类代码示例发布时间:2022-05-22
下一篇:
Java Properties类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap