2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019 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.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.model.eventmodel.concepts;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertNotEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
30 import org.junit.Test;
31 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
32 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
33 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
37 * @author Liam Fallon (liam.fallon@ericsson.com)
39 public class EventModelTest {
42 public void testEventModel() {
43 assertNotNull(new AxEventModel());
44 assertNotNull(new AxEventModel(new AxArtifactKey()));
46 new AxEventModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation(), new AxEvents()));
48 final AxArtifactKey modelKey = new AxArtifactKey("ModelKey", "0.0.1");
49 final AxArtifactKey schemasKey = new AxArtifactKey("SchemasKey", "0.0.1");
50 final AxArtifactKey eventsKey = new AxArtifactKey("EventsKey", "0.0.1");
51 final AxArtifactKey keyInfoKey = new AxArtifactKey("SchemasKey", "0.0.1");
52 final AxEventModel model = new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
53 new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey));
58 assertEquals("AxEventModel:(AxEventModel:(key=AxArtifactKey:(nam", model.toString().substring(0, 50));
60 final AxEventModel clonedModel = new AxEventModel(model);
62 assertFalse(model.hashCode() == 0);
64 assertTrue(model.equals(model));
65 assertTrue(model.equals(clonedModel));
66 assertFalse(model.equals((Object) "Hello"));
67 assertFalse(model.equals(new AxEventModel(new AxArtifactKey())));
68 assertFalse(model.equals(new AxEventModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey),
69 new AxEvents(eventsKey))));
70 assertFalse(model.equals(new AxEventModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(),
71 new AxEvents(eventsKey))));
72 assertFalse(model.equals(new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
73 new AxKeyInformation(keyInfoKey), new AxEvents())));
74 assertTrue(model.equals(new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
75 new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))));
77 assertEquals(0, model.compareTo(model));
78 assertEquals(0, model.compareTo(clonedModel));
79 assertNotEquals(0, model.compareTo(new AxArtifactKey()));
80 assertNotEquals(0, model.compareTo(new AxEventModel(modelKey, new AxContextSchemas(),
81 new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))));
82 assertNotEquals(0, model.compareTo(new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
83 new AxKeyInformation(), new AxEvents(eventsKey))));
84 assertNotEquals(0, model.compareTo(new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
85 new AxKeyInformation(keyInfoKey), new AxEvents())));
86 assertEquals(0, model.compareTo(new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
87 new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))));