2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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 * ============LICENSE_END=========================================================
19 package org.onap.policy.guard;
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertNotEquals;
23 import static org.junit.Assert.assertTrue;
25 import java.util.Date;
26 import org.junit.Test;
28 public class OperationsHistoryTest {
32 OperationsHistory dao = new OperationsHistory();
34 dao.setActor("my-actor");
35 dao.setClosedLoopName("cl-name");
36 Date endDate = new Date();
37 dao.setEndtime(endDate);
39 dao.setMessage("my-message");
40 dao.setOperation("my-operation");
41 dao.setOutcome("my-outcome");
42 dao.setRequestId("my-request");
43 Date startDate = new Date(endDate.getTime() - 1);
44 dao.setStarttime(startDate);
45 dao.setSubrequestId("my-sub");
46 dao.setTarget("my-target");
48 assertEquals("my-actor", dao.getActor());
49 assertEquals("cl-name", dao.getClosedLoopName());
50 assertEquals(endDate, dao.getEndtime());
51 assertEquals(100L, dao.getId().longValue());
52 assertEquals("my-message", dao.getMessage());
53 assertEquals("my-operation", dao.getOperation());
54 assertEquals("my-outcome", dao.getOutcome());
55 assertEquals("my-request", dao.getRequestId());
56 assertEquals(startDate, dao.getStarttime());
57 assertEquals("my-sub", dao.getSubrequestId());
58 assertEquals("my-target", dao.getTarget());
60 assertTrue(dao.toString().startsWith("OperationsHistory"));
62 int hc = dao.hashCode();
64 assertNotEquals(hc, dao.hashCode());
66 assertEquals(dao, (Object) dao);
67 assertNotEquals(dao, new OperationsHistory());