blob: d4e3750fc2142534aa1c14bf9e5e5824451299c6 [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 */
Pier Ventre647138f2016-08-26 17:32:44 -070016
Brian O'Connorabafb502014-12-02 22:26:20 -080017package org.onosproject.net.intent;
Brian O'Connorf3d06162014-10-02 15:54:12 -070018
19import org.junit.Test;
20
21import static org.junit.Assert.assertEquals;
Ray Milkey37f6a382014-11-25 14:54:42 -080022import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
Brian O'Connorf3d06162014-10-02 15:54:12 -070023
24/**
25 * Suite of tests of the multi-to-single point intent descriptor.
26 */
27public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest {
28
Ray Milkey37f6a382014-11-25 14:54:42 -080029 /**
30 * Checks that the MultiPointToSinglePointIntent class is immutable.
31 */
32 @Test
33 public void checkImmutability() {
34 assertThatClassIsImmutable(MultiPointToSinglePointIntent.class);
35 }
36
Yi Tseng2a81c9d2016-09-14 10:14:24 -070037 /**
38 * Create three intents with normal connect points.
39 */
Brian O'Connorf3d06162014-10-02 15:54:12 -070040 @Test
41 public void basics() {
42 MultiPointToSinglePointIntent intent = createOne();
Thomas Vachuskac96058a2014-10-20 23:00:16 -070043 assertEquals("incorrect id", APPID, intent.appId());
tom85258ee2014-10-07 00:10:02 -070044 assertEquals("incorrect match", MATCH, intent.selector());
45 assertEquals("incorrect ingress", PS1, intent.ingressPoints());
46 assertEquals("incorrect egress", P2, intent.egressPoint());
Brian O'Connorf3d06162014-10-02 15:54:12 -070047
Yi Tseng2a81c9d2016-09-14 10:14:24 -070048 intent = createAnother();
Pier Ventre647138f2016-08-26 17:32:44 -070049 assertEquals("incorrect id", APPID, intent.appId());
50 assertEquals("incorrect match", MATCH, intent.selector());
Yi Tseng2a81c9d2016-09-14 10:14:24 -070051 assertEquals("incorrect ingress", PS2, intent.ingressPoints());
52 assertEquals("incorrect egress", P1, intent.egressPoint());
Pier Ventre647138f2016-08-26 17:32:44 -070053
Yi Tseng2a81c9d2016-09-14 10:14:24 -070054 intent = createVlanMatch();
Pier Ventre647138f2016-08-26 17:32:44 -070055 assertEquals("incorrect id", APPID, intent.appId());
56 assertEquals("incorrect match", VLANMATCH1, intent.selector());
57 assertEquals("incorrect ingress", PS1, intent.ingressPoints());
58 assertEquals("incorrect egress", P2, intent.egressPoint());
Luca Prete670ac5d2017-02-03 15:55:43 -080059
60 intent = createWithResourceGroup();
61 assertEquals("incorrect id", APPID, intent.appId());
62 assertEquals("incorrect match", MATCH, intent.selector());
63 assertEquals("incorrect ingress", PS1, intent.ingressPoints());
64 assertEquals("incorrect egress", P2, intent.egressPoint());
65 assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup());
66
Pier Ventre647138f2016-08-26 17:32:44 -070067 }
68
Yi Tseng2a81c9d2016-09-14 10:14:24 -070069 /**
70 * Create two intents with filtered connect points.
71 */
72 @Test
73 public void filteredIntent() {
74 MultiPointToSinglePointIntent intent = createFilteredOne();
75 assertEquals("incorrect id", APPID, intent.appId());
76 assertEquals("incorrect match", MATCH, intent.selector());
77 assertEquals("incorrect filtered ingress", FPS1, intent.filteredIngressPoints());
78 assertEquals("incorrect filtered egress", FP2, intent.filteredEgressPoint());
79
80 intent = createAnotherFiltered();
81 assertEquals("incorrect id", APPID, intent.appId());
82 assertEquals("incorrect match", MATCH, intent.selector());
83 assertEquals("incorrect filtered ingress", FPS2, intent.filteredIngressPoints());
84 assertEquals("incorrect filtered egress", FP1, intent.filteredEgressPoint());
85
86 }
Pier Ventre647138f2016-08-26 17:32:44 -070087
Brian O'Connorf3d06162014-10-02 15:54:12 -070088 @Override
89 protected MultiPointToSinglePointIntent createOne() {
Ray Milkeyebc5d222015-03-18 15:45:36 -070090 return MultiPointToSinglePointIntent.builder()
91 .appId(APPID)
92 .selector(MATCH)
93 .treatment(NOP)
Ray Milkey27cff8c2018-03-05 14:58:26 -080094 .filteredIngressPoints(FPS1)
95 .filteredEgressPoint(FP2)
Ray Milkeyebc5d222015-03-18 15:45:36 -070096 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -070097 }
98
99 @Override
100 protected MultiPointToSinglePointIntent createAnother() {
Ray Milkeyebc5d222015-03-18 15:45:36 -0700101 return MultiPointToSinglePointIntent.builder()
102 .appId(APPID)
103 .selector(MATCH)
104 .treatment(NOP)
Ray Milkey27cff8c2018-03-05 14:58:26 -0800105 .filteredIngressPoints(FPS2)
106 .filteredEgressPoint(FP1)
Ray Milkeyebc5d222015-03-18 15:45:36 -0700107 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -0700108 }
Pier Ventre647138f2016-08-26 17:32:44 -0700109
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700110 protected MultiPointToSinglePointIntent createVlanMatch() {
Pier Ventre647138f2016-08-26 17:32:44 -0700111 return MultiPointToSinglePointIntent.builder()
112 .appId(APPID)
113 .selector(VLANMATCH1)
114 .treatment(NOP)
Ray Milkey27cff8c2018-03-05 14:58:26 -0800115 .filteredIngressPoints(FPS1)
116 .filteredEgressPoint(FP2)
Pier Ventre647138f2016-08-26 17:32:44 -0700117 .build();
118 }
119
Luca Prete670ac5d2017-02-03 15:55:43 -0800120 protected MultiPointToSinglePointIntent createWithResourceGroup() {
121 return MultiPointToSinglePointIntent.builder()
122 .appId(APPID)
123 .selector(MATCH)
124 .treatment(NOP)
Ray Milkey27cff8c2018-03-05 14:58:26 -0800125 .filteredIngressPoints(FPS1)
126 .filteredEgressPoint(FP2)
Luca Prete670ac5d2017-02-03 15:55:43 -0800127 .resourceGroup(RESOURCE_GROUP)
128 .build();
129 }
130
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700131
132 protected MultiPointToSinglePointIntent createFilteredOne() {
Pier Ventre647138f2016-08-26 17:32:44 -0700133 return MultiPointToSinglePointIntent.builder()
134 .appId(APPID)
Pier Ventre647138f2016-08-26 17:32:44 -0700135 .treatment(NOP)
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700136 .filteredIngressPoints(FPS1)
137 .filteredEgressPoint(FP2)
Pier Ventre647138f2016-08-26 17:32:44 -0700138 .build();
139 }
140
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700141 protected MultiPointToSinglePointIntent createAnotherFiltered() {
142 return MultiPointToSinglePointIntent.builder()
143 .appId(APPID)
144 .treatment(NOP)
145 .filteredIngressPoints(FPS2)
146 .filteredEgressPoint(FP1)
147 .build();
148 }
149
150 protected MultiPointToSinglePointIntent createWrongIntent() {
Pier Ventre647138f2016-08-26 17:32:44 -0700151 return MultiPointToSinglePointIntent.builder()
152 .appId(APPID)
153 .selector(VLANMATCH1)
154 .treatment(NOP)
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700155 .filteredIngressPoints(FPS1)
156 .filteredEgressPoint(FP2)
Pier Ventre647138f2016-08-26 17:32:44 -0700157 .build();
158 }
159
Brian O'Connorf3d06162014-10-02 15:54:12 -0700160}