blob: 57f4fe8066fcfb5b679a634a9b3c197eff63ea53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fd.hc2vpp.srv6.read.steering;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
import io.fd.hc2vpp.srv6.write.sid.request.LocalSidRequestTest;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.vpp.jvpp.core.dto.SrSteeringPolDetails;
import io.fd.vpp.jvpp.core.dto.SrSteeringPolDetailsReplyDump;
import io.fd.vpp.jvpp.core.types.Srv6Sid;
import java.util.ArrayList;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
public abstract class SteeringTest extends LocalSidRequestTest {
private static final Ipv6Address A = new Ipv6Address("a::");
private static final Ipv4Address B = new Ipv4Address("10.0.0.1");
static final Ipv6Address BSID_ADR = new Ipv6Address("a::e");
@Mock
ReadContext readCtx;
@Mock
ModificationCache modificationCache;
SrSteeringPolDetailsReplyDump replyDump = new SrSteeringPolDetailsReplyDump();
@Override
protected void init() {
when(readCtx.getModificationCache()).thenReturn(modificationCache);
when(modificationCache.get(any())).thenReturn(replyDump);
replyDump.srSteeringPolDetails = new ArrayList<>();
SrSteeringPolDetails polDetailsA = new SrSteeringPolDetails();
polDetailsA.trafficType = 6;
polDetailsA.fibTable = 1;
polDetailsA.prefixAddr = AddressTranslator.INSTANCE.ipAddressToArray(new IpAddress(A));
Srv6Sid bsidA = new Srv6Sid();
bsidA.addr = AddressTranslator.INSTANCE.ipAddressToArray(new IpAddress(BSID_ADR));
polDetailsA.bsid = bsidA;
polDetailsA.maskWidth = 64;
SrSteeringPolDetails polDetailsB = new SrSteeringPolDetails();
polDetailsB.trafficType = 4;
polDetailsB.fibTable = 0;
polDetailsB.prefixAddr = AddressTranslator.INSTANCE.ipAddressToArray(new IpAddress(B));
Srv6Sid bsidB = new Srv6Sid();
bsidB.addr = AddressTranslator.INSTANCE.ipAddressToArray(new IpAddress(BSID_ADR));
polDetailsB.bsid = bsidB;
polDetailsB.maskWidth = 24;
SrSteeringPolDetails polDetailsC = new SrSteeringPolDetails();
polDetailsC.trafficType = 2;
polDetailsC.swIfIndex = 1;
bsidA.addr = AddressTranslator.INSTANCE.ipAddressToArray(new IpAddress(BSID_ADR));
polDetailsA.bsid = bsidA;
replyDump.srSteeringPolDetails.add(polDetailsA);
replyDump.srSteeringPolDetails.add(polDetailsB);
replyDump.srSteeringPolDetails.add(polDetailsC);
}
}
|