Add new revision for pcep types model
[bgpcep.git] / pcep / ietf-stateful07 / src / test / java / org / opendaylight / protocol / pcep / ietf / PCEPStatefulCapabilityTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep.ietf;
9
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev181109.Stateful1;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev181109.Stateful1Builder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.Tlvs1;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.Tlvs1Builder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.stateful.capability.tlv.StatefulBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.Tlvs;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
20
21 public class PCEPStatefulCapabilityTest {
22
23     private static final Tlvs EXPECTED_TLVS =
24         new TlvsBuilder().addAugmentation(
25             Tlvs1.class, new Tlvs1Builder()
26                 .setStateful( new StatefulBuilder().setLspUpdateCapability(true)
27                     .addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(true).build())
28                     .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Stateful1Builder()
29                         .setTriggeredInitialSync(true)
30                         .setTriggeredResync(false)
31                         .setDeltaLspSyncCapability(true)
32                         .setIncludeDbVersion(true)
33                         .build())
34                     .build())
35                 .build())
36             .build();
37
38     @Test
39     public void testPCEPStatefulCapability() {
40         final PCEPStatefulCapability sspf = new PCEPStatefulCapability(true, true, true, true, false, true, false);
41         Assert.assertTrue(sspf.isActive());
42         Assert.assertTrue(sspf.isInstant());
43         Assert.assertTrue(sspf.isStateful());
44         Assert.assertFalse(sspf.isTriggeredResync());
45         Assert.assertTrue(sspf.isTriggeredSync());
46         Assert.assertTrue(sspf.isDeltaLspSync());
47         Assert.assertTrue(sspf.isIncludeDbVersion());
48         final TlvsBuilder builder = new TlvsBuilder();
49         sspf.setCapabilityProposal(null, builder);
50         Assert.assertEquals(EXPECTED_TLVS, builder.build());
51     }
52 }