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; |
Ray Milkey | a2cf3a1 | 2018-02-15 16:13:56 -0800 | [diff] [blame] | 19 | import org.onosproject.net.FilteredConnectPoint; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 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.assertThatClassIsImmutableBaseClass; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Suite of tests of the point-to-point intent descriptor. |
| 26 | */ |
| 27 | public class PointToPointIntentTest extends ConnectivityIntentTest { |
| 28 | |
Ray Milkey | 37f6a38 | 2014-11-25 14:54:42 -0800 | [diff] [blame] | 29 | /** |
helenyrwu | 2a67490 | 2016-07-20 09:48:04 -0700 | [diff] [blame] | 30 | * Checks that the PointToPointIntent class is immutable. |
Ray Milkey | 37f6a38 | 2014-11-25 14:54:42 -0800 | [diff] [blame] | 31 | */ |
| 32 | @Test |
| 33 | public void checkImmutability() { |
| 34 | assertThatClassIsImmutableBaseClass(PointToPointIntent.class); |
| 35 | } |
| 36 | |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 37 | @Test |
| 38 | public void basics() { |
| 39 | PointToPointIntent intent = createOne(); |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 40 | assertEquals("incorrect id", APPID, intent.appId()); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 41 | assertEquals("incorrect match", MATCH, intent.selector()); |
Ray Milkey | a2cf3a1 | 2018-02-15 16:13:56 -0800 | [diff] [blame] | 42 | assertEquals("incorrect ingress", P1, intent.filteredIngressPoint().connectPoint()); |
| 43 | assertEquals("incorrect egress", P2, intent.filteredEgressPoint().connectPoint()); |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 44 | |
| 45 | intent = createWithResourceGroup(); |
| 46 | assertEquals("incorrect id", APPID, intent.appId()); |
| 47 | assertEquals("incorrect match", MATCH, intent.selector()); |
Ray Milkey | a2cf3a1 | 2018-02-15 16:13:56 -0800 | [diff] [blame] | 48 | assertEquals("incorrect ingress", P1, intent.filteredIngressPoint().connectPoint()); |
| 49 | assertEquals("incorrect egress", P2, intent.filteredEgressPoint().connectPoint()); |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 50 | assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup()); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Pier Ventre | ffe88d6 | 2016-10-13 14:34:40 -0700 | [diff] [blame] | 53 | @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'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 62 | @Override |
| 63 | protected PointToPointIntent createOne() { |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 64 | return PointToPointIntent.builder() |
| 65 | .appId(APPID) |
| 66 | .selector(MATCH) |
| 67 | .treatment(NOP) |
Ray Milkey | a2cf3a1 | 2018-02-15 16:13:56 -0800 | [diff] [blame] | 68 | .filteredIngressPoint(new FilteredConnectPoint(P1)) |
| 69 | .filteredEgressPoint(new FilteredConnectPoint(P2)) |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 70 | .build(); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 73 | protected PointToPointIntent createWithResourceGroup() { |
| 74 | return PointToPointIntent.builder() |
| 75 | .appId(APPID) |
| 76 | .selector(MATCH) |
| 77 | .treatment(NOP) |
Ray Milkey | a2cf3a1 | 2018-02-15 16:13:56 -0800 | [diff] [blame] | 78 | .filteredIngressPoint(new FilteredConnectPoint(P1)) |
| 79 | .filteredEgressPoint(new FilteredConnectPoint(P2)) |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 80 | .resourceGroup(RESOURCE_GROUP) |
| 81 | .build(); |
| 82 | } |
| 83 | |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 84 | @Override |
| 85 | protected PointToPointIntent createAnother() { |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 86 | return PointToPointIntent.builder() |
| 87 | .appId(APPID) |
| 88 | .selector(MATCH) |
| 89 | .treatment(NOP) |
Ray Milkey | a2cf3a1 | 2018-02-15 16:13:56 -0800 | [diff] [blame] | 90 | .filteredIngressPoint(new FilteredConnectPoint(P2)) |
| 91 | .filteredEgressPoint(new FilteredConnectPoint(P1)) |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 92 | .build(); |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 93 | } |
Pier Ventre | ffe88d6 | 2016-10-13 14:34:40 -0700 | [diff] [blame] | 94 | |
| 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'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 104 | } |