2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 IBM.
6 * Modifications Copyright (C) 2020-2022 Bell Canada.
7 * Modifications Copyright (C) 2021 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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * SPDX-License-Identifier: Apache-2.0
22 * ============LICENSE_END=========================================================
25 package org.onap.policy.api.main.rest;
27 import static org.junit.Assert.assertEquals;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.onap.policy.api.main.PolicyApiApplication;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.boot.test.context.SpringBootTest;
34 import org.springframework.test.context.ActiveProfiles;
35 import org.springframework.test.context.junit4.SpringRunner;
37 @RunWith(SpringRunner.class)
38 @SpringBootTest(classes = PolicyApiApplication.class)
39 @ActiveProfiles("test")
40 public class TestApiStatisticsManager {
43 private ApiStatisticsManager mgr = new ApiStatisticsManager();
46 public void testUpdateMethods() {
47 assertEquals(1, mgr.updateTotalApiCallCount());
48 assertEquals(1, mgr.updateApiCallSuccessCount());
49 assertEquals(1, mgr.updateApiCallFailureCount());
50 assertEquals(1, mgr.updateTotalPolicyGetCount());
51 assertEquals(1, mgr.updateTotalPolicyPostCount());
52 assertEquals(1, mgr.updateTotalPolicyDeleteCount());
53 assertEquals(1, mgr.updateTotalPolicyTypeGetCount());
54 assertEquals(1, mgr.updateTotalPolicyTypePostCount());
55 assertEquals(1, mgr.updateTotalPolicyTypeDeleteCount());
56 assertEquals(1, mgr.updatePolicyGetSuccessCount());
57 assertEquals(1, mgr.updatePolicyGetFailureCount());
58 assertEquals(1, mgr.updatePolicyPostSuccessCount());
59 assertEquals(1, mgr.updatePolicyPostFailureCount());
60 assertEquals(1, mgr.updatePolicyDeleteSuccessCount());
61 assertEquals(1, mgr.updatePolicyDeleteFailureCount());
62 assertEquals(1, mgr.updatePolicyTypeGetSuccessCount());
63 assertEquals(1, mgr.updatePolicyTypeGetFailureCount());
64 assertEquals(1, mgr.updatePolicyTypePostSuccessCount());
65 assertEquals(1, mgr.updatePolicyTypePostFailureCount());
66 assertEquals(1, mgr.updatePolicyTypeDeleteSuccessCount());
67 assertEquals(1, mgr.updatePolicyTypeDeleteFailureCount());