blob: a6ce3dd39fbca8256f8941086e2841b7a7a33096 [file] [log] [blame]
Ray Milkeyc8f481f2014-11-18 15:37:12 -08001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
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.onlab.onos.net.intent;
17
Brian O'Connor520c0522014-11-23 23:50:47 -080018import org.junit.Ignore;
Ray Milkeyc8f481f2014-11-18 15:37:12 -080019import org.junit.Test;
20import org.onlab.onos.net.HostId;
21import org.onlab.onos.net.flow.TrafficSelector;
22
23import com.google.common.testing.EqualsTester;
24
25import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
26import static org.onlab.onos.net.NetTestTools.APP_ID;
27import static org.onlab.onos.net.NetTestTools.hid;
28
29/**
30 * Unit tests for the HostToHostIntent class.
31 */
Brian O'Connor520c0522014-11-23 23:50:47 -080032public class HostToHostIntentTest extends IntentTest {
33 private final TrafficSelector selector = new IntentTestsMocks.MockSelector();
34 private final IntentTestsMocks.MockTreatment treatment = new IntentTestsMocks.MockTreatment();
35 private final HostId id1 = hid("12:34:56:78:91:ab/1");
36 private final HostId id2 = hid("12:34:56:78:92:ab/1");
37 private final HostId id3 = hid("12:34:56:78:93:ab/1");
Ray Milkeyc8f481f2014-11-18 15:37:12 -080038
39 /**
40 * Checks that the HostToHostIntent class is immutable.
41 */
42 @Test
43 public void testImmutability() {
44 assertThatClassIsImmutable(HostToHostIntent.class);
45 }
46
47 /**
48 * Tests equals(), hashCode() and toString() methods.
49 */
Brian O'Connor520c0522014-11-23 23:50:47 -080050 @Test @Ignore("Equality is based on ids, which will be different")
Ray Milkeyc8f481f2014-11-18 15:37:12 -080051 public void testEquals() {
Ray Milkeyc8f481f2014-11-18 15:37:12 -080052 final HostToHostIntent intent1 = new HostToHostIntent(APP_ID,
53 id1,
54 id2,
55 selector,
56 treatment);
57 final HostToHostIntent sameAsIntent1 = new HostToHostIntent(APP_ID,
58 id1,
59 id2,
60 selector,
61 treatment);
62 final HostToHostIntent intent2 = new HostToHostIntent(APP_ID,
63 id2,
64 id3,
65 selector,
66 treatment);
67
68 new EqualsTester()
69 .addEqualityGroup(intent1, sameAsIntent1)
70 .addEqualityGroup(intent2)
71 .testEquals();
72 }
Brian O'Connor520c0522014-11-23 23:50:47 -080073
74 @Override
75 protected Intent createOne() {
76 return new HostToHostIntent(APP_ID, id1, id2, selector, treatment);
77 }
78
79 @Override
80 protected Intent createAnother() {
81 return new HostToHostIntent(APP_ID, id1, id3, selector, treatment);
82 }
Ray Milkeyc8f481f2014-11-18 15:37:12 -080083}