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


Java LoggedRequest.queryParameter方法代码示例

本文整理汇总了Java中com.github.tomakehurst.wiremock.verification.LoggedRequest.queryParameter方法的典型用法代码示例。如果您正苦于以下问题:Java LoggedRequest.queryParameter方法的具体用法?Java LoggedRequest.queryParameter怎么用?Java LoggedRequest.queryParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.tomakehurst.wiremock.verification.LoggedRequest的用法示例。


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

示例1: testLogSearchWithMinimumParameters

import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入方法依赖的package包/类
@Test
public void testLogSearchWithMinimumParameters() throws Exception {
    stubSolrUrl();

    LogSearchCriteria logSearchCriteria = new LogSearchCriteria.Builder(TEST_APP_ID, TEST_FROM, TEST_TO).build();
    LogSearchResult result = logSearch.search(logSearchCriteria);
    verifyLogSearchResults(result);

    // please note that space should be escaped to '+' since Wiremock doesn't handle it when matching...
    String dateRangeValue = "%s:[%s+TO+%s]";

    Instant fromInstant = Instant.ofEpochMilli(TEST_FROM);
    Instant toInstant = Instant.ofEpochMilli(TEST_TO);

    dateRangeValue = String.format(dateRangeValue, COLUMN_NAME_LOG_TIME, fromInstant.toString(), toInstant.toString());

    String expectedLogLevels = "(" + String.join("+OR+", AmbariInfraWithStormLogSearch.DEFAULT_LOG_LEVELS) + ")";

    List<LoggedRequest> requests = wireMockRule.findAll(getRequestedFor(urlPathEqualTo(STUB_REQUEST_API_PATH)));
    assertEquals(1, requests.size());

    LoggedRequest request = requests.get(0);

    QueryParameter qParam = request.queryParameter("q");
    assertTrue(qParam.containsValue(COLUMN_NAME_LOG_MESSAGE + ":*"));

    QueryParameter fqParam = request.queryParameter("fq");
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_TOPOLOGY_ID + ":" + TEST_APP_ID));
    assertTrue(fqParam.containsValue(COLUMN_NAME_TYPE + ":" + COLUMN_VALUE_TYPE_WORKER_LOG));
    assertTrue(fqParam.containsValue(dateRangeValue));
    assertTrue(fqParam.containsValue(COLUMN_NAME_LOG_LEVEL + ":" + expectedLogLevels));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_COMPONENT_NAME)));

    QueryParameter sortParam = request.queryParameter("sort");
    assertTrue(sortParam.containsValue(COLUMN_NAME_LOG_TIME + "+asc"));
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:37,代码来源:AmbariInfraWithStormLogSearchTest.java

示例2: testLogSearchWithSingleComponentNameAndLogLevelParameters

import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入方法依赖的package包/类
@Test
public void testLogSearchWithSingleComponentNameAndLogLevelParameters() throws Exception {
    stubSolrUrl();

    int testStart = 100;
    int testLimit = 2000;
    List<String> testLogLevels = Collections.singletonList("INFO");
    String testSearchString = "helloworld";
    List<String> testComponentNames = Collections.singletonList("testComponent");

    LogSearchCriteria logSearchCriteria = new LogSearchCriteria.Builder(TEST_APP_ID, TEST_FROM, TEST_TO)
        .setLogLevels(testLogLevels)
        .setSearchString(testSearchString)
        .setComponentNames(testComponentNames)
        .setStart(testStart)
        .setLimit(testLimit)
        .build();

    LogSearchResult result = logSearch.search(logSearchCriteria);

    // note that the result doesn't change given that we just provide same result from file
    verifyLogSearchResults(result);

    // others are covered from testLogSearchWithFullParameters()

    List<LoggedRequest> requests = wireMockRule.findAll(getRequestedFor(urlPathEqualTo(STUB_REQUEST_API_PATH)));
    assertEquals(1, requests.size());

    LoggedRequest request = requests.get(0);

    QueryParameter fqParam = request.queryParameter("fq");
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_COMPONENT_NAME + ":" + testComponentNames.get(0)));
    assertTrue(fqParam.containsValue(COLUMN_NAME_TYPE + ":" + COLUMN_VALUE_TYPE_WORKER_LOG));
    assertTrue(fqParam.containsValue(COLUMN_NAME_LOG_LEVEL + ":" + testLogLevels.get(0)));
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:36,代码来源:AmbariInfraWithStormLogSearchTest.java

示例3: testEventSearchWithMinimumParameters

import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入方法依赖的package包/类
@Test
public void testEventSearchWithMinimumParameters() throws Exception {
    stubSolrUrl();

    EventSearchCriteria eventSearchCriteria = new EventSearchCriteria.Builder(TEST_APP_ID, TEST_FROM, TEST_TO).build();
    EventSearchResult result = logSearch.searchEvent(eventSearchCriteria);
    verifyEventSearchResults(result);

    // please note that space should be escaped to '+' since Wiremock doesn't handle it when matching...
    String dateRangeValue = "%s:[%s+TO+%s]";

    Instant fromInstant = Instant.ofEpochMilli(TEST_FROM);
    Instant toInstant = Instant.ofEpochMilli(TEST_TO);

    dateRangeValue = String.format(dateRangeValue, COLUMN_NAME_LOG_TIME, fromInstant.toString(), toInstant.toString());

    List<LoggedRequest> requests = wireMockRule.findAll(getRequestedFor(urlPathEqualTo(STUB_REQUEST_API_PATH)));
    assertEquals(1, requests.size());

    LoggedRequest request = requests.get(0);

    QueryParameter qParam = request.queryParameter("q");
    assertTrue(qParam.containsValue(COLUMN_NAME_STREAMLINE_EVENT_ID + ":*"));

    QueryParameter fqParam = request.queryParameter("fq");
    assertTrue(fqParam.containsValue(COLUMN_NAME_TYPE + ":" + COLUMN_VALUE_TYPE_EVENT));
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_TOPOLOGY_ID + ":" + TEST_APP_ID));
    assertTrue(fqParam.containsValue(dateRangeValue));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_COMPONENT_NAME)));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_EVENT_ID)));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_EVENT_ROOT_ID_SET)));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_EVENT_PARENT_ID_SET)));

    QueryParameter sortParam = request.queryParameter("sort");
    assertTrue(sortParam.containsValue(COLUMN_NAME_LOG_TIME + "+asc"));
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:37,代码来源:AmbariInfraWithStormLogSearchTest.java

示例4: testLogSearchWithFullParameters

import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入方法依赖的package包/类
@Test
public void testLogSearchWithFullParameters() throws Exception {
    stubSolrUrl();

    int testStart = 100;
    int testLimit = 2000;
    List<String> testLogLevels = Lists.newArrayList("INFO", "DEBUG");
    String testSearchString = "helloworld";
    List<String> testComponentNames = Lists.newArrayList("testComponent", "testComponent2");

    LogSearchCriteria logSearchCriteria = new LogSearchCriteria.Builder(TEST_APP_ID, TEST_FROM, TEST_TO)
        .setLogLevels(testLogLevels)
        .setSearchString(testSearchString)
        .setComponentNames(testComponentNames)
        .setStart(testStart)
        .setLimit(testLimit)
        .build();

    LogSearchResult result = logSearch.search(logSearchCriteria);

    // note that the result doesn't change given that we just provide same result from file
    verifyLogSearchResults(result);

    // please note that space should be escaped to '+' since Wiremock doesn't handle it when matching...
    String dateRangeValue = "%s:[%s+TO+%s]";

    Instant fromInstant = Instant.ofEpochMilli(TEST_FROM);
    Instant toInstant = Instant.ofEpochMilli(TEST_TO);

    dateRangeValue = String.format(dateRangeValue, COLUMN_NAME_LOG_TIME, fromInstant.toString(), toInstant.toString());

    String expectedComponentNames = "(" + String.join("+OR+", testComponentNames) + ")";
    String expectedLogLevels = "(" + String.join("+OR+", testLogLevels) + ")";

    List<LoggedRequest> requests = wireMockRule.findAll(getRequestedFor(urlPathEqualTo(STUB_REQUEST_API_PATH)));
    assertEquals(1, requests.size());

    LoggedRequest request = requests.get(0);

    QueryParameter qParam = request.queryParameter("q");
    assertTrue(qParam.containsValue(COLUMN_NAME_LOG_MESSAGE + ":" + testSearchString));

    QueryParameter fqParam = request.queryParameter("fq");
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_TOPOLOGY_ID + ":" + TEST_APP_ID));
    assertTrue(fqParam.containsValue(COLUMN_NAME_TYPE + ":" + COLUMN_VALUE_TYPE_WORKER_LOG));
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_COMPONENT_NAME + ":" + expectedComponentNames));
    assertTrue(fqParam.containsValue(COLUMN_NAME_LOG_LEVEL + ":" + expectedLogLevels));
    assertTrue(fqParam.containsValue(dateRangeValue));

    QueryParameter sortParam = request.queryParameter("sort");
    assertTrue(sortParam.containsValue(COLUMN_NAME_LOG_TIME + "+asc"));

    QueryParameter startParam = request.queryParameter("start");
    assertTrue(startParam.containsValue(String.valueOf(testStart)));

    QueryParameter rowsParam = request.queryParameter("rows");
    assertTrue(rowsParam.containsValue(String.valueOf(testLimit)));
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:59,代码来源:AmbariInfraWithStormLogSearchTest.java

示例5: testEventSearchWithComponentNamesAndStartAndLimitAndDescendingParameters

import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入方法依赖的package包/类
@Test
public void testEventSearchWithComponentNamesAndStartAndLimitAndDescendingParameters() throws Exception {
    stubSolrUrl();

    int testStart = 100;
    int testLimit = 2000;
    List<String> testComponentNames = Collections.singletonList("SOURCE");

    EventSearchCriteria eventSearchCriteria = new EventSearchCriteria.Builder(TEST_APP_ID, TEST_FROM, TEST_TO)
            .setComponentNames(testComponentNames).setAscending(false).setStart(testStart).setLimit(testLimit).build();
    EventSearchResult result = logSearch.searchEvent(eventSearchCriteria);
    verifyEventSearchResults(result);

    // please note that space should be escaped to '+' since Wiremock doesn't handle it when matching...
    String dateRangeValue = "%s:[%s+TO+%s]";

    Instant fromInstant = Instant.ofEpochMilli(TEST_FROM);
    Instant toInstant = Instant.ofEpochMilli(TEST_TO);

    dateRangeValue = String.format(dateRangeValue, COLUMN_NAME_LOG_TIME, fromInstant.toString(), toInstant.toString());

    List<LoggedRequest> requests = wireMockRule.findAll(getRequestedFor(urlPathEqualTo(STUB_REQUEST_API_PATH)));
    assertEquals(1, requests.size());

    LoggedRequest request = requests.get(0);

    QueryParameter qParam = request.queryParameter("q");
    assertTrue(qParam.containsValue(COLUMN_NAME_STREAMLINE_EVENT_ID + ":*"));

    QueryParameter fqParam = request.queryParameter("fq");
    assertTrue(fqParam.containsValue(COLUMN_NAME_TYPE + ":" + COLUMN_VALUE_TYPE_EVENT));
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_TOPOLOGY_ID + ":" + TEST_APP_ID));
    assertTrue(fqParam.containsValue(dateRangeValue));
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_COMPONENT_NAME + ":" + testComponentNames.get(0)));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_EVENT_ID)));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_EVENT_ROOT_ID_SET)));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_EVENT_PARENT_ID_SET)));

    QueryParameter sortParam = request.queryParameter("sort");
    assertTrue(sortParam.containsValue(COLUMN_NAME_LOG_TIME + "+desc"));

    QueryParameter startParam = request.queryParameter("start");
    assertTrue(startParam.containsValue(String.valueOf(testStart)));

    QueryParameter rowsParam = request.queryParameter("rows");
    assertTrue(rowsParam.containsValue(String.valueOf(testLimit)));
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:48,代码来源:AmbariInfraWithStormLogSearchTest.java

示例6: testEventSearchWithEventId

import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入方法依赖的package包/类
@Test
public void testEventSearchWithEventId() throws Exception {
    stubSolrUrl();

    String testEventId = "b7715c60-74ad-43dd-814a-8a40403a31bc";

    EventSearchCriteria eventSearchCriteria = new EventSearchCriteria.Builder(TEST_APP_ID, TEST_FROM, TEST_TO)
            .setSearchEventId(testEventId).build();
    EventSearchResult result = logSearch.searchEvent(eventSearchCriteria);
    verifyEventSearchResults(result);

    // please note that space should be escaped to '+' since Wiremock doesn't handle it when matching...
    String dateRangeValue = "%s:[%s+TO+%s]";

    Instant fromInstant = Instant.ofEpochMilli(TEST_FROM);
    Instant toInstant = Instant.ofEpochMilli(TEST_TO);

    dateRangeValue = String.format(dateRangeValue, COLUMN_NAME_LOG_TIME, fromInstant.toString(), toInstant.toString());

    List<LoggedRequest> requests = wireMockRule.findAll(getRequestedFor(urlPathEqualTo(STUB_REQUEST_API_PATH)));
    assertEquals(1, requests.size());

    LoggedRequest request = requests.get(0);

    QueryParameter qParam = request.queryParameter("q");
    assertTrue(qParam.containsValue(COLUMN_NAME_STREAMLINE_EVENT_ID + ":*"));

    QueryParameter fqParam = request.queryParameter("fq");
    assertTrue(fqParam.containsValue(COLUMN_NAME_TYPE + ":" + COLUMN_VALUE_TYPE_EVENT));
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_TOPOLOGY_ID + ":" + TEST_APP_ID));
    assertTrue(fqParam.containsValue(dateRangeValue));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_COMPONENT_NAME)));

    String expectedEventIdQuery = COLUMN_NAME_STREAMLINE_EVENT_ID + ":" + testEventId;
    expectedEventIdQuery += "+OR+" + COLUMN_NAME_STREAMLINE_EVENT_ROOT_ID_SET + ":*" + testEventId + "*";
    expectedEventIdQuery += "+OR+" + COLUMN_NAME_STREAMLINE_EVENT_PARENT_ID_SET + ":*" + testEventId + "*";
    assertTrue(fqParam.containsValue(expectedEventIdQuery));

    QueryParameter sortParam = request.queryParameter("sort");
    assertTrue(sortParam.containsValue(COLUMN_NAME_LOG_TIME + "+asc"));
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:42,代码来源:AmbariInfraWithStormLogSearchTest.java

示例7: testEventSearchWithKeyValuesQueryAndHeadersQuery

import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入方法依赖的package包/类
@Test
public void testEventSearchWithKeyValuesQueryAndHeadersQuery() throws Exception {
    stubSolrUrl();

    String searchQuery = "hello=world";

    EventSearchCriteria eventSearchCriteria = new EventSearchCriteria.Builder(TEST_APP_ID, TEST_FROM, TEST_TO)
            .setSearchString(searchQuery).build();
    EventSearchResult result = logSearch.searchEvent(eventSearchCriteria);
    verifyEventSearchResults(result);

    // please note that space should be escaped to '+' since Wiremock doesn't handle it when matching...
    String dateRangeValue = "%s:[%s+TO+%s]";

    Instant fromInstant = Instant.ofEpochMilli(TEST_FROM);
    Instant toInstant = Instant.ofEpochMilli(TEST_TO);

    dateRangeValue = String.format(dateRangeValue, COLUMN_NAME_LOG_TIME, fromInstant.toString(), toInstant.toString());

    List<LoggedRequest> requests = wireMockRule.findAll(getRequestedFor(urlPathEqualTo(STUB_REQUEST_API_PATH)));
    assertEquals(1, requests.size());

    LoggedRequest request = requests.get(0);

    QueryParameter qParam = request.queryParameter("q");
    String expectedQuery = COLUMN_NAME_STREAMLINE_EVENT_ID + ":*";
    expectedQuery += "+AND+(";
    expectedQuery += COLUMN_NAME_STREAMLINE_EVENT_KEYVALUES + ":" + searchQuery;
    expectedQuery += "+OR+" + COLUMN_NAME_STREAMLINE_EVENT_HEADERS + ":" + searchQuery;
    expectedQuery += "+OR+" + COLUMN_NAME_STREAMLINE_EVENT_AUX_KEYVALUES + ":" + searchQuery;
    expectedQuery += ")";

    assertTrue(qParam.containsValue(expectedQuery));

    QueryParameter fqParam = request.queryParameter("fq");
    assertTrue(fqParam.containsValue(COLUMN_NAME_TYPE + ":" + COLUMN_VALUE_TYPE_EVENT));
    assertTrue(fqParam.containsValue(COLUMN_NAME_STREAMLINE_TOPOLOGY_ID + ":" + TEST_APP_ID));
    assertTrue(fqParam.containsValue(dateRangeValue));
    assertFalse(fqParam.hasValueMatching(ValuePattern.containing(COLUMN_NAME_STREAMLINE_COMPONENT_NAME)));

    QueryParameter sortParam = request.queryParameter("sort");
    assertTrue(sortParam.containsValue(COLUMN_NAME_LOG_TIME + "+asc"));
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:44,代码来源:AmbariInfraWithStormLogSearchTest.java


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