2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
4 * Modifications Copyright (C) 2024 Nordix Foundation
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.models.pap.concepts;
22 import static org.junit.jupiter.api.Assertions.assertEquals;
23 import static org.junit.jupiter.api.Assertions.assertFalse;
24 import static org.junit.jupiter.api.Assertions.assertSame;
25 import static org.junit.jupiter.api.Assertions.assertTrue;
27 import java.util.Arrays;
28 import java.util.Collections;
29 import java.util.List;
30 import org.junit.jupiter.api.Test;
31 import org.onap.policy.common.utils.coder.CoderException;
32 import org.onap.policy.common.utils.coder.StandardCoder;
35 * This only tests the methods that aren't already tested via TestModels.
37 class PolicyNotificationTest {
40 void test() throws CoderException {
41 PolicyStatus statusAdd1 = new PolicyStatus();
42 statusAdd1.setSuccessCount(10);
43 PolicyStatus statusAdd2 = new PolicyStatus();
44 statusAdd2.setFailureCount(20);
45 List<PolicyStatus> add = Arrays.asList(statusAdd1, statusAdd2);
47 PolicyStatus statusDel1 = new PolicyStatus();
48 statusDel1.setIncompleteCount(30);
49 PolicyStatus statusDel2 = new PolicyStatus();
50 List<PolicyStatus> del = Arrays.asList(statusDel1, statusDel2);
52 // test constructor with arguments
53 PolicyNotification notify = new PolicyNotification(add, del);
54 assertSame(add, notify.getAdded());
55 assertSame(del, notify.getDeleted());
58 StandardCoder coder = new StandardCoder();
59 PolicyNotification notify2 = coder.decode(coder.encode(notify), PolicyNotification.class);
61 // test equals() method (and verify encode/decode worked)
62 assertEquals(notify, notify2);
67 assertFalse(notify.isEmpty());
68 assertFalse(notify2.isEmpty());
69 assertTrue(new PolicyNotification().isEmpty());
70 assertFalse(new PolicyNotification(add, Collections.emptyList()).isEmpty());
71 assertFalse(new PolicyNotification(Collections.emptyList(), del).isEmpty());