Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 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 Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 16 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 17 | package org.onosproject.net.intent; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 18 | |
| 19 | import org.junit.Test; |
| 20 | |
| 21 | import static org.junit.Assert.assertEquals; |
Ray Milkey | 37f6a38 | 2014-11-25 14:54:42 -0800 | [diff] [blame] | 22 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Suite of tests of the multi-to-single point intent descriptor. |
| 26 | */ |
| 27 | public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest { |
| 28 | |
Ray Milkey | 37f6a38 | 2014-11-25 14:54:42 -0800 | [diff] [blame] | 29 | /** |
| 30 | * Checks that the MultiPointToSinglePointIntent class is immutable. |
| 31 | */ |
| 32 | @Test |
| 33 | public void checkImmutability() { |
| 34 | assertThatClassIsImmutable(MultiPointToSinglePointIntent.class); |
| 35 | } |
| 36 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Create three intents with normal connect points. |
| 39 | */ |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 40 | @Test |
| 41 | public void basics() { |
| 42 | MultiPointToSinglePointIntent intent = createOne(); |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 43 | assertEquals("incorrect id", APPID, intent.appId()); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 44 | assertEquals("incorrect match", MATCH, intent.selector()); |
| 45 | assertEquals("incorrect ingress", PS1, intent.ingressPoints()); |
| 46 | assertEquals("incorrect egress", P2, intent.egressPoint()); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 47 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 48 | intent = createAnother(); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 49 | assertEquals("incorrect id", APPID, intent.appId()); |
| 50 | assertEquals("incorrect match", MATCH, intent.selector()); |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 51 | assertEquals("incorrect ingress", PS2, intent.ingressPoints()); |
| 52 | assertEquals("incorrect egress", P1, intent.egressPoint()); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 53 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 54 | intent = createVlanMatch(); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 55 | 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 Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 59 | |
| 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 Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 69 | /** |
| 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 Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 87 | |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 88 | @Override |
| 89 | protected MultiPointToSinglePointIntent createOne() { |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 90 | return MultiPointToSinglePointIntent.builder() |
| 91 | .appId(APPID) |
| 92 | .selector(MATCH) |
| 93 | .treatment(NOP) |
Ray Milkey | 27cff8c | 2018-03-05 14:58:26 -0800 | [diff] [blame] | 94 | .filteredIngressPoints(FPS1) |
| 95 | .filteredEgressPoint(FP2) |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 96 | .build(); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | @Override |
| 100 | protected MultiPointToSinglePointIntent createAnother() { |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 101 | return MultiPointToSinglePointIntent.builder() |
| 102 | .appId(APPID) |
| 103 | .selector(MATCH) |
| 104 | .treatment(NOP) |
Ray Milkey | 27cff8c | 2018-03-05 14:58:26 -0800 | [diff] [blame] | 105 | .filteredIngressPoints(FPS2) |
| 106 | .filteredEgressPoint(FP1) |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 107 | .build(); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 108 | } |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 109 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 110 | protected MultiPointToSinglePointIntent createVlanMatch() { |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 111 | return MultiPointToSinglePointIntent.builder() |
| 112 | .appId(APPID) |
| 113 | .selector(VLANMATCH1) |
| 114 | .treatment(NOP) |
Ray Milkey | 27cff8c | 2018-03-05 14:58:26 -0800 | [diff] [blame] | 115 | .filteredIngressPoints(FPS1) |
| 116 | .filteredEgressPoint(FP2) |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 117 | .build(); |
| 118 | } |
| 119 | |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 120 | protected MultiPointToSinglePointIntent createWithResourceGroup() { |
| 121 | return MultiPointToSinglePointIntent.builder() |
| 122 | .appId(APPID) |
| 123 | .selector(MATCH) |
| 124 | .treatment(NOP) |
Ray Milkey | 27cff8c | 2018-03-05 14:58:26 -0800 | [diff] [blame] | 125 | .filteredIngressPoints(FPS1) |
| 126 | .filteredEgressPoint(FP2) |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 127 | .resourceGroup(RESOURCE_GROUP) |
| 128 | .build(); |
| 129 | } |
| 130 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 131 | |
| 132 | protected MultiPointToSinglePointIntent createFilteredOne() { |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 133 | return MultiPointToSinglePointIntent.builder() |
| 134 | .appId(APPID) |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 135 | .treatment(NOP) |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 136 | .filteredIngressPoints(FPS1) |
| 137 | .filteredEgressPoint(FP2) |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 138 | .build(); |
| 139 | } |
| 140 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 141 | 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 Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 151 | return MultiPointToSinglePointIntent.builder() |
| 152 | .appId(APPID) |
| 153 | .selector(VLANMATCH1) |
| 154 | .treatment(NOP) |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 155 | .filteredIngressPoints(FPS1) |
| 156 | .filteredEgressPoint(FP2) |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 157 | .build(); |
| 158 | } |
| 159 | |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 160 | } |