Fix mongodb errors on application startup
[dcaegen2/analytics/tca-gen2.git] / dcae-analytics / dcae-analytics-tca-web / src / test / java / org / onap / dcae / analytics / tca / web / integration / TcaPublisherResponseHandlerTest.java
1 /*
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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=========================================================
18  *
19  */
20 package org.onap.dcae.analytics.tca.web.integration;
21
22 import java.util.HashMap;
23 import java.util.Map;
24
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;
31
32 public class TcaPublisherResponseHandlerTest {
33
34     static MessageHeaders messageHeaders;
35
36     @BeforeAll
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);
43
44     }
45
46     @Test
47     void getHandleLoggingEnabledTest() throws Exception {
48
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);
53
54         TcaPublisherResponseHandler responseHandler = new TcaPublisherResponseHandler(tcaAppProperties);
55         responseHandler.handle("testpayload", messageHeaders);
56
57     }
58
59     @Test
60     void getHandleLoggingNotEnabledTest() throws Exception {
61
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);
66
67         TcaPublisherResponseHandler responseHandler = new TcaPublisherResponseHandler(tcaAppProperties);
68         responseHandler.handle("testpayload", messageHeaders);
69
70     }
71
72 }
73