Improve Test coverage of DFC
[nonrtric/plt/ranpm.git] / datafilecollector / src / test / java / org / oran / datafile / model / CountersTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019-2023 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.oran.datafile.model;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24
25 import org.junit.jupiter.api.Test;
26
27 class CountersTest {
28     @Test
29     void testIncNoOfReceivedEvents() {
30         Counters counters = new Counters();
31         counters.incNoOfReceivedEvents();
32         assertEquals(1L, counters.getTotalReceivedEvents());
33     }
34
35     @Test
36     void testIncNoOfCollectedFiles() {
37         Counters counters = new Counters();
38         counters.incNoOfCollectedFiles();
39         counters.incNoOfFailedFtp();
40         counters.incNoOfFailedFtpAttempts();
41         counters.incNoOfFailedHttp();
42         counters.incNoOfFailedHttpAttempts();
43         counters.incNoOfFailedPublish();
44         counters.incNoOfFailedPublishAttempts();
45         String actualToStringResult = counters.toString();
46         long actualNoOfCollectedFiles = counters.getNoOfCollectedFiles();
47         long actualNoOfFailedFtp = counters.getNoOfFailedFtp();
48         long actualNoOfFailedFtpAttempts = counters.getNoOfFailedFtpAttempts();
49         long actualNoOfFailedHttp = counters.getNoOfFailedHttp();
50         long actualNoOfFailedHttpAttempts = counters.getNoOfFailedHttpAttempts();
51         long actualNoOfFailedPublish = counters.getNoOfFailedPublish();
52         long actualNoOfFailedPublishAttempts = counters.getNoOfFailedPublishAttempts();
53         long actualTotalPublishedFiles = counters.getTotalPublishedFiles();
54         assertEquals(1L, actualNoOfCollectedFiles);
55         assertEquals(1L, actualNoOfFailedFtp);
56         assertEquals(1L, actualNoOfFailedFtpAttempts);
57         assertEquals(1L, actualNoOfFailedHttp);
58         assertEquals(1L, actualNoOfFailedHttpAttempts);
59         assertEquals(1L, actualNoOfFailedPublish);
60         assertEquals(1L, actualNoOfFailedPublishAttempts);
61         assertEquals(0L, actualTotalPublishedFiles);
62         assertEquals(0L, counters.getTotalReceivedEvents());
63     }
64     @Test
65     void testIncTotalPublishedFiles() {
66         Counters counters = new Counters();
67         counters.incTotalPublishedFiles();
68         assertEquals(1L, counters.getTotalPublishedFiles());
69     }
70 }
71