blob: 3b170a02ef9f4419e7b74f35d4d97a0529c1cf36 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
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;
Ray Milkeya2cf3a12018-02-15 16:13:56 -080019import org.onosproject.net.FilteredConnectPoint;
Brian O'Connorf3d06162014-10-02 15:54:12 -070020
21import static org.junit.Assert.assertEquals;
Ray Milkey37f6a382014-11-25 14:54:42 -080022import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
Brian O'Connorf3d06162014-10-02 15:54:12 -070023
24/**
25 * Suite of tests of the point-to-point intent descriptor.
26 */
27public class PointToPointIntentTest extends ConnectivityIntentTest {
28
Ray Milkey37f6a382014-11-25 14:54:42 -080029 /**
helenyrwu2a674902016-07-20 09:48:04 -070030 * Checks that the PointToPointIntent class is immutable.
Ray Milkey37f6a382014-11-25 14:54:42 -080031 */
32 @Test
33 public void checkImmutability() {
34 assertThatClassIsImmutableBaseClass(PointToPointIntent.class);
35 }
36
Brian O'Connorf3d06162014-10-02 15:54:12 -070037 @Test
38 public void basics() {
39 PointToPointIntent intent = createOne();
Thomas Vachuskac96058a2014-10-20 23:00:16 -070040 assertEquals("incorrect id", APPID, intent.appId());
tom85258ee2014-10-07 00:10:02 -070041 assertEquals("incorrect match", MATCH, intent.selector());
Ray Milkeya2cf3a12018-02-15 16:13:56 -080042 assertEquals("incorrect ingress", P1, intent.filteredIngressPoint().connectPoint());
43 assertEquals("incorrect egress", P2, intent.filteredEgressPoint().connectPoint());
Luca Prete670ac5d2017-02-03 15:55:43 -080044
45 intent = createWithResourceGroup();
46 assertEquals("incorrect id", APPID, intent.appId());
47 assertEquals("incorrect match", MATCH, intent.selector());
Ray Milkeya2cf3a12018-02-15 16:13:56 -080048 assertEquals("incorrect ingress", P1, intent.filteredIngressPoint().connectPoint());
49 assertEquals("incorrect egress", P2, intent.filteredEgressPoint().connectPoint());
Luca Prete670ac5d2017-02-03 15:55:43 -080050 assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup());
Brian O'Connorf3d06162014-10-02 15:54:12 -070051 }
52
Pier Ventreffe88d62016-10-13 14:34:40 -070053 @Test
54 public void filtered() {
55 PointToPointIntent intent = createOneFiltered();
56 assertEquals("incorrect id", APPID, intent.appId());
57 assertEquals("incorrect match", MATCH, intent.selector());
58 assertEquals("incorrect ingress", FP1, intent.filteredIngressPoint());
59 assertEquals("incorrect egress", FP2, intent.filteredEgressPoint());
60 }
61
Brian O'Connorf3d06162014-10-02 15:54:12 -070062 @Override
63 protected PointToPointIntent createOne() {
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070064 return PointToPointIntent.builder()
65 .appId(APPID)
66 .selector(MATCH)
67 .treatment(NOP)
Ray Milkeya2cf3a12018-02-15 16:13:56 -080068 .filteredIngressPoint(new FilteredConnectPoint(P1))
69 .filteredEgressPoint(new FilteredConnectPoint(P2))
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070070 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -070071 }
72
Luca Prete670ac5d2017-02-03 15:55:43 -080073 protected PointToPointIntent createWithResourceGroup() {
74 return PointToPointIntent.builder()
75 .appId(APPID)
76 .selector(MATCH)
77 .treatment(NOP)
Ray Milkeya2cf3a12018-02-15 16:13:56 -080078 .filteredIngressPoint(new FilteredConnectPoint(P1))
79 .filteredEgressPoint(new FilteredConnectPoint(P2))
Luca Prete670ac5d2017-02-03 15:55:43 -080080 .resourceGroup(RESOURCE_GROUP)
81 .build();
82 }
83
Brian O'Connorf3d06162014-10-02 15:54:12 -070084 @Override
85 protected PointToPointIntent createAnother() {
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070086 return PointToPointIntent.builder()
87 .appId(APPID)
88 .selector(MATCH)
89 .treatment(NOP)
Ray Milkeya2cf3a12018-02-15 16:13:56 -080090 .filteredIngressPoint(new FilteredConnectPoint(P2))
91 .filteredEgressPoint(new FilteredConnectPoint(P1))
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070092 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -070093 }
Pier Ventreffe88d62016-10-13 14:34:40 -070094
95 protected PointToPointIntent createOneFiltered() {
96 return PointToPointIntent.builder()
97 .appId(APPID)
98 .selector(MATCH)
99 .treatment(NOP)
100 .filteredIngressPoint(FP1)
101 .filteredEgressPoint(FP2)
102 .build();
103 }
Brian O'Connorf3d06162014-10-02 15:54:12 -0700104}