SequenceManager implements SequenceDescriptorHolder { public void removeSequenceDescriptors(final String groupName) { Iterator<SequenceDescriptor> descItr = descriptors.values().iterator(); SequenceDescriptor actualDescriptor = null; while (descItr.hasNext()) { actualDescriptor = descItr.next(); if (groupName.equals(actualDescriptor.getGroupName())) { descItr.remove(); } } }  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 testRemoveSequenceDescriptorsShouldRemoveDescriptor() { Map<String, SequenceDescriptor> descriptors = new ConcurrentHashMap<>(); descriptors.put("TestTeam-fistDescriptor-TestHandler", sequenceDescriptor); Whitebox.setInternalState(underTest, "descriptors", descriptors); given(sequenceDescriptor.getGroupName()).willReturn("TestTeam"); underTest.removeSequenceDescriptors("TestTeam"); Map<String, SequenceDescriptor> actualDescriptors = (Map<String, SequenceDescriptor>) Whitebox.getInternalState(underTest, "descriptors"); Assert.assertEquals(actualDescriptors.size(), 0); }
@Test public void testRemoveSequenceDescriptorsShouldNotRemoveDescriptor() { Map<String, SequenceDescriptor> descriptors = new ConcurrentHashMap<>(); descriptors.put("TestTeam-fistDescriptor-TestHandler", sequenceDescriptor); Whitebox.setInternalState(underTest, "descriptors", descriptors); underTest.removeSequenceDescriptors("something"); Map<String, SequenceDescriptor> actualDescriptors = (Map<String, SequenceDescriptor>) Whitebox.getInternalState(underTest, "descriptors"); Assert.assertEquals(actualDescriptors.size(), 1); }