blob: f05e93c828373f11fc07e801f125429eef384fae [file] [log] [blame]
Ray Milkeybd4f0112015-03-02 17:07:09 -08001/*
2 * Copyright 2015 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.onosproject.net.intent;
17
Ray Milkeya05fd202015-04-27 15:27:30 -070018import org.hamcrest.Matchers;
19import org.junit.Before;
Ray Milkeybd4f0112015-03-02 17:07:09 -080020import org.junit.Test;
Ray Milkeya05fd202015-04-27 15:27:30 -070021import org.onosproject.net.Path;
Ray Milkeybd4f0112015-03-02 17:07:09 -080022
Ray Milkeya05fd202015-04-27 15:27:30 -070023import com.google.common.testing.EqualsTester;
24
25import static org.hamcrest.MatcherAssert.assertThat;
26import static org.hamcrest.Matchers.is;
27import static org.hamcrest.core.IsEqual.equalTo;
Ray Milkeybd4f0112015-03-02 17:07:09 -080028import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
Ray Milkeya05fd202015-04-27 15:27:30 -070029import static org.onosproject.net.NetTestTools.APP_ID;
30import static org.onosproject.net.NetTestTools.connectPoint;
31import static org.onosproject.net.NetTestTools.createPath;
Ray Milkeybd4f0112015-03-02 17:07:09 -080032
Ray Milkeya05fd202015-04-27 15:27:30 -070033public class OpticalPathIntentTest extends AbstractIntentTest {
34
35 static final int PRIORITY = 777;
36
37 OpticalPathIntent intent1;
38 OpticalPathIntent intent2;
39 Path defaultPath;
40
41 @Before
42 public void opticalPathIntentTestSetUp() {
43 defaultPath = createPath("a", "b", "c");
44 intent1 = OpticalPathIntent.builder()
45 .appId(APP_ID)
46 .src(connectPoint("one", 1))
47 .dst(connectPoint("two", 2))
48 .path(defaultPath)
49 .priority(PRIORITY)
50 .build();
51
52 intent2 = OpticalPathIntent.builder()
53 .appId(APP_ID)
54 .src(connectPoint("two", 1))
55 .dst(connectPoint("one", 2))
56 .path(defaultPath)
57 .priority(PRIORITY)
58 .build();
59 }
Ray Milkeybd4f0112015-03-02 17:07:09 -080060
61 /**
62 * Checks that the OpticalPathIntent class is immutable.
63 */
64 @Test
65 public void testImmutability() {
66 assertThatClassIsImmutable(OpticalPathIntent.class);
67 }
68
Ray Milkeya05fd202015-04-27 15:27:30 -070069 /**
70 * Checks the operation of equals(), hashCode() and toString() methods.
71 */
72 @Test
73 public void testEquals() {
74 new EqualsTester()
75 .addEqualityGroup(intent1)
76 .addEqualityGroup(intent2)
77 .testEquals();
78 }
79
80 /**
81 * Checks that the optical path ntent objects are created correctly.
82 */
83 @Test
84 public void testContents() {
85 assertThat(intent1.appId(), equalTo(APP_ID));
86 assertThat(intent1.src(), Matchers.equalTo(connectPoint("one", 1)));
87 assertThat(intent1.dst(), Matchers.equalTo(connectPoint("two", 2)));
88 assertThat(intent1.priority(), is(PRIORITY));
89 assertThat(intent1.path(), is(defaultPath));
90 }
Ray Milkeybd4f0112015-03-02 17:07:09 -080091}