gpt4 book ai didi

com.epam.wilma.domain.sequence.WilmaSequence.checkIfAllResponsesArrived()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 07:29:05 25 4
gpt4 key购买 nike

本文整理了Java中com.epam.wilma.domain.sequence.WilmaSequence.checkIfAllResponsesArrived()方法的一些代码示例,展示了WilmaSequence.checkIfAllResponsesArrived()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WilmaSequence.checkIfAllResponsesArrived()方法的具体详情如下:
包路径:com.epam.wilma.domain.sequence.WilmaSequence
类名称:WilmaSequence
方法名:checkIfAllResponsesArrived

WilmaSequence.checkIfAllResponsesArrived介绍

[英]Checks if all of the requests' responses arrived with the exception of the request with the given loggerId.
[中]检查是否所有请求的响应都已到达,但具有给定loggerId的请求除外。

代码示例

代码示例来源:origin: epam/Wilma

/**
 * Waits for the given sequence's responses to arrive.
 * Throws a {@link ResponseTimeoutException} if the waiting times out.
 * @param stubbedRequest the request that got stubbed
 * @param actualSequence the given request
 * @throws InterruptedException if the waiting is interrupted
 */
public void waitForResponses(final WilmaHttpRequest stubbedRequest, final WilmaSequence actualSequence) throws InterruptedException {
  String wilmaLoggerId = stubbedRequest.getWilmaMessageId();
  boolean allResponsesArrived = actualSequence.checkIfAllResponsesArrived(wilmaLoggerId);
  int timeWaited = 0;
  getProperties();
  int waitInterval = properties.getWaitInterval();
  int timeout = properties.getTimeout();
  while (!allResponsesArrived) {
    Thread.sleep(waitInterval);
    timeWaited += waitInterval;
    if (timeWaited > timeout) {
      throw new ResponseTimeoutException(TIMEOUT_ERROR_MESSAGE);
    }
    allResponsesArrived = actualSequence.checkIfAllResponsesArrived(wilmaLoggerId);
  }
}

代码示例来源:origin: epam/Wilma

@Test
  public void testWaitForResponses() throws InterruptedException {
    //GIVEN
    given(actualSequence.checkIfAllResponsesArrived(LOGGER_ID)).willReturn(false, false, false, true);
    //WHEN
    underTest.waitForResponses(stubbedRequest, actualSequence);
    //THEN
    verify(actualSequence, times(4)).checkIfAllResponsesArrived(LOGGER_ID);
  }
}

代码示例来源:origin: epam/Wilma

@Test(expectedExceptions = ResponseTimeoutException.class)
public void testWhenResponsesCannotArriveInTimeThenExceptionIsThrown() throws InterruptedException {
  //GIVEN
  given(actualSequence.checkIfAllResponsesArrived(LOGGER_ID)).willReturn(false);
  //WHEN
  underTest.waitForResponses(stubbedRequest, actualSequence);
  //THEN exception is thrown
}

代码示例来源:origin: epam/Wilma

@Test
public void testCheckShouldNotLookForResponsePairOfTheGivenLoggerId() {
  //GIVEN
  Map<String, RequestResponsePair> messages = new HashMap<>();
  RequestResponsePair pair = new RequestResponsePair(new WilmaHttpRequest());
  messages.put(STUBBED_REQUEST_LOGGER_ID, pair);
  given(messageStore.getMessages()).willReturn(messages);
  //WHEN
  boolean result = underTest.checkIfAllResponsesArrived(STUBBED_REQUEST_LOGGER_ID);
  //THEN
  assertTrue(result);
}

代码示例来源:origin: epam/Wilma

@Test
public void testCheckShouldReturnFalseWhenAResponseIsNull() {
  //GIVEN
  Map<String, RequestResponsePair> messages = new TreeMap<>();
  RequestResponsePair pair = new RequestResponsePair(new WilmaHttpRequest());
  pair.setResponse(new WilmaHttpResponse(isVolatile));
  RequestResponsePair pair2 = new RequestResponsePair(new WilmaHttpRequest());
  messages.put("id2", pair);
  messages.put("id3", pair2);
  given(messageStore.getMessages()).willReturn(messages);
  //WHEN
  boolean result = underTest.checkIfAllResponsesArrived(STUBBED_REQUEST_LOGGER_ID);
  //THEN
  assertFalse(result);
}

代码示例来源:origin: epam/Wilma

@Test
  public void testCheckShouldReturnTrueWhenNoneOfTheResponsesAreNull() {
    //GIVEN
    Map<String, RequestResponsePair> messages = new TreeMap<>();
    RequestResponsePair pair = new RequestResponsePair(new WilmaHttpRequest());
    pair.setResponse(new WilmaHttpResponse(isVolatile));
    RequestResponsePair pair2 = new RequestResponsePair(new WilmaHttpRequest());
    pair2.setResponse(new WilmaHttpResponse(isVolatile));
    messages.put("id2", pair);
    messages.put("id3", pair2);
    given(messageStore.getMessages()).willReturn(messages);
    //WHEN
    boolean result = underTest.checkIfAllResponsesArrived(STUBBED_REQUEST_LOGGER_ID);
    //THEN
    assertTrue(result);
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com