2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5 * Modifications Copyright (C) 2019 Nordix Foundation.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.policy;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.assertTrue;
28 import org.junit.Test;
30 public class OperationsAccumulateParamsTest {
33 public void testConstructor() {
34 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
35 assertNull(operationsAccumulateParams.getPeriod());
36 assertNull(operationsAccumulateParams.getLimit());
40 public void testConstructorOperationsAccumulateParams() {
41 String period = "15m";
43 OperationsAccumulateParams operationsAccumulateParams1 =
44 new OperationsAccumulateParams(period, limit);
45 OperationsAccumulateParams operationsAccumulateParams2 =
46 new OperationsAccumulateParams(operationsAccumulateParams1);
47 assertEquals(period, operationsAccumulateParams1.getPeriod());
48 assertEquals(limit, operationsAccumulateParams2.getLimit());
52 public void testOperationsAccumulateParamsStringInteger() {
53 String period = "15m";
55 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(period, limit);
56 assertEquals(period, operationsAccumulateParams.getPeriod());
57 assertEquals(limit, operationsAccumulateParams.getLimit());
61 public void testSetAndGetPeriod() {
62 String period = "15m";
63 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
64 operationsAccumulateParams.setPeriod(period);
65 assertEquals(period, operationsAccumulateParams.getPeriod());
69 public void testSetLimit() {
71 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
72 operationsAccumulateParams.setLimit(limit);
73 assertEquals(limit, operationsAccumulateParams.getLimit());
77 public void testToString() {
78 String period = "15m";
80 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(period, limit);
81 assertEquals("OperationsAccumulateParams [period=15m, limit=10]", operationsAccumulateParams.toString());
85 public void testEqualsAndHashCode() {
86 final String period = "15m";
87 final Integer limit = 10;
88 OperationsAccumulateParams operationsAccumulateParams1 = new OperationsAccumulateParams();
89 OperationsAccumulateParams operationsAccumulateParams2 = new OperationsAccumulateParams();
91 assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2));
93 operationsAccumulateParams1.setPeriod(period);
94 assertFalse(operationsAccumulateParams1.equals(operationsAccumulateParams2));
95 operationsAccumulateParams2.setPeriod(period);
96 assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2));
97 assertEquals(operationsAccumulateParams1.hashCode(), operationsAccumulateParams2.hashCode());
99 operationsAccumulateParams1.setLimit(limit);;
100 assertFalse(operationsAccumulateParams1.equals(operationsAccumulateParams2));
101 operationsAccumulateParams2.setLimit(limit);
102 assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2));
103 assertEquals(operationsAccumulateParams1.hashCode(), operationsAccumulateParams2.hashCode());
108 public void testEqualsSameObject() {
109 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
110 assertTrue(operationsAccumulateParams.equals(operationsAccumulateParams));
114 public void testEqualsNull() {
115 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
116 assertFalse(operationsAccumulateParams.equals(null));
120 public void testEqualsInstanceOfDiffClass() {
121 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
122 assertFalse(operationsAccumulateParams.equals(""));