2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.aai.sparky.subscription;
24 import org.apache.camel.Exchange;
25 import org.apache.camel.Message;
26 import org.apache.camel.component.restlet.RestletConstants;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.mockito.Mockito;
30 import org.onap.aai.sparky.subscription.services.SubscriptionService;
31 import org.onap.aai.sparky.util.RestletUtils;
32 import org.restlet.Request;
33 import org.restlet.Response;
34 import org.restlet.data.ClientInfo;
36 public class SubscriptionServiceProcessorTest {
37 private SubscriptionServiceProcessor subscriptionProcessor;
38 private Exchange mockExchange;
39 private Message mockRequestMessage;
40 private Message mockResponseMessage;
41 private Request mockRestletRequest;
42 private Response mockRestletResponse;
43 private ClientInfo requestClientInfo;
44 private RestletUtils mockRestletUtils;
45 private SubscriptionService mockSubscriptionService;
49 public void init() throws Exception {
51 mockExchange = Mockito.mock(Exchange.class);
52 mockRequestMessage = Mockito.mock(Message.class);
53 mockResponseMessage = Mockito.mock(Message.class);
54 mockRestletRequest = Mockito.mock(Request.class);
55 mockRestletResponse = Mockito.mock(Response.class);
56 mockRestletUtils = Mockito.mock(RestletUtils.class);
57 mockSubscriptionService = Mockito.mock(SubscriptionService.class);
58 subscriptionProcessor = new SubscriptionServiceProcessor(mockSubscriptionService);
60 requestClientInfo = new ClientInfo();
62 Mockito.when(mockExchange.getIn()).thenReturn(mockRequestMessage);
63 Mockito.when(mockExchange.getOut()).thenReturn(mockResponseMessage);
65 Mockito.when(mockRequestMessage.getHeader(RestletConstants.RESTLET_REQUEST, Request.class))
66 .thenReturn(mockRestletRequest);
68 Mockito.when(mockRestletRequest.getClientInfo()).thenReturn(requestClientInfo);
71 Mockito.when(mockRequestMessage.getHeader(RestletConstants.RESTLET_RESPONSE, Response.class))
72 .thenReturn(mockRestletResponse);
77 @Test(expected = NullPointerException.class)
78 public void testGetEntityCountHistory_success() {
80 subscriptionProcessor.getSubscription(mockExchange);