blob: a41214bba4d72a99634956eb5f1a674d5887e5ea [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 */
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());
Pier Ventre647138f2016-08-26 17:32:44 -070059 }
60
Yi Tseng2a81c9d2016-09-14 10:14:24 -070061 /**
62 * Create two intents with filtered connect points.
63 */
64 @Test
65 public void filteredIntent() {
66 MultiPointToSinglePointIntent intent = createFilteredOne();
67 assertEquals("incorrect id", APPID, intent.appId());
68 assertEquals("incorrect match", MATCH, intent.selector());
69 assertEquals("incorrect filtered ingress", FPS1, intent.filteredIngressPoints());
70 assertEquals("incorrect filtered egress", FP2, intent.filteredEgressPoint());
71
72 intent = createAnotherFiltered();
73 assertEquals("incorrect id", APPID, intent.appId());
74 assertEquals("incorrect match", MATCH, intent.selector());
75 assertEquals("incorrect filtered ingress", FPS2, intent.filteredIngressPoints());
76 assertEquals("incorrect filtered egress", FP1, intent.filteredEgressPoint());
77
78 }
Pier Ventre647138f2016-08-26 17:32:44 -070079
Brian O'Connorf3d06162014-10-02 15:54:12 -070080 @Override
81 protected MultiPointToSinglePointIntent createOne() {
Ray Milkeyebc5d222015-03-18 15:45:36 -070082 return MultiPointToSinglePointIntent.builder()
83 .appId(APPID)
84 .selector(MATCH)
85 .treatment(NOP)
86 .ingressPoints(PS1)
87 .egressPoint(P2)
88 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -070089 }
90
91 @Override
92 protected MultiPointToSinglePointIntent createAnother() {
Ray Milkeyebc5d222015-03-18 15:45:36 -070093 return MultiPointToSinglePointIntent.builder()
94 .appId(APPID)
95 .selector(MATCH)
96 .treatment(NOP)
97 .ingressPoints(PS2)
98 .egressPoint(P1)
99 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -0700100 }
Pier Ventre647138f2016-08-26 17:32:44 -0700101
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700102 protected MultiPointToSinglePointIntent createVlanMatch() {
Pier Ventre647138f2016-08-26 17:32:44 -0700103 return MultiPointToSinglePointIntent.builder()
104 .appId(APPID)
105 .selector(VLANMATCH1)
106 .treatment(NOP)
107 .ingressPoints(PS1)
108 .egressPoint(P2)
Pier Ventre647138f2016-08-26 17:32:44 -0700109 .build();
110 }
111
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700112
113 protected MultiPointToSinglePointIntent createFilteredOne() {
Pier Ventre647138f2016-08-26 17:32:44 -0700114 return MultiPointToSinglePointIntent.builder()
115 .appId(APPID)
Pier Ventre647138f2016-08-26 17:32:44 -0700116 .treatment(NOP)
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700117 .filteredIngressPoints(FPS1)
118 .filteredEgressPoint(FP2)
Pier Ventre647138f2016-08-26 17:32:44 -0700119 .build();
120 }
121
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700122 protected MultiPointToSinglePointIntent createAnotherFiltered() {
123 return MultiPointToSinglePointIntent.builder()
124 .appId(APPID)
125 .treatment(NOP)
126 .filteredIngressPoints(FPS2)
127 .filteredEgressPoint(FP1)
128 .build();
129 }
130
131 protected MultiPointToSinglePointIntent createWrongIntent() {
Pier Ventre647138f2016-08-26 17:32:44 -0700132 return MultiPointToSinglePointIntent.builder()
133 .appId(APPID)
134 .selector(VLANMATCH1)
135 .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
Brian O'Connorf3d06162014-10-02 15:54:12 -0700141}