blob: 84ef04bc351b6dbb06a7562ffd1a4bc439ca77e6 [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
kmcpeake4fe18c82015-11-17 20:07:39 +00003 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16package org.onosproject.incubator.net.faultmanagement.alarm;
17
18import com.google.common.testing.EqualsTester;
19import static org.junit.Assert.assertEquals;
20import org.junit.Test;
21import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
22import static org.onosproject.incubator.net.faultmanagement.alarm.AlarmEntityId.alarmEntityId;
23
24/**
25 * Test of the alarm source identifier.
26 *
27 */
28public class AlarmEntityIdTest {
29
30 /**
31 * Checks that the class is immutable.
32 */
33 @Test
34 public void testImmutability() {
35 assertThatClassIsImmutable(AlarmEntityId.class);
36 }
37
38 @Test
39 public void string() {
40 assertEquals("och:foo",
41 alarmEntityId("och:foo").toString());
42 }
43
44 @Test
45 public void basics() {
46 new EqualsTester()
47 .addEqualityGroup(
48 alarmEntityId("och:foo"),
49 alarmEntityId("och:foo"))
50 .addEqualityGroup(alarmEntityId("och:bar"))
51 .testEquals();
52
53 }
54
55 @Test
56 public void validSchemaPermitted() {
57 alarmEntityId("none:foo");
58 alarmEntityId("port:foo");
59 alarmEntityId("och:foo");
60 alarmEntityId("other:foo");
61
62 }
63
64 @Test(expected = IllegalArgumentException.class)
65 public void verifyUnexpectedSchemaRejected() {
66 alarmEntityId("junk:foo");
67 }
68
69 @Test(expected = IllegalArgumentException.class)
70 public void verifyCorruptSchemaRejected() {
71 alarmEntityId("other:");
72 }
73
74}