blob: 3109cadbd3bb45b889330e9119daf268e2217200 [file] [log] [blame]
Ray Milkeybd4f0112015-03-02 17:07:09 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Ray Milkeybd4f0112015-03-02 17:07:09 -08003 *
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;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070021import org.onosproject.net.OchSignalType;
Ray Milkeya05fd202015-04-27 15:27:30 -070022import org.onosproject.net.Path;
Ray Milkeybd4f0112015-03-02 17:07:09 -080023
Ray Milkeya05fd202015-04-27 15:27:30 -070024import com.google.common.testing.EqualsTester;
25
26import static org.hamcrest.MatcherAssert.assertThat;
27import static org.hamcrest.Matchers.is;
28import static org.hamcrest.core.IsEqual.equalTo;
Ray Milkeybd4f0112015-03-02 17:07:09 -080029import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
Ray Milkeya05fd202015-04-27 15:27:30 -070030import static org.onosproject.net.NetTestTools.APP_ID;
31import static org.onosproject.net.NetTestTools.connectPoint;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070032import static org.onosproject.net.NetTestTools.createLambda;
Ray Milkeya05fd202015-04-27 15:27:30 -070033import static org.onosproject.net.NetTestTools.createPath;
Ray Milkeybd4f0112015-03-02 17:07:09 -080034
Ray Milkeya05fd202015-04-27 15:27:30 -070035public class OpticalPathIntentTest extends AbstractIntentTest {
36
37 static final int PRIORITY = 777;
38
39 OpticalPathIntent intent1;
40 OpticalPathIntent intent2;
41 Path defaultPath;
42
43 @Before
44 public void opticalPathIntentTestSetUp() {
45 defaultPath = createPath("a", "b", "c");
46 intent1 = OpticalPathIntent.builder()
47 .appId(APP_ID)
48 .src(connectPoint("one", 1))
49 .dst(connectPoint("two", 2))
50 .path(defaultPath)
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070051 .lambda(createLambda())
Marc De Leenheerd24420f2015-05-27 09:40:59 -070052 .signalType(OchSignalType.FIXED_GRID)
Ray Milkeya05fd202015-04-27 15:27:30 -070053 .priority(PRIORITY)
54 .build();
55
56 intent2 = OpticalPathIntent.builder()
57 .appId(APP_ID)
58 .src(connectPoint("two", 1))
59 .dst(connectPoint("one", 2))
60 .path(defaultPath)
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070061 .lambda(createLambda())
Marc De Leenheerd24420f2015-05-27 09:40:59 -070062 .signalType(OchSignalType.FIXED_GRID)
Ray Milkeya05fd202015-04-27 15:27:30 -070063 .priority(PRIORITY)
64 .build();
65 }
Ray Milkeybd4f0112015-03-02 17:07:09 -080066
67 /**
68 * Checks that the OpticalPathIntent class is immutable.
69 */
70 @Test
71 public void testImmutability() {
72 assertThatClassIsImmutable(OpticalPathIntent.class);
73 }
74
Ray Milkeya05fd202015-04-27 15:27:30 -070075 /**
76 * Checks the operation of equals(), hashCode() and toString() methods.
77 */
78 @Test
79 public void testEquals() {
80 new EqualsTester()
81 .addEqualityGroup(intent1)
82 .addEqualityGroup(intent2)
83 .testEquals();
84 }
85
86 /**
Marc De Leenheerd24420f2015-05-27 09:40:59 -070087 * Checks that the optical path intent objects are created correctly.
Ray Milkeya05fd202015-04-27 15:27:30 -070088 */
89 @Test
90 public void testContents() {
91 assertThat(intent1.appId(), equalTo(APP_ID));
92 assertThat(intent1.src(), Matchers.equalTo(connectPoint("one", 1)));
93 assertThat(intent1.dst(), Matchers.equalTo(connectPoint("two", 2)));
94 assertThat(intent1.priority(), is(PRIORITY));
95 assertThat(intent1.path(), is(defaultPath));
96 }
Ray Milkeybd4f0112015-03-02 17:07:09 -080097}