- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.epam.wilma.domain.sequence.WilmaSequence
类的一些代码示例,展示了WilmaSequence
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WilmaSequence
类的具体详情如下:
包路径:com.epam.wilma.domain.sequence.WilmaSequence
类名称:WilmaSequence
[英]This class represents a sequence.
[中]这个类代表一个序列。
代码示例来源: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
/**
* Checks if all of the requests' responses arrived with the exception of the request with the given loggerId.
* @param loggerId the given loggerId
* @return true if all of the responses arrived (with the exception of the request's with the given loggerId), false otherwise
*/
public boolean checkIfAllResponsesArrived(final String loggerId) {
Map<String, RequestResponsePair> pairs = getPairs();
pairs.remove(loggerId);
Iterator<RequestResponsePair> pairIterator = pairs.values().iterator();
boolean result = true;
while (pairIterator.hasNext() && result) {
RequestResponsePair pair = pairIterator.next();
result = pair.getResponse() != null;
}
return result;
}
代码示例来源:origin: epam/Wilma
@BeforeMethod
public void setUp() throws Exception {
String sequenceKey = "key";
Timestamp timestamp = new Timestamp(10);
underTest = new WilmaSequence(sequenceKey, timestamp, messageStore);
}
代码示例来源:origin: epam/Wilma
private void appendSequence(final String sequenceKey, final WilmaHttpRequest request, final SequenceDescriptor sequenceDescriptor) {
WilmaSequence sequence = sequenceDescriptor.getSequence(sequenceKey);
if (sequence != null) {
String loggerId = request.getWilmaMessageId();
RequestResponsePair pair = new RequestResponsePair(requestCloner.cloneRequest(request));
sequence.setTimeout(new Timestamp(dateProvider.getCurrentTimeInMillis() + sequenceDescriptor.getDefaultTimeout()));
sequence.addPair(loggerId, pair);
}
}
代码示例来源:origin: epam/Wilma
@Test
public void testCreateNewSequence() {
//GIVEN
String testKey = "TestKey";
String logggerId = "testId";
given(request.getWilmaMessageId()).willReturn(logggerId);
//WHEN
WilmaSequence result = underTest.createNewSequence(testKey, request, 1000L);
//THEN
Assert.assertEquals(result.getSequenceKey(), testKey);
Assert.assertFalse(result.isExpired(new Timestamp(1000L)));
RequestResponsePair firstPair = result.getPairs().get(logggerId);
Assert.assertEquals(firstPair.getRequest(), request);
}
}
代码示例来源:origin: epam/Wilma
private void cleanSequences(final SequenceDescriptor sequenceDescriptor) {
Iterator<WilmaSequence> iterator = sequenceDescriptor.getSequencesInCollection().iterator();
while (iterator.hasNext()) {
WilmaSequence actualSeq = iterator.next();
if (actualSeq.isExpired(new Timestamp(dateProvider.getCurrentTimeInMillis()))) {
iterator.remove();
}
}
}
}
代码示例来源:origin: epam/Wilma
private void addResponseToSequence(final String sequenceId, final WilmaHttpResponse response) {
String descriptorName = sequenceIdUtil.getDescriptorKey(sequenceId);
SequenceDescriptor descriptor = descriptors.get(descriptorName);
String handlerKey = sequenceIdUtil.getHandlerKey(sequenceId);
if (descriptor != null) {
WilmaSequence sequence = descriptor.getSequence(handlerKey);
if (sequence != null) {
sequence.addResponseToPair(responseCloner.cloneResponse(response));
}
}
}
代码示例来源:origin: epam/Wilma
/**
* Put a new sequence object into the sequences collection.
* @param sequence is the new sequence what we want to store
*/
public void putIntoSequences(final WilmaSequence sequence) {
sequences.put(sequence.getSequenceKey(), sequence);
}
代码示例来源:origin: epam/Wilma
@Test
public void testCheckRequestShouldAppendRequestToAnExistingSequence() {
//GIVEN
String sequenceKeyFirst = "testKey1";
Map<String, WilmaSequence> sequences = new ConcurrentHashMap<>();
sequences.put(sequenceKeyFirst, sequenceFirst);
given(sequenceEvaluator.evaluate(request, sequenceDescriptor)).willReturn(true);
given(sequenceDescriptor.getSequences()).willReturn(sequences);
given(handler.getExistingSequence(request, sequences, null)).willReturn(sequenceKeyFirst);
given(sequenceDescriptor.getSequence(sequenceKeyFirst)).willReturn(sequenceFirst);
given(request.getWilmaMessageId()).willReturn("TestLoggerId");
given(sequenceIdUtil.createSequenceId(sequenceKeyFirst, sequenceDescriptor)).willReturn("newID");
given(request.getSequenceId()).willReturn(null);
given(headerUtil.createSequenceHeader(null, "newID")).willReturn("newID");
//WHEN
underTest.checkRequest(request, sequenceDescriptor);
//THEN
verify(sequenceFirst).setTimeout(Mockito.any(Timestamp.class));
verify(sequenceFirst).addPair(Mockito.eq("TestLoggerId"), Mockito.any(RequestResponsePair.class));
verify(request).addSequenceId("newID");
}
代码示例来源:origin: epam/Wilma
@Test
public void testCleanTheExpiredSequences() {
//GIVEN
descriptors.put("TestKey1", descriptor);
List<WilmaSequence> sequences = new ArrayList<>();
sequences.add(firstSequence);
sequences.add(secondSequence);
given(descriptor.getSequencesInCollection()).willReturn(sequences);
given(firstSequence.isExpired(new Timestamp(1000L))).willReturn(false);
given(secondSequence.isExpired(new Timestamp(1000L))).willReturn(true);
//WHEN
underTest.cleanTheExpiredSequences(descriptors);
//THEN
Assert.assertEquals(sequences.size(), 1);
}
代码示例来源:origin: epam/Wilma
@Test
public void testTryToSaveResponseIntoSequence() {
//GIVEN
response = new WilmaHttpResponse(isVolatile);
String sequenceKey = "TestTeam-fistDescriptor-TestHandler|Sequence1";
Map<String, String> requestHeaders = new HashMap<>();
requestHeaders.put(WilmaHttpEntity.WILMA_SEQUENCE_ID, sequenceKey);
Map<String, SequenceDescriptor> descriptors = new ConcurrentHashMap<>();
descriptors.put("TestTeam-fistDescriptor-TestHandler", sequenceDescriptor);
Whitebox.setInternalState(response, "requestHeaders", requestHeaders);
Whitebox.setInternalState(underTest, "descriptors", descriptors);
given(headerUtil.resolveSequenceHeader(sequenceKey)).willReturn(new String[]{sequenceKey});
given(sequenceKeyResolver.getDescriptorKey(sequenceKey)).willReturn("TestTeam-fistDescriptor-TestHandler");
given(sequenceKeyResolver.getHandlerKey(sequenceKey)).willReturn("Sequence1");
given(sequenceDescriptor.getSequence("Sequence1")).willReturn(sequence);
//WHEN
underTest.tryToSaveResponseIntoSequence(response);
//THEN
verify(sequence).addResponseToPair(clonedResponse);
}
代码示例来源:origin: epam/Wilma
@Test
public void testCheckRequestShouldCreateANewSequence() {
//GIVEN
String sequenceKeyFirst = "testKey1";
String sequenceKeySecond = "testKey2";
Map<String, WilmaSequence> sequences = new ConcurrentHashMap<>();
sequences.put(sequenceKeyFirst, sequenceFirst);
given(sequenceEvaluator.evaluate(request, sequenceDescriptor)).willReturn(true);
given(handler.getExistingSequence(request, sequences, null)).willReturn(null);
given(handler.generateNewSequenceKey(request, null)).willReturn(sequenceKeySecond);
given(sequenceDescriptor.getDefaultTimeout()).willReturn(1000L);
given(sequenceFactory.createNewSequence(sequenceKeySecond, request, 1000L)).willReturn(sequenceSecond);
given(sequenceSecond.getSequenceKey()).willReturn(sequenceKeySecond);
given(sequenceIdUtil.createSequenceId(sequenceKeySecond, sequenceDescriptor)).willReturn("newID");
given(request.getSequenceId()).willReturn(null);
given(headerUtil.createSequenceHeader(null, "newID")).willReturn("newID");
//WHEN
underTest.checkRequest(request, sequenceDescriptor);
//THEN
verify(sequenceDescriptor).putIntoSequences(sequenceSecond);
verify(request).addSequenceId("newID");
}
代码示例来源: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
private String getReferredSource(final String expression) {
String[] parts = expression.substring(1).split("\\.");
String link = parts[0];
String linkedContent;
if (SELF_REQUEST_REFFERENCE.equals(link)) {
linkedContent = getSource();
} else {
Map<String, String> map = sequenceJsonTransformer.transform(params, sequence.getPairs());
linkedContent = map.get(link);
}
return linkedContent;
}
代码示例来源:origin: epam/Wilma
/**
* This method creates new WilmaSequence object from the given parameters.
* @param sequenceKey is the key of the new WilmaSequence
* @param request is the first request of the new WilmaSequence
* @param timeout is time in milliseconds when the sequence will be expired
* @return with the new WilmaSequence object.
*/
public WilmaSequence createNewSequence(final String sequenceKey, final WilmaHttpRequest request, final long timeout) {
WilmaSequencePairs messageStore = new WilmaSequencePairs();
RequestResponsePair firstPair = new RequestResponsePair(request);
String loggerId = request.getWilmaMessageId();
messageStore.addStore(loggerId, firstPair);
WilmaSequence sequence = new WilmaSequence(sequenceKey, new Timestamp(dateProvider.getCurrentTimeInMillis() + timeout), messageStore);
return sequence;
}
}
代码示例来源: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
@Override
public byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp,
final byte[] templateResource, final ParameterList params) {
Map<String, RequestResponsePair> message = wilmaRequest.getSequence().getPairs();
Map<String, String> nameToXml = sequenceXmlTransformer.transform(params, message);
String xslResourcePath = checkAndGetXslResourcePath(params);
byte[] xslResource = readXslResourceFromFileSystem(xslResourcePath);
byte[] requestXmlResource = wilmaRequest.getBody().getBytes(StandardCharsets.UTF_8);
return xslResponseGenerator.generateResponse(requestXmlResource, xslResource, templateResource, nameToXml);
}
代码示例来源: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);
}
}
给定一个 Sequence of Sequences 类型,如何将其转换为单个扁平化 Sequence 类型?考虑以下 Ceylon 代码: Integer[] range(Integer max)
出于学习目的,我正在尝试使用 F# 以序列形式运行模拟。从一系列随机数开始,如果状态不依赖于先前的状态,map 是生成状态序列的直接方法。我遇到问题的地方是当我尝试做类似的事情时: State(i+1
我正在 DynamoDB 上开发论坛。 有一个帖子表,其中包含线程中的所有帖子。我需要对帖子中的顺序有一个概念,即我需要知道哪个帖子先出现,哪个后出现。 我的服务将在分布式环境中运行。 我不确定使用时
我正在 DynamoDB 上开发论坛。 有一个帖子表,其中包含线程中的所有帖子。我需要对帖子中的顺序有一个概念,即我需要知道哪个帖子先出现,哪个后出现。 我的服务将在分布式环境中运行。 我不确定使用时
在 Z3 中,它支持 String 和 Sequence。但是 Z3py 是否也支持它们,或者我们必须使用 Python 中的字符串或列表?从最新的版本来看,新版本好像确实支持了String和Sequ
我是 Clojure 世界的新手,我遇到了一个问题。我得到了一个 LazySeq,看起来像这样(实际上更长) values = (("Brand1" "0") ("Brand2" "15") ("Br
我正在开发一个用于文本生成的序列到序列模型 ( paper )。我没有在解码器端使用“教师强制”,即 t0 时解码器的输出被馈送到 t1 时解码器的输入。 现在,实际上,解码器(LSTM/GRU)的输
Rust 中的规则是什么,类似于这里描述的规则http://en.cppreference.com/w/cpp/language/eval_order对于 C++? 目前我凭经验发现, 1) 函数的参
我当前的代码: import re from Bio.Seq import Seq def check_promoter(binding_element,promoter_seq): promoter
您好,此代码旨在存储使用 open cv 绘制的矩形的坐标,并将结果编译为单个图像。 import numpy as np import cv2 im = cv2.imread('1.jpg') im
在我的程序中,我有一个正则表达式,它确保输入字符串至少有一个字母和一个数字字符,并且长度在 2 到 10 之间。 Pattern p = Pattern.compile("^(?=.*\\d)(?=.
我正在查看 Google 的免费机器学习速成类(class),并尝试根据他们类(class)的第一部分制作一个预测模型。但是,在输入函数中,有一个字典,我不断收到此错误, in my_input_fn
我想使用 Boost 的 any_range 来处理多个异构数据范围。我的数据范围类型称为 fusion vector ,例如: typedef vector TypeSequence 鉴于这样的类型
我正在使用 SimpleJdbcInsert 作为, SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(dataSource).with
我正在尝试通过从我的数据创建 .phy 文件来创建系统发育树。 我有一个数据框 ndf= ESV trunc 1 esv1 TACGTAGGTG... 2 esv2 TACGGAGGGT... 3 e
这可能真的很简单,但我正处于 Rx 学习曲线的底部。我花了几个小时阅读文章、观看视频和编写代码,但我似乎对一些看起来应该非常简单的事情有心理障碍。 我正在从串行端口收集数据。我已使用 Observab
我正在将一些模块从 v8 迁移到 v10,我有这个模型: class SearchInfoPartnerSeniat(models.TransientModel): _name = "search.i
我尝试添加一个新的“自定义”序列到我的Marten DB中,以获取新用户的用户ID(在注册过程中)。。后来,我能够访问下一个序列值,如下所示:。问题出在上面的代码中:在第一次运行时:将userid_s
我在 rosettacode 遇到了这个代码 my @pascal = [1], { [0, |$_ Z+ |$_, 0] } ... Inf; .say for @pascal[^4]; # ==>
我不明白为什么这个程序有效: my $supply = Supply.interval: 1; react { whenever $supply { put "Got $^a" }
我是一名优秀的程序员,十分优秀!