class ChangeStatusCommand implements StubDescriptorModificationCommand {

    @Override
    public Map<String, StubDescriptor> modify(Map<String, StubDescriptor> stubDescriptors) {
        Map<String, StubDescriptor> updated = new LinkedHashMap<>(stubDescriptors);
        StubDescriptor selected = updated.get(groupName);
        if (selected != null) {
            StubDescriptorAttributes attributes = selected.getAttributes();
            attributes.setActive(nextStatus);
            if (nextStatus) {
                logger.info(urlAccessLogMessageAssembler.assembleMessage(request, groupName + " stub configuration: Enabled"));
            } else {
                logger.info(urlAccessLogMessageAssembler.assembleMessage(request, groupName + " stub configuration: Disabled"));
            }
        }
        return updated;
    }

}

class ChangeStatusCommandTest {

    private static final String GROUPNAME_FIRST;
    private Map<String, StubDescriptor> normalStubDescriptors;
    private StubDescriptorAttributes attributes;
    private StubDescriptor stubDescriptor;
    @Mock
    private HttpServletRequest request;
    @Mock
    private UrlAccessLogMessageAssembler urlAccessLogMessageAssembler;
    private ChangeStatusCommand underTest;

    @Test
    public void testSetStatusShouldDisableTheSelectedStubDescriptor() {

        //GIVEN in setUp
        normalStubDescriptors = new LinkedHashMap<>();
        attributes = new StubDescriptorAttributes(GROUPNAME_FIRST, true);
        stubDescriptor = new StubDescriptor(attributes, new ArrayList<DialogDescriptor>(), new ArrayList<InterceptorDescriptor>(), null);
        normalStubDescriptors.put(GROUPNAME_FIRST, stubDescriptor);
        //WHEN
        underTest = new ChangeStatusCommand(false, GROUPNAME_FIRST, request, urlAccessLogMessageAssembler);
        Map<String, StubDescriptor> result = underTest.modify(normalStubDescriptors);
        //THEN
        StubDescriptor resultDescriptor = result.get(GROUPNAME_FIRST);
        Assert.assertNotNull(resultDescriptor);
        boolean resultAttribute = resultDescriptor.getAttributes().isActive();
        Assert.assertFalse(resultAttribute);
    }

}