@Test public void testCheckRequestShouldAppendRequestToAnExistingSequence() { 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"); underTest.checkRequest(request, sequenceDescriptor); verify(sequenceFirst).setTimeout(Mockito.any(Timestamp.class)); verify(sequenceFirst).addPair(Mockito.eq("TestLoggerId"), Mockito.any(RequestResponsePair.class)); verify(request).addSequenceId("newID"); }
public void checkRequest(final WilmaHttpRequest request, final SequenceDescriptor sequenceDescriptor) { if (sequenceEvaluator.evaluate(request, sequenceDescriptor)) { SequenceHandler handler = sequenceDescriptor.getHandler(); String sequenceKey = handler.getExistingSequence(request, sequenceDescriptor.getSequences(), sequenceDescriptor.getParameters()); if (sequenceKey == null) { sequenceKey = handler.generateNewSequenceKey(request, sequenceDescriptor.getParameters()); handlerKeyValidator.validateGeneratedKey(sequenceKey, handler.getClass().getName()); WilmaSequence sequence = sequenceFactory.createNewSequence(sequenceKey, request, sequenceDescriptor.getDefaultTimeout()); sequenceDescriptor.putIntoSequences(sequence); } else { appendSequence(sequenceKey, request, sequenceDescriptor); } String sequenceId = sequenceIdUtil.createSequenceId(sequenceKey, sequenceDescriptor); appendSequenceKeyToHeader(sequenceId, request); } }
SequenceService { public void checkRequest(final WilmaHttpRequest request, final SequenceDescriptor sequenceDescriptor) { if (sequenceEvaluator.evaluate(request, sequenceDescriptor)) { SequenceHandler handler = sequenceDescriptor.getHandler(); String sequenceKey = handler.getExistingSequence(request, sequenceDescriptor.getSequences(), sequenceDescriptor.getParameters()); if (sequenceKey == null) { sequenceKey = handler.generateNewSequenceKey(request, sequenceDescriptor.getParameters()); handlerKeyValidator.validateGeneratedKey(sequenceKey, handler.getClass().getName()); WilmaSequence sequence = sequenceFactory.createNewSequence(sequenceKey, request, sequenceDescriptor.getDefaultTimeout()); sequenceDescriptor.putIntoSequences(sequence); } else { appendSequence(sequenceKey, request, sequenceDescriptor); } String sequenceId = sequenceIdUtil.createSequenceId(sequenceKey, sequenceDescriptor); appendSequenceKeyToHeader(sequenceId, request); } } }
SequenceService { public void checkRequest(final WilmaHttpRequest request, final SequenceDescriptor sequenceDescriptor) { if (sequenceEvaluator.evaluate(request, sequenceDescriptor)) { SequenceHandler handler = sequenceDescriptor.getHandler(); String sequenceKey = handler.getExistingSequence(request, sequenceDescriptor.getSequences(), sequenceDescriptor.getParameters()); if (sequenceKey == null) { sequenceKey = handler.generateNewSequenceKey(request, sequenceDescriptor.getParameters()); handlerKeyValidator.validateGeneratedKey(sequenceKey, handler.getClass().getName()); WilmaSequence sequence = sequenceFactory.createNewSequence(sequenceKey, request, sequenceDescriptor.getDefaultTimeout()); sequenceDescriptor.putIntoSequences(sequence); } else { appendSequence(sequenceKey, request, sequenceDescriptor); } String sequenceId = sequenceIdUtil.createSequenceId(sequenceKey, sequenceDescriptor); appendSequenceKeyToHeader(sequenceId, request); } }  }
SequenceService { public void checkRequest(final WilmaHttpRequest request, final SequenceDescriptor sequenceDescriptor) { if (sequenceEvaluator.evaluate(request, sequenceDescriptor)) { SequenceHandler handler = sequenceDescriptor.getHandler(); String sequenceKey = handler.getExistingSequence(request, sequenceDescriptor.getSequences(), sequenceDescriptor.getParameters()); if (sequenceKey == null) { sequenceKey = handler.generateNewSequenceKey(request, sequenceDescriptor.getParameters()); handlerKeyValidator.validateGeneratedKey(sequenceKey, handler.getClass().getName()); WilmaSequence sequence = sequenceFactory.createNewSequence(sequenceKey, request, sequenceDescriptor.getDefaultTimeout()); sequenceDescriptor.putIntoSequences(sequence); } else { appendSequence(sequenceKey, request, sequenceDescriptor); } String sequenceId = sequenceIdUtil.createSequenceId(sequenceKey, sequenceDescriptor); appendSequenceKeyToHeader(sequenceId, request); } }  void checkRequest(final WilmaHttpRequest request, final SequenceDescriptor sequenceDescriptor); }
SequenceService { public void checkRequest(final WilmaHttpRequest request, final SequenceDescriptor sequenceDescriptor) { if (sequenceEvaluator.evaluate(request, sequenceDescriptor)) { SequenceHandler handler = sequenceDescriptor.getHandler(); String sequenceKey = handler.getExistingSequence(request, sequenceDescriptor.getSequences(), sequenceDescriptor.getParameters()); if (sequenceKey == null) { sequenceKey = handler.generateNewSequenceKey(request, sequenceDescriptor.getParameters()); handlerKeyValidator.validateGeneratedKey(sequenceKey, handler.getClass().getName()); WilmaSequence sequence = sequenceFactory.createNewSequence(sequenceKey, request, sequenceDescriptor.getDefaultTimeout()); sequenceDescriptor.putIntoSequences(sequence); } else { appendSequence(sequenceKey, request, sequenceDescriptor); } String sequenceId = sequenceIdUtil.createSequenceId(sequenceKey, sequenceDescriptor); appendSequenceKeyToHeader(sequenceId, request); } }  void checkRequest(final WilmaHttpRequest request, final SequenceDescriptor sequenceDescriptor);  }