SequenceManager implements SequenceDescriptorHolder { public void tryToSaveResponseIntoSequence(final WilmaHttpResponse response) { String headerParameter = response.getSequenceId(); if (headerParameter != null) { String[] sequenceKeys = headerUtil.resolveSequenceHeader(headerParameter); for (String key : sequenceKeys) { addResponseToSequence(key, response); } } }  void handleRequest(final WilmaHttpRequest request); void cleanUpDescriptors(); void addSequenceDescriptor(final String descriptorKey, final SequenceDescriptor descriptor); void removeSequenceDescriptors(final String groupName); void setStatusOfDescriptors(final String groupName, final boolean newStatus); void dropAllSequences(); void tryToSaveResponseIntoSequence(final WilmaHttpResponse response); Map<String, WilmaSequence> getSequences(final String sequenceDescriptorName); @Override void addAllSequenceDescriptors(final StubDescriptor stubDescriptor); Map<String, SequenceDescriptor> getDescriptors();  }
@Test public void testTryToSaveResponseIntoSequence() { 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); underTest.tryToSaveResponseIntoSequence(response); verify(sequence).addResponseToPair(clonedResponse); }
@Test public void testTryToSaveResponseIntoSequenceWhenResponseDoesNotBelongsToSequence() { response = new WilmaHttpResponse(isVolatile); underTest.tryToSaveResponseIntoSequence(response); verify(headerUtil, times(0)).resolveSequenceHeader(Mockito.anyString()); }