ChangeOrderCommand implements StubDescriptorModificationCommand { @Override public Map<String, StubDescriptor> modify(Map<String, StubDescriptor> stubDescriptors) { Map<String, StubDescriptor> updated; updated = doTheMoving(direction, groupName, stubDescriptors, request); return updated; } ChangeOrderCommand(final int direction, final String groupName, final HttpServletRequest request, final UrlAccessLogMessageAssembler urlAccessLogMessageAssembler); @Override Map<String, StubDescriptor> modify(Map<String, StubDescriptor> stubDescriptors); String getGroupName(); HttpServletRequest getRequest(); int getDirection();  }
@Test public void testDoChangeShouldMoveTheFirstStubConfigurationToDownByOne() { String[] expectedGroupnames = reverseStubDescriptors.keySet().toArray(new String[reverseStubDescriptors.size()]); underTest = new ChangeOrderCommand(-1, GROUPNAME_FIRST, request, urlAccessLogMessageAssembler); Map<String, StubDescriptor> result = underTest.modify(normalStubDescriptors); String[] resultGroupnames = result.keySet().toArray(new String[result.size()]); Assert.assertEquals(resultGroupnames, expectedGroupnames); }
@Test public void testDoChangeShouldMoveTheSecondStubConfigurationToUpByOne() { String[] expectedGroupnames = normalStubDescriptors.keySet().toArray(new String[normalStubDescriptors.size()]); underTest = new ChangeOrderCommand(1, GROUPNAME_FIRST, request, urlAccessLogMessageAssembler); Map<String, StubDescriptor> result = underTest.modify(reverseStubDescriptors); String[] resultGroupnames = result.keySet().toArray(new String[result.size()]); Assert.assertEquals(resultGroupnames, expectedGroupnames); }
@Test public void testDoChangeShouldNotMoveTheFirstStubConfigurationToUpByOne() { String[] expectedGroupnames = normalStubDescriptors.keySet().toArray(new String[normalStubDescriptors.size()]); underTest = new ChangeOrderCommand(1, GROUPNAME_FIRST, request, urlAccessLogMessageAssembler); Map<String, StubDescriptor> result = underTest.modify(normalStubDescriptors); String[] resultGroupnames = result.keySet().toArray(new String[result.size()]); Assert.assertEquals(resultGroupnames, expectedGroupnames); }
@Test public void testDoChangeShouldNotMoveTheSecondStubConfigurationToDownByOne() { String[] expectedGroupnames = normalStubDescriptors.keySet().toArray(new String[normalStubDescriptors.size()]); underTest = new ChangeOrderCommand(-1, GROUPNAME_SECOND, request, urlAccessLogMessageAssembler); Map<String, StubDescriptor> result = underTest.modify(normalStubDescriptors); String[] resultGroupnames = result.keySet().toArray(new String[result.size()]); Assert.assertEquals(resultGroupnames, expectedGroupnames); }