DropCommand implements StubDescriptorModificationCommand { @Override public Map<String, StubDescriptor> modify(final Map<String, StubDescriptor> stubDescriptors) { Map<String, StubDescriptor> updated = new LinkedHashMap<>(stubDescriptors); StubDescriptor removed = updated.remove(groupName); if (removed != null) { logger.info(urlAccessLogMessageAssembler.assembleMessage(request, groupName + "'s stub configuration has been deleted.")); } return updated; } DropCommand(final String groupName, final HttpServletRequest request, final UrlAccessLogMessageAssembler urlAccessLogMessageAssembler); @Override Map<String, StubDescriptor> modify(final Map<String, StubDescriptor> stubDescriptors); String getGroupName(); HttpServletRequest getRequest();  }
@Test public void testDropShouldRemoveTheSelectedStubConfiguration() { Map<String, StubDescriptor> expected = normalStubDescriptors; expected.remove(GROUPNAME_FIRST); underTest = new DropCommand(GROUPNAME_FIRST, request, urlAccessLogMessageAssembler); Map<String, StubDescriptor> result = underTest.modify(normalStubDescriptors); Assert.assertEquals(result, expected); }
@Test public void testDropShouldNotRomveAnythingBecauseWeWantRemoveAValueWithUnknownKey() { Map<String, StubDescriptor> expected = normalStubDescriptors; underTest = new DropCommand("test", request, urlAccessLogMessageAssembler); Map<String, StubDescriptor> result = underTest.modify(normalStubDescriptors); Assert.assertEquals(result, expected); }