/*
 * Copyright (c) 2010-2019. Axon Framework
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.axonframework.axonserver.connector.processor;

import org.axonframework.axonserver.connector.AxonServerConfiguration;
import org.axonframework.axonserver.connector.AxonServerConnectionManager;
import org.junit.jupiter.api.*;

import java.util.function.Consumer;

import static io.axoniq.axonserver.grpc.control.PlatformOutboundInstruction.RequestCase.*;
import static org.axonframework.axonserver.connector.TestTargetContextResolver.BOUNDED_CONTEXT;
import static org.mockito.Mockito.*;

class EventProcessorControlServiceTest {

    private final AxonServerConnectionManager axonServerConnectionManager = mock(AxonServerConnectionManager.class);
    private final EventProcessorController eventProcessorController = mock(EventProcessorController.class);

    @BeforeEach
    void setUp() {
        when(axonServerConnectionManager.getDefaultContext()).thenReturn(BOUNDED_CONTEXT);

        EventProcessorControlService testSubject =
                new EventProcessorControlService(axonServerConnectionManager,
                                                 eventProcessorController,
                                                 new AxonServerConfiguration());
        testSubject.start();
    }

    @SuppressWarnings("unchecked")
    @Test
    void testStartAddOutboundInstructionToTheAxonServerConnectionManager() {
        verify(axonServerConnectionManager).onOutboundInstruction(
                eq(BOUNDED_CONTEXT), eq(PAUSE_EVENT_PROCESSOR), any(Consumer.class)
        );
        verify(axonServerConnectionManager).onOutboundInstruction(
                eq(BOUNDED_CONTEXT), eq(START_EVENT_PROCESSOR), any(Consumer.class)
        );
        verify(axonServerConnectionManager).onOutboundInstruction(
                eq(BOUNDED_CONTEXT), eq(RELEASE_SEGMENT), any(Consumer.class)
        );
        verify(axonServerConnectionManager).onOutboundInstruction(
                eq(BOUNDED_CONTEXT), eq(REQUEST_EVENT_PROCESSOR_INFO), any(Consumer.class)
        );
        verify(axonServerConnectionManager).onOutboundInstruction(
                eq(BOUNDED_CONTEXT), eq(SPLIT_EVENT_PROCESSOR_SEGMENT), any(Consumer.class)
        );
        verify(axonServerConnectionManager).onOutboundInstruction(
                eq(BOUNDED_CONTEXT), eq(MERGE_EVENT_PROCESSOR_SEGMENT), any(Consumer.class)
        );
        verify(axonServerConnectionManager, atLeastOnce()).getDefaultContext();
        verifyNoMoreInteractions(axonServerConnectionManager);
    }
}

@@ -1143,16 +1143,111 @@
 Test %7B%0A%0A
+    private final AxonServerConfiguration configuration = mock(AxonServerConfiguration.class);%0A
     priv
@@ -1347,32 +1347,32 @@
 Manager.class);%0A
-
     private fina
@@ -1516,45 +1516,24 @@
 hen(
-axonServerConnectionManager.getDefaul
+configuration.ge
 tCon
@@ -1827,23 +1827,9 @@
     
-new AxonServerC
+c
 onfi
@@ -1836,18 +1836,16 @@
 guration
-()
 );%0A     
@@ -3005,35 +3005,21 @@
 ify(
-axonServerConnectionManager
+configuration
 , at
@@ -3038,15 +3038,8 @@
 .get
-Default
 Cont

Fix unit test.