blob: 76aaa851fde0729c3e492335c0a10010263b1e71 [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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
Brian O'Connorf3d06162014-10-02 15:54:12 -070017
18import org.junit.Test;
19
20import static org.junit.Assert.assertEquals;
Ray Milkeybd4f0112015-03-02 17:07:09 -080021import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
Brian O'Connorf3d06162014-10-02 15:54:12 -070022
23/**
24 * Suite of tests of the single-to-multi point intent descriptor.
25 */
26public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest {
27
Ray Milkeybd4f0112015-03-02 17:07:09 -080028 /**
29 * Checks that the SinglePointToMultiPointIntent class is immutable.
30 */
31 @Test
32 public void testImmutability() {
33 assertThatClassIsImmutable(SinglePointToMultiPointIntent.class);
34 }
35
Brian O'Connorf3d06162014-10-02 15:54:12 -070036 @Test
37 public void basics() {
38 SinglePointToMultiPointIntent intent = createOne();
Thomas Vachuskac96058a2014-10-20 23:00:16 -070039 assertEquals("incorrect id", APPID, intent.appId());
tom85258ee2014-10-07 00:10:02 -070040 assertEquals("incorrect match", MATCH, intent.selector());
41 assertEquals("incorrect ingress", P1, intent.ingressPoint());
42 assertEquals("incorrect egress", PS2, intent.egressPoints());
Yi Tseng2a81c9d2016-09-14 10:14:24 -070043
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());
Brian O'Connorf3d06162014-10-02 15:54:12 -070049 }
50
Pier Ventre27d42572016-08-29 17:37:08 -070051 @Test
Yi Tseng2a81c9d2016-09-14 10:14:24 -070052 public void filteredIntent() {
53 SinglePointToMultiPointIntent intent = createFilteredOne();
Pier Ventre27d42572016-08-29 17:37:08 -070054 assertEquals("incorrect id", APPID, intent.appId());
55 assertEquals("incorrect match", MATCH, intent.selector());
Yi Tseng2a81c9d2016-09-14 10:14:24 -070056 assertEquals("incorrect filtered ingress", FP2, intent.filteredIngressPoint());
57 assertEquals("incorrect filtered egress", FPS1, intent.filteredEgressPoints());
Pier Ventre27d42572016-08-29 17:37:08 -070058
Yi Tseng2a81c9d2016-09-14 10:14:24 -070059 intent = createAnotherFiltered();
Pier Ventre27d42572016-08-29 17:37:08 -070060 assertEquals("incorrect id", APPID, intent.appId());
61 assertEquals("incorrect match", MATCH, intent.selector());
Yi Tseng2a81c9d2016-09-14 10:14:24 -070062 assertEquals("incorrect filtered ingress", FP1, intent.filteredIngressPoint());
63 assertEquals("incorrect filtered egress", FPS2, intent.filteredEgressPoints());
Pier Ventre27d42572016-08-29 17:37:08 -070064
Pier Ventre27d42572016-08-29 17:37:08 -070065 }
66
Brian O'Connorf3d06162014-10-02 15:54:12 -070067 @Override
68 protected SinglePointToMultiPointIntent createOne() {
Ray Milkeyebc5d222015-03-18 15:45:36 -070069 return SinglePointToMultiPointIntent.builder()
70 .appId(APPID)
71 .selector(MATCH)
72 .treatment(NOP)
73 .ingressPoint(P1)
74 .egressPoints(PS2)
75 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -070076 }
77
78 @Override
79 protected SinglePointToMultiPointIntent createAnother() {
Ray Milkeyebc5d222015-03-18 15:45:36 -070080 return SinglePointToMultiPointIntent.builder()
81 .appId(APPID)
82 .selector(MATCH)
83 .treatment(NOP)
84 .ingressPoint(P2)
85 .egressPoints(PS1)
86 .build();
Brian O'Connorf3d06162014-10-02 15:54:12 -070087 }
Pier Ventre27d42572016-08-29 17:37:08 -070088
Yi Tseng2a81c9d2016-09-14 10:14:24 -070089 protected SinglePointToMultiPointIntent createFilteredOne() {
Pier Ventre27d42572016-08-29 17:37:08 -070090 return SinglePointToMultiPointIntent.builder()
91 .appId(APPID)
Pier Ventre27d42572016-08-29 17:37:08 -070092 .treatment(NOP)
Yi Tseng2a81c9d2016-09-14 10:14:24 -070093 .filteredEgressPoints(FPS1)
94 .filteredIngressPoint(FP2)
Pier Ventre27d42572016-08-29 17:37:08 -070095 .build();
96 }
97
Yi Tseng2a81c9d2016-09-14 10:14:24 -070098 protected SinglePointToMultiPointIntent createAnotherFiltered() {
Pier Ventre27d42572016-08-29 17:37:08 -070099 return SinglePointToMultiPointIntent.builder()
100 .appId(APPID)
Pier Ventre27d42572016-08-29 17:37:08 -0700101 .treatment(NOP)
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700102 .filteredEgressPoints(FPS2)
103 .filteredIngressPoint(FP1)
Pier Ventre27d42572016-08-29 17:37:08 -0700104 .build();
105 }
106
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700107 protected SinglePointToMultiPointIntent createWrongIntent() {
Pier Ventre27d42572016-08-29 17:37:08 -0700108 return SinglePointToMultiPointIntent.builder()
109 .appId(APPID)
Yi Tseng2a81c9d2016-09-14 10:14:24 -0700110 .treatment(NOP)
111 .selector(VLANMATCH1)
112 .filteredEgressPoints(FPS2)
113 .filteredIngressPoint(FP1)
Pier Ventre27d42572016-08-29 17:37:08 -0700114 .build();
115 }
116
Brian O'Connorf3d06162014-10-02 15:54:12 -0700117}