ServiceRegistry serviceRegistry = Mockito.mock(ServiceRegistry.class);
ServiceController serviceController = Mockito.mock(ServiceController.class);
Mockito.when(serviceController.getValue()).thenReturn(stateService);
Mockito.when(serviceRegistry.getService(SubsystemState.SERVICE_NAME)).thenReturn(serviceController);
ModelNode result = new ModelNode();
final OperationContext context = Mockito.mock(OperationContext.class);
Resource resource = Mockito.mock(Resource.class);
Mockito.when(resource.getModel()).thenReturn(result);
Mockito.when(context.getServiceRegistry(true)).thenReturn(serviceRegistry);
Mockito.when(context.completeStep()).thenReturn(stepResult);
Mockito.when(context.createResource(PathAddress.EMPTY_ADDRESS)).thenReturn(resource);
Mockito.when(context.readResource(PathAddress.EMPTY_ADDRESS)).thenReturn(resource);
Mockito.when(context.getProcessType()).thenReturn(ProcessType.STANDALONE_SERVER);
Mockito.when(context.getRunningMode()).thenReturn(RunningMode.NORMAL);
Mockito.when(context.isNormalServer()).thenReturn(true);
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
addedSteps.add((OperationStepHandler) invocation.getArguments()[0]);
return null;