blob: 7f83850c903a8bc5fdc1e07706bae9b5f2317203 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
Brian O'Connorf3d06162014-10-02 15:54:12 -070017
18import org.junit.Test;
19
20import static org.junit.Assert.assertEquals;
Ray Milkey37f6a382014-11-25 14:54:42 -080021import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
Brian O'Connorf3d06162014-10-02 15:54:12 -070022
23/**
24 * Suite of tests of the point-to-point intent descriptor.
25 */
26public class PointToPointIntentTest extends ConnectivityIntentTest {
27
Ray Milkey37f6a382014-11-25 14:54:42 -080028 /**
helenyrwu2a674902016-07-20 09:48:04 -070029 * Checks that the PointToPointIntent class is immutable.
Ray Milkey37f6a382014-11-25 14:54:42 -080030 */
31 @Test
32 public void checkImmutability() {
33 assertThatClassIsImmutableBaseClass(PointToPointIntent.class);
34 }
35
Brian O'Connorf3d06162014-10-02 15:54:12 -070036 @Test
37 public void basics() {
38 PointToPointIntent intent = createOne();
Thomas Vachuskac96058a2014-10-20 23:00:16 -070039 assertEquals("incorrect id", APPID, intent.appId());
tom85258ee2014-10-07 00:10:02 -070040 assertEquals("incorrect match", MATCH, intent.selector());
41 assertEquals("incorrect ingress", P1, intent.ingressPoint());
42 assertEquals("incorrect egress", P2, intent.egressPoint());
Brian O'Connorf3d06162014-10-02 15:54:12 -070043 }
44
Pier Ventreffe88d62016-10-13 14:34:40 -070045 @Test
46 public void filtered() {
47 PointToPointIntent intent = createOneFiltered();
48 assertEquals("incorrect id", APPID, intent.appId());
49 assertEquals("incorrect match", MATCH, intent.selector());
50 assertEquals("incorrect ingress", FP1, intent.filteredIngressPoint());
51 assertEquals("incorrect egress", FP2, intent.filteredEgressPoint());
52 }
53
Brian O'Connorf3d06162014-10-02 15:54:12 -070054 @Override
55 protected PointToPointIntent createOne() {
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070056 return PointToPointIntent.builder()
57 .appId(APPID)
58 .selector(MATCH)
59 .treatment(NOP)
60 .ingressPoint(P1)
61 .egressPoint(P2)
62 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -070063 }
64
65 @Override
66 protected PointToPointIntent createAnother() {
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070067 return PointToPointIntent.builder()
68 .appId(APPID)
69 .selector(MATCH)
70 .treatment(NOP)
71 .ingressPoint(P2)
72 .egressPoint(P1)
73 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -070074 }
Pier Ventreffe88d62016-10-13 14:34:40 -070075
76 protected PointToPointIntent createOneFiltered() {
77 return PointToPointIntent.builder()
78 .appId(APPID)
79 .selector(MATCH)
80 .treatment(NOP)
81 .filteredIngressPoint(FP1)
82 .filteredEgressPoint(FP2)
83 .build();
84 }
Brian O'Connorf3d06162014-10-02 15:54:12 -070085}