2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.service.engine.engdep;
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertTrue;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.mockito.MockitoAnnotations;
31 import org.onap.policy.apex.core.infrastructure.messaging.MessagingService;
32 import org.onap.policy.apex.core.protocols.Message;
33 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
36 * Test the EngDep messaging Service.
38 public class EngDepMessagingServiceTest {
40 private MessagingService<Message> messageServiceMock;
41 private EngDepMessagingService edMessagingService;
44 * Set up mocking of the engine service facade.
46 * @throws ApexException on engine service facade setup errors
49 public void initializeMocking() throws ApexException {
50 MockitoAnnotations.initMocks(this);
52 edMessagingService = Mockito.spy(new EngDepMessagingService(new DummyEngineService(), 12345));
53 Mockito.doReturn(messageServiceMock).when(edMessagingService).getMessageService(12345);
57 public void testStartStop() throws ApexException {
58 edMessagingService.start();
59 assertTrue(edMessagingService.isStarted());
60 assertFalse(edMessagingService.isStopped());
61 edMessagingService.stop();
62 assertTrue(edMessagingService.isStopped());
63 assertFalse(edMessagingService.isStarted());