Change code to use dmaap microservice
[appc.git] / appc-dispatcher / appc-request-handler / appc-request-handler-core / src / test / java / org / onap / appc / messageadapter / impl / MessageAdapterImplTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2019 Ericsson
6  * ================================================================================
7  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.messageadapter.impl;
25
26 import static org.junit.Assert.assertTrue;
27
28 import javax.ws.rs.core.Response.Status;
29
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.mockito.Mockito;
33 import org.onap.appc.domainmodel.lcm.CommonHeader;
34 import org.onap.appc.domainmodel.lcm.ResponseContext;
35 import org.onap.appc.domainmodel.lcm.VNFOperation;
36 import org.onap.appc.srvcomm.messaging.MessagingConnector;
37 import com.att.eelf.configuration.EELFLogger;
38 import com.att.eelf.configuration.EELFManager;
39 import com.fasterxml.jackson.core.JsonProcessingException;
40
41 public class MessageAdapterImplTest {
42
43     private final MessagingConnector connector = Mockito.mock(MessagingConnector.class);
44     private static final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapterImpl.class);
45     private final MessageAdapterImpl impl = new MessageAdapterImpl();
46     
47     @Before
48     public void setUp() {
49         impl.init(connector);
50     }
51
52     @Test
53     public void testSuccess() throws JsonProcessingException {
54
55         ResponseContext context = new ResponseContext();
56         context.setPayload("payload");
57         org.onap.appc.domainmodel.lcm.Status status = new org.onap.appc.domainmodel.lcm.Status();
58         status.setCode(200);
59         status.setMessage("success");
60         context.setStatus(status);
61         CommonHeader commonHeader = new CommonHeader();
62         commonHeader.setRequestId("test123");
63         commonHeader.setSubRequestId("test456");
64         context.setCommonHeader(commonHeader);
65         Mockito.when(connector.publishMessage(Mockito.any(), Mockito.any(),Mockito.any())).thenReturn(true);
66         assertTrue(impl.post(VNFOperation.Start, "test", context));
67     }
68
69 }