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