blob: eeec41e725b1d25d0740c113b976f4954abd2111 [file] [log] [blame]
bobzhou35148972015-10-31 17:39:59 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
bobzhou35148972015-10-31 17:39:59 +08003 *
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 */
Ray Milkey6c1bac32015-11-13 14:40:40 -080016package org.onosproject.vtnrsc;
bobzhou35148972015-10-31 17:39:59 +080017
18import java.util.HashSet;
19import java.util.Set;
20
21import org.junit.Test;
bobzhou35148972015-10-31 17:39:59 +080022
23import com.google.common.testing.EqualsTester;
24
Ray Milkey6c1bac32015-11-13 14:40:40 -080025import static org.hamcrest.MatcherAssert.assertThat;
26import static org.hamcrest.Matchers.is;
27import static org.hamcrest.Matchers.notNullValue;
28import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
29
bobzhou35148972015-10-31 17:39:59 +080030/**
31 * Unit tests for RouterGateway class.
32 */
33public class RouterGatewayTest {
34 final TenantNetworkId networkId1 = TenantNetworkId.networkId("1");
35 final TenantNetworkId networkId2 = TenantNetworkId.networkId("2");
36 final Set<FixedIp> fixedIpSet1 = new HashSet<>();
37 final Set<FixedIp> fixedIpSet2 = new HashSet<>();
38
39 /**
40 * Checks that the RouterGateway class is immutable.
41 */
42 @Test
43 public void testImmutability() {
44 assertThatClassIsImmutable(RouterGateway.class);
45 }
46
47 /**
48 * Checks the operation of equals().
49 */
50 @Test
51 public void testEquals() {
52 RouterGateway routerGateway1 = RouterGateway.routerGateway(networkId1,
53 true,
54 fixedIpSet1);
55 RouterGateway routerGateway2 = RouterGateway.routerGateway(networkId1,
56 true,
57 fixedIpSet1);
58 RouterGateway routerGateway3 = RouterGateway.routerGateway(networkId2,
59 true,
60 fixedIpSet2);
61 new EqualsTester().addEqualityGroup(routerGateway1, routerGateway2)
62 .addEqualityGroup(routerGateway3).testEquals();
63 }
64
65 /**
66 * Checks the construction of a RouterGateway object.
67 */
68 @Test
69 public void testConstruction() {
70 RouterGateway routerGateway = RouterGateway.routerGateway(networkId1,
71 true,
72 fixedIpSet1);
73 assertThat(fixedIpSet1, is(notNullValue()));
74 assertThat(fixedIpSet1, is(routerGateway.externalFixedIps()));
75 assertThat(networkId1, is(notNullValue()));
76 assertThat(networkId1, is(routerGateway.networkId()));
77 assertThat(routerGateway.enableSnat(), is(true));
78 }
79}