2 * ================================================================================
3 * Copyright (c) 2019 IBM Intellectual Property. All rights reserved.
4 * Copyright (c) 2021 China Mobile Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
20 package org.onap.dcae.analytics.tca.web.integration;
22 import java.util.HashMap;
25 import org.junit.jupiter.api.BeforeAll;
26 import org.junit.jupiter.api.Test;
27 import org.mockito.Mockito;
28 import org.onap.dcae.analytics.tca.web.TcaAppProperties;
29 import org.onap.dcae.analytics.tca.web.TcaAppProperties.Tca;
30 import org.springframework.messaging.MessageHeaders;
32 public class TcaPublisherResponseHandlerTest {
34 static MessageHeaders messageHeaders;
37 static void initialize() {
38 Map headers = new HashMap<>();
39 headers.put("X-ECOMP-RequestID", "TestRequestID");
40 headers.put("X-ECOMP-TransactionID", "TestTransactionID");
41 headers.put("X-ECOMP-FromAppID", "TestFromAppID");
42 messageHeaders = new MessageHeaders(headers);
47 void getHandleLoggingEnabledTest() throws Exception {
49 TcaAppProperties tcaAppProperties = Mockito.mock(TcaAppProperties.class);
50 Tca tca = Mockito.mock(Tca.class);
51 Mockito.when(tcaAppProperties.getTca()).thenReturn(tca);
52 Mockito.when(tcaAppProperties.getTca().getEnableEcompLogging()).thenReturn(true);
54 TcaPublisherResponseHandler responseHandler = new TcaPublisherResponseHandler(tcaAppProperties);
55 responseHandler.handle("testpayload", messageHeaders);
60 void getHandleLoggingNotEnabledTest() throws Exception {
62 TcaAppProperties tcaAppProperties = Mockito.mock(TcaAppProperties.class);
63 Tca tca = Mockito.mock(Tca.class);
64 Mockito.when(tcaAppProperties.getTca()).thenReturn(tca);
65 Mockito.when(tcaAppProperties.getTca().getEnableEcompLogging()).thenReturn(false);
67 TcaPublisherResponseHandler responseHandler = new TcaPublisherResponseHandler(tcaAppProperties);
68 responseHandler.handle("testpayload", messageHeaders);