2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.holmes.common.api.entity;
19 import static org.hamcrest.core.IsEqual.equalTo;
20 import static org.junit.Assert.assertThat;
22 import java.util.Date;
23 import org.junit.After;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.holmes.common.api.stat.Alarm;
28 public class CorrelationResultTest {
30 private CorrelationResult correlationResult;
33 public void before() throws Exception {
34 correlationResult = new CorrelationResult();
38 public void after() throws Exception {
42 public void getterAndSetter4RuleId() throws Exception {
43 final String ruleId = "ruleId";
44 correlationResult.setRuleId(ruleId);
45 assertThat(correlationResult.getRuleId(), equalTo(ruleId));
49 public void getterAndSetter4CreateTimeL() throws Exception {
50 final long createTimeL = new Date().getTime();
51 correlationResult.setCreateTimeL(
53 assertThat(correlationResult.getCreateTimeL(), equalTo(createTimeL));
57 public void getterAndSetter4GetResultType() throws Exception {
58 final byte resultType = 2;
59 correlationResult.setResultType(resultType);
60 assertThat(correlationResult.getResultType(), equalTo(resultType));
64 public void getterAndSetter4AffectedAlarms() throws Exception {
65 final Alarm alarm[] = new Alarm[2];
66 correlationResult.setAffectedAlarms(alarm);
67 assertThat(correlationResult.getAffectedAlarms(), equalTo(alarm));
71 public void testToString() throws Exception {
72 CorrelationResult resultTemp = new CorrelationResult();
73 final String tempStr = "aa";
74 resultTemp.setRuleId(tempStr);
75 correlationResult.setRuleId(tempStr);
76 assertThat(correlationResult.toString(), equalTo(resultTemp.toString()));