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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.intent; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 17 | |
| 18 | import org.junit.Test; |
| 19 | |
| 20 | import static org.junit.Assert.assertEquals; |
Ray Milkey | bd4f011 | 2015-03-02 17:07:09 -0800 | [diff] [blame] | 21 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Suite of tests of the single-to-multi point intent descriptor. |
| 25 | */ |
| 26 | public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest { |
| 27 | |
Ray Milkey | bd4f011 | 2015-03-02 17:07:09 -0800 | [diff] [blame] | 28 | /** |
| 29 | * Checks that the SinglePointToMultiPointIntent class is immutable. |
| 30 | */ |
| 31 | @Test |
| 32 | public void testImmutability() { |
| 33 | assertThatClassIsImmutable(SinglePointToMultiPointIntent.class); |
| 34 | } |
| 35 | |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 36 | @Test |
| 37 | public void basics() { |
| 38 | SinglePointToMultiPointIntent intent = createOne(); |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 39 | assertEquals("incorrect id", APPID, intent.appId()); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 40 | assertEquals("incorrect match", MATCH, intent.selector()); |
| 41 | assertEquals("incorrect ingress", P1, intent.ingressPoint()); |
| 42 | assertEquals("incorrect egress", PS2, intent.egressPoints()); |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 43 | |
| 44 | intent = createAnother(); |
| 45 | assertEquals("incorrect id", APPID, intent.appId()); |
| 46 | assertEquals("incorrect match", MATCH, intent.selector()); |
| 47 | assertEquals("incorrect ingress", P2, intent.ingressPoint()); |
| 48 | assertEquals("incorrect egress", PS1, intent.egressPoints()); |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 49 | |
| 50 | intent = createWithResourceGroup(); |
| 51 | assertEquals("incorrect id", APPID, intent.appId()); |
| 52 | assertEquals("incorrect match", MATCH, intent.selector()); |
| 53 | assertEquals("incorrect ingress", P2, intent.ingressPoint()); |
| 54 | assertEquals("incorrect egress", PS1, intent.egressPoints()); |
| 55 | assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup()); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 58 | @Test |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 59 | public void filteredIntent() { |
| 60 | SinglePointToMultiPointIntent intent = createFilteredOne(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 61 | assertEquals("incorrect id", APPID, intent.appId()); |
| 62 | assertEquals("incorrect match", MATCH, intent.selector()); |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 63 | assertEquals("incorrect filtered ingress", FP2, intent.filteredIngressPoint()); |
| 64 | assertEquals("incorrect filtered egress", FPS1, intent.filteredEgressPoints()); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 65 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 66 | intent = createAnotherFiltered(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 67 | assertEquals("incorrect id", APPID, intent.appId()); |
| 68 | assertEquals("incorrect match", MATCH, intent.selector()); |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 69 | assertEquals("incorrect filtered ingress", FP1, intent.filteredIngressPoint()); |
| 70 | assertEquals("incorrect filtered egress", FPS2, intent.filteredEgressPoints()); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 73 | @Override |
| 74 | protected SinglePointToMultiPointIntent createOne() { |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 75 | return SinglePointToMultiPointIntent.builder() |
| 76 | .appId(APPID) |
| 77 | .selector(MATCH) |
| 78 | .treatment(NOP) |
| 79 | .ingressPoint(P1) |
| 80 | .egressPoints(PS2) |
| 81 | .build(); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | @Override |
| 85 | protected SinglePointToMultiPointIntent createAnother() { |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 86 | return SinglePointToMultiPointIntent.builder() |
| 87 | .appId(APPID) |
| 88 | .selector(MATCH) |
| 89 | .treatment(NOP) |
| 90 | .ingressPoint(P2) |
| 91 | .egressPoints(PS1) |
| 92 | .build(); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 93 | } |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 94 | |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 95 | protected SinglePointToMultiPointIntent createWithResourceGroup() { |
| 96 | return SinglePointToMultiPointIntent.builder() |
| 97 | .appId(APPID) |
| 98 | .selector(MATCH) |
| 99 | .treatment(NOP) |
| 100 | .ingressPoint(P2) |
| 101 | .egressPoints(PS1) |
| 102 | .resourceGroup(RESOURCE_GROUP) |
| 103 | .build(); |
| 104 | } |
| 105 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 106 | protected SinglePointToMultiPointIntent createFilteredOne() { |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 107 | return SinglePointToMultiPointIntent.builder() |
| 108 | .appId(APPID) |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 109 | .treatment(NOP) |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 110 | .filteredEgressPoints(FPS1) |
| 111 | .filteredIngressPoint(FP2) |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 112 | .build(); |
| 113 | } |
| 114 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 115 | protected SinglePointToMultiPointIntent createAnotherFiltered() { |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 116 | return SinglePointToMultiPointIntent.builder() |
| 117 | .appId(APPID) |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 118 | .treatment(NOP) |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 119 | .filteredEgressPoints(FPS2) |
| 120 | .filteredIngressPoint(FP1) |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 121 | .build(); |
| 122 | } |
| 123 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 124 | protected SinglePointToMultiPointIntent createWrongIntent() { |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 125 | return SinglePointToMultiPointIntent.builder() |
| 126 | .appId(APPID) |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 127 | .treatment(NOP) |
| 128 | .selector(VLANMATCH1) |
| 129 | .filteredEgressPoints(FPS2) |
| 130 | .filteredIngressPoint(FP1) |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 131 | .build(); |
| 132 | } |
| 133 | |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 134 | } |