2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2018 AT&T Intellectual 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.policy.controlloop.policy;
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertNull;
25 import static org.junit.Assert.assertTrue;
27 import org.junit.Test;
29 public class OperationsAccumulateParamsTest {
32 public void testConstructor() {
33 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
34 assertNull(operationsAccumulateParams.getPeriod());
35 assertNull(operationsAccumulateParams.getLimit());
39 public void testConstructorOperationsAccumulateParams() {
40 String period = "15m";
42 OperationsAccumulateParams operationsAccumulateParams1 =
43 new OperationsAccumulateParams(period, limit);
44 OperationsAccumulateParams operationsAccumulateParams2 =
45 new OperationsAccumulateParams(operationsAccumulateParams1);
46 assertEquals(period, operationsAccumulateParams1.getPeriod());
47 assertEquals(limit, operationsAccumulateParams2.getLimit());
51 public void testOperationsAccumulateParamsStringInteger() {
52 String period = "15m";
54 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(period, limit);
55 assertEquals(period, operationsAccumulateParams.getPeriod());
56 assertEquals(limit, operationsAccumulateParams.getLimit());
60 public void testSetAndGetPeriod() {
61 String period = "15m";
62 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
63 operationsAccumulateParams.setPeriod(period);
64 assertEquals(period, operationsAccumulateParams.getPeriod());
68 public void testSetLimit() {
70 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
71 operationsAccumulateParams.setLimit(limit);
72 assertEquals(limit, operationsAccumulateParams.getLimit());
76 public void testToString() {
77 String period = "15m";
79 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(period, limit);
80 assertEquals("OperationsAccumulateParams [period=15m, limit=10]", operationsAccumulateParams.toString());
84 public void testEqualsAndHashCode() {
85 final String period = "15m";
86 final Integer limit = 10;
87 OperationsAccumulateParams operationsAccumulateParams1 = new OperationsAccumulateParams();
88 OperationsAccumulateParams operationsAccumulateParams2 = new OperationsAccumulateParams();
90 assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2));
92 operationsAccumulateParams1.setPeriod(period);
93 assertFalse(operationsAccumulateParams1.equals(operationsAccumulateParams2));
94 operationsAccumulateParams2.setPeriod(period);
95 assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2));
96 assertEquals(operationsAccumulateParams1.hashCode(), operationsAccumulateParams2.hashCode());
98 operationsAccumulateParams1.setLimit(limit);;
99 assertFalse(operationsAccumulateParams1.equals(operationsAccumulateParams2));
100 operationsAccumulateParams2.setLimit(limit);
101 assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2));
102 assertEquals(operationsAccumulateParams1.hashCode(), operationsAccumulateParams2.hashCode());
107 public void testEqualsSameObject() {
108 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
109 assertTrue(operationsAccumulateParams.equals(operationsAccumulateParams));
113 public void testEqualsNull() {
114 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
115 assertFalse(operationsAccumulateParams.equals(null));
119 public void testEqualsInstanceOfDiffClass() {
120 OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams();
121 assertFalse(operationsAccumulateParams.equals(""));