Test coverage: openconfig-impl 47/29547/8
authorIveta Halanova <ihalanov@cisco.com>
Thu, 19 Nov 2015 08:03:22 +0000 (09:03 +0100)
committerIveta Halanova <ihalanov@cisco.com>
Fri, 20 Nov 2015 07:48:47 +0000 (08:48 +0100)
Change-Id: Ie1de0875a1f4fbe1aab3c602a5a75b78b3654d08
Signed-off-by: Iveta Halanova <ihalanov@cisco.com>
bgp/openconfig-impl/pom.xml
bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/BGPConfigHolderImplTest.java [new file with mode: 0644]
bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/BGPConfigStateStoreImplTest.java [new file with mode: 0644]
bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/openconfig/BGPConfigModuleMapperProviderTest.java [new file with mode: 0644]
bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/openconfig/BGPGlobalProviderImplTest.java
bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/openconfig/BGPNeighborProviderImplTest.java

index 353ec4ea56a1f9218bf1aab46c05382e57750259..e07a7b8300927ad3ac57064c29694fc0074fcbd8 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>mockito-configuration</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-manager</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-manager</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-dom-broker-config</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
diff --git a/bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/BGPConfigHolderImplTest.java b/bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/BGPConfigHolderImplTest.java
new file mode 100644 (file)
index 0000000..a858459
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.openconfig.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.openconfig.impl.util.GlobalIdentifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.bgp.openconfig.rev150718.OpenconfigBgp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.modules.ModuleKey;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public class BGPConfigHolderImplTest {
+    private static final BGPConfigHolderImpl<DataObject> HOLDER = new BGPConfigHolderImpl<DataObject>();
+
+    @Test
+    public void test() {
+        assertNull(HOLDER.getModuleKey(GlobalIdentifier.GLOBAL_IDENTIFIER));
+
+        final ModuleKey moduleKey = new ModuleKey("key1", OpenconfigBgp.class);
+        final ModuleKey moduleKey2 = new ModuleKey("key2", OpenconfigBgp.class);
+        assertNull(HOLDER.getKey(moduleKey));
+
+        final MyDataObject obj1 = new MyDataObject();
+        final MyDataObject obj2 = new MyDataObject();
+        assertTrue(HOLDER.addOrUpdate(moduleKey, GlobalIdentifier.GLOBAL_IDENTIFIER, obj1));
+        assertFalse(HOLDER.addOrUpdate(moduleKey, GlobalIdentifier.GLOBAL_IDENTIFIER, obj1));
+        assertEquals(moduleKey, HOLDER.getModuleKey(GlobalIdentifier.GLOBAL_IDENTIFIER));
+        assertEquals(GlobalIdentifier.GLOBAL_IDENTIFIER, HOLDER.getKey(moduleKey));
+        assertTrue(HOLDER.addOrUpdate(moduleKey, GlobalIdentifier.GLOBAL_IDENTIFIER, obj2));
+        assertFalse(HOLDER.addOrUpdate(moduleKey, GlobalIdentifier.GLOBAL_IDENTIFIER, obj2));
+        assertTrue(HOLDER.remove(moduleKey));
+        assertFalse(HOLDER.remove(moduleKey2));
+        assertTrue(HOLDER.addOrUpdate(moduleKey, GlobalIdentifier.GLOBAL_IDENTIFIER, obj2));
+    }
+
+    private class MyDataObject implements DataObject {
+        @Override
+        public Class<? extends DataContainer> getImplementedInterface() {
+            return null;
+        }
+    }
+}
diff --git a/bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/BGPConfigStateStoreImplTest.java b/bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/BGPConfigStateStoreImplTest.java
new file mode 100644 (file)
index 0000000..f98ef4c
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.openconfig.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public class BGPConfigStateStoreImplTest {
+
+    private static final BGPConfigStateStoreImpl STORE = new BGPConfigStateStoreImpl();
+    private static final BGPConfigHolderImpl<MyDataObject> HOLDER = new BGPConfigHolderImpl<MyDataObject>();
+
+    @Test
+    public void test() {
+        assertNull(STORE.getBGPConfigHolder(MyDataObject.class));
+        STORE.registerBGPConfigHolder(MyDataObject.class, HOLDER);
+        assertEquals(HOLDER, STORE.getBGPConfigHolder(MyDataObject.class));
+    }
+
+    private class MyDataObject implements DataObject {
+        @Override
+        public Class<? extends DataContainer> getImplementedInterface() {
+            return null;
+        }
+    }
+
+}
diff --git a/bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/openconfig/BGPConfigModuleMapperProviderTest.java b/bgp/openconfig-impl/src/test/java/org/opendaylight/protocol/bgp/openconfig/impl/openconfig/BGPConfigModuleMapperProviderTest.java
new file mode 100644 (file)
index 0000000..a8c5d57
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.openconfig.impl.openconfig;
+
+import static org.junit.Assert.assertTrue;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.protocol.bgp.openconfig.impl.spi.BGPConfigHolder;
+import org.opendaylight.protocol.bgp.openconfig.impl.spi.BGPConfigStateStore;
+import org.opendaylight.protocol.bgp.openconfig.spi.pojo.BGPAppPeerInstanceConfiguration;
+import org.opendaylight.protocol.bgp.openconfig.spi.pojo.BGPPeerInstanceConfiguration;
+import org.opendaylight.protocol.bgp.openconfig.spi.pojo.BGPRibInstanceConfiguration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class BGPConfigModuleMapperProviderTest {
+
+    private BGPConfigModuleMapperProvider mapperProvider;
+
+    private final BindingTransactionChain txChain = Mockito.mock(BindingTransactionChain.class);
+    private final AsyncTransaction<?, ?> asyncTx = Mockito.mock(AsyncTransaction.class);
+    private final WriteTransaction myTx = Mockito.mock(WriteTransaction.class);
+
+    @SuppressWarnings("unchecked")
+    @Before
+    public void setUp() throws Exception {
+
+        final BindingDOMDataBrokerAdapter dataBroker = Mockito.mock(BindingDOMDataBrokerAdapter.class);
+        final BGPConfigStateStore stateHolders = Mockito.mock(BGPConfigStateStore.class);
+        final CheckedFuture<?, ?> checkedFuture = Mockito.mock(CheckedFuture.class);
+        final BGPConfigHolder<?> confHolder = Mockito.mock(BGPConfigHolder.class);
+
+        Mockito.doReturn(this.txChain).when(dataBroker).createTransactionChain(Mockito.any(TransactionChainListener.class));
+        Mockito.doReturn(this.myTx).when(this.txChain).newWriteOnlyTransaction();
+        Mockito.doNothing().when(this.txChain).close();
+        Mockito.doNothing().when(this.myTx).put(Mockito.any(LogicalDatastoreType.class), Mockito.any(InstanceIdentifier.class), Mockito.any(DataObject.class));
+        Mockito.doNothing().when(this.myTx).delete(Mockito.any(LogicalDatastoreType.class), Mockito.any(InstanceIdentifier.class));
+        Mockito.doReturn(checkedFuture).when(this.myTx).submit();
+        Mockito.doReturn(null).when(checkedFuture).checkedGet();
+        Mockito.doReturn(confHolder).when(stateHolders).getBGPConfigHolder(Mockito.any(Class.class));
+
+        this.mapperProvider = new BGPConfigModuleMapperProvider(dataBroker, stateHolders);
+    }
+
+    @Test
+    public void testGetOpenConfigMapper() {
+        assertTrue(this.mapperProvider.getOpenConfigMapper(BGPRibInstanceConfiguration.class) instanceof BGPGlobalProviderImpl);
+        assertTrue(this.mapperProvider.getOpenConfigMapper(BGPPeerInstanceConfiguration.class) instanceof BGPNeighborProviderImpl);
+        assertTrue(this.mapperProvider.getOpenConfigMapper(BGPAppPeerInstanceConfiguration.class) instanceof BGPAppNeighborProviderImpl);
+    }
+
+    @Test
+    public void testOnTransactionChainFailed() {
+        this.mapperProvider.onTransactionChainFailed(this.txChain, this.asyncTx, new Throwable());
+        Mockito.verify(this.txChain).close();
+    }
+
+    @Test
+    public void testClose() throws Exception {
+        this.mapperProvider.close();
+        Mockito.verify(this.myTx).delete(Mockito.any(LogicalDatastoreType.class), Mockito.any(InstanceIdentifier.class));
+        Mockito.verify(this.myTx, Mockito.times(2)).submit();
+        Mockito.verify(this.txChain).close();
+    }
+
+}
index c8ba0ef551784a438f0cbff942a3982f4b9b90ab..201757149ac4f15074a848088f963a23c3e967d5 100644 (file)
@@ -49,17 +49,17 @@ public class BGPGlobalProviderImplTest {
         final BGPConfigStateStore stateHolders = Mockito.mock(BGPConfigStateStore.class);
         final BGPConfigHolder<Global> configHolder = Mockito.mock(BGPConfigHolder.class);
         Mockito.doReturn(configHolder).when(stateHolders).getBGPConfigHolder(Mockito.any(Class.class));
-        globalProvider = new BGPGlobalProviderImpl(txChain, stateHolders);
+        this.globalProvider = new BGPGlobalProviderImpl(txChain, stateHolders);
     }
 
     @Test
     public void testCreateModuleKey() {
-        assertEquals(new ModuleKey("instanceName", RibImpl.class), globalProvider.createModuleKey("instanceName"));
+        assertEquals(new ModuleKey("instanceName", RibImpl.class), this.globalProvider.createModuleKey("instanceName"));
     }
 
     @Test
     public void testApply() {
-        final Global global = globalProvider.apply(new BGPRibInstanceConfiguration(new InstanceConfigurationIdentifier("instanceName"), new AsNumber(1L),
+        final Global global = this.globalProvider.apply(new BGPRibInstanceConfiguration(new InstanceConfigurationIdentifier("instanceName"), new AsNumber(1L),
                 new Ipv4Address("1.2.3.4"), null,
                 Lists.<BgpTableType>newArrayList(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class))));
         final Global expectedGlobal = new GlobalBuilder()
@@ -77,12 +77,14 @@ public class BGPGlobalProviderImplTest {
 
     @Test
     public void testKeyForConfigurationGlobal() {
-        assertEquals(GlobalIdentifier.GLOBAL_IDENTIFIER, globalProvider.keyForConfiguration(new GlobalBuilder().build()));
+        final GlobalIdentifier globalId = (GlobalIdentifier) this.globalProvider.keyForConfiguration(new GlobalBuilder().build());
+        assertEquals(GlobalIdentifier.GLOBAL_IDENTIFIER, globalId);
+        assertEquals("GLOBAL", globalId.getName());
     }
 
     @Test
     public void testGetInstanceConfigurationType() {
-        assertEquals(BGPRibInstanceConfiguration.class, globalProvider.getInstanceConfigurationType());
+        assertEquals(BGPRibInstanceConfiguration.class, this.globalProvider.getInstanceConfigurationType());
     }
 
 }
index 3edc5ce3a27d04364afb0dc4069cccb36c38a655..1a4835873b4f8a6a8157fdd2600e778e4e7298e9 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertEquals;
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import java.math.BigDecimal;
+import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -39,8 +40,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.FlowspecSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev150930.Ipv4Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev150930.Ipv6Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.bgp.rib.impl.rev130409.BgpPeer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.modules.ModuleKey;
@@ -49,6 +52,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 public class BGPNeighborProviderImplTest {
 
     private BGPNeighborProviderImpl neighborProvider;
+    private static final String PASSWORD = "Ug1Yp4Ssw0Rd";
+    private static final IpAddress IP = new IpAddress(new Ipv4Address("1.2.3.4"));
+    private static final PortNumber PORT = new PortNumber(123);
+    private static final short TIMER = (short) 10;
+    private static final AsNumber AS = new AsNumber(10L);
 
     @SuppressWarnings("unchecked")
     @Before
@@ -57,35 +65,72 @@ public class BGPNeighborProviderImplTest {
         final BGPConfigStateStore stateHolders = Mockito.mock(BGPConfigStateStore.class);
         final BGPConfigHolder<Neighbor> configHolder = Mockito.mock(BGPConfigHolder.class);
         Mockito.doReturn(configHolder).when(stateHolders).getBGPConfigHolder(Mockito.any(Class.class));
-        neighborProvider = new BGPNeighborProviderImpl(txChain, stateHolders);
+        this.neighborProvider = new BGPNeighborProviderImpl(txChain, stateHolders);
     }
 
     @Test
     public void testCreateModuleKey() {
-        assertEquals(new ModuleKey("instanceName", BgpPeer.class), neighborProvider.createModuleKey("instanceName"));
+        assertEquals(new ModuleKey("instanceName", BgpPeer.class), this.neighborProvider.createModuleKey("instanceName"));
     }
 
     @Test
     public void testGetInstanceConfigurationType() {
-        assertEquals(BGPPeerInstanceConfiguration.class, neighborProvider.getInstanceConfigurationType());
+        assertEquals(BGPPeerInstanceConfiguration.class, this.neighborProvider.getInstanceConfigurationType());
     }
 
     @Test
     public void testApply() {
-        final Neighbor neighbor = neighborProvider.apply(new BGPPeerInstanceConfiguration(new InstanceConfigurationIdentifier("instanceName"),
-                new IpAddress(new Ipv4Address("1.2.3.4")), new PortNumber(123), (short) 10, PeerRole.RrClient, false,
-                Lists.<BgpTableType>newArrayList(new BgpTableTypeImpl(Ipv6AddressFamily.class, FlowspecSubsequentAddressFamily.class)),
-                new AsNumber(10L), Optional.<Rfc2385Key>absent()));
-        final Neighbor expectedNeighbor = new NeighborBuilder()
-            .setAfiSafis(new AfiSafisBuilder().setAfiSafi(Lists.<AfiSafi>newArrayList(new AfiSafiBuilder().setAfiSafiName(Ipv6Flow.class).build())).build())
-            .setNeighborAddress(new IpAddress(new Ipv4Address("1.2.3.4")))
-            .setKey(new NeighborKey(new IpAddress(new Ipv4Address("1.2.3.4"))))
-            .setConfig(new ConfigBuilder().setPeerAs(new AsNumber(10L)).setPeerType(PeerType.INTERNAL).build())
-            .setRouteReflector(new RouteReflectorBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.route.reflector.ConfigBuilder().setRouteReflectorClient(true).build()).build())
-            .setTimers(new TimersBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder().setHoldTime(BigDecimal.valueOf(10)).build()).build())
-            .setTransport(new TransportBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().setPassiveMode(true).build()).build())
-            .build();
+        final boolean active = false;
+        final PeerRole role = PeerRole.RrClient;
+        final Neighbor neighbor = this.neighborProvider.apply(createConfiguration(new InstanceConfigurationIdentifier("instanceName"),
+            IP, PORT, TIMER, role, active,
+            Lists.<BgpTableType>newArrayList(new BgpTableTypeImpl(Ipv6AddressFamily.class, FlowspecSubsequentAddressFamily.class)),
+            AS, Optional.<Rfc2385Key>absent()));
+        final Neighbor expectedNeighbor = createNeighbor(Lists.<AfiSafi>newArrayList(new AfiSafiBuilder().setAfiSafiName(Ipv6Flow.class).build()),
+            IP, null, AS, PeerType.INTERNAL, role, TIMER, !active);
         assertEquals(expectedNeighbor, neighbor);
     }
 
+    @Test
+    public void testApply2() {
+        final boolean active = false;
+        final PeerRole role = PeerRole.Ebgp;
+        final Neighbor neighbor = this.neighborProvider.apply(createConfiguration(new InstanceConfigurationIdentifier("instanceName"),
+            IP, PORT, TIMER, role, active,
+            Lists.<BgpTableType>newArrayList(new BgpTableTypeImpl(Ipv6AddressFamily.class, FlowspecSubsequentAddressFamily.class)),
+            AS, Optional.of(new Rfc2385Key(PASSWORD)) ));
+        final Neighbor expectedNeighbor = createNeighbor(Lists.<AfiSafi>newArrayList(new AfiSafiBuilder().setAfiSafiName(Ipv6Flow.class).build()),
+            IP, PASSWORD, AS, PeerType.EXTERNAL, role, TIMER, !active);
+        assertEquals(expectedNeighbor, neighbor);
+    }
+
+    @Test
+    public void testApply3() {
+        final boolean active = true;
+        final PeerRole role = PeerRole.Internal;
+        final Neighbor neighbor = this.neighborProvider.apply(createConfiguration(new InstanceConfigurationIdentifier("instanceName"),
+            IP, PORT, TIMER, role, active,
+            Lists.<BgpTableType>newArrayList(new BgpTableTypeImpl(Ipv4AddressFamily.class, FlowspecSubsequentAddressFamily.class)),
+            AS, Optional.of(new Rfc2385Key(PASSWORD)) ));
+        final Neighbor expectedNeighbor = createNeighbor(Lists.<AfiSafi>newArrayList(new AfiSafiBuilder().setAfiSafiName(Ipv4Flow.class).build()),
+            IP, PASSWORD, AS, null, role, TIMER, !active);
+        assertEquals(expectedNeighbor, neighbor);
+    }
+
+    private BGPPeerInstanceConfiguration createConfiguration(final InstanceConfigurationIdentifier confId, final IpAddress ip, final PortNumber port,
+        final short holdTimer, final PeerRole role, final boolean active, final List<BgpTableType> advertized, final AsNumber as, final Optional<Rfc2385Key> passwd) {
+        return new BGPPeerInstanceConfiguration(confId, ip, port, holdTimer, role, active, advertized, as, passwd);
+    }
+
+    private Neighbor createNeighbor(final List<AfiSafi> families, final IpAddress ip, final String passwd, final AsNumber as, final PeerType peerType, final PeerRole role, final short timer, final boolean passive) {
+        return new NeighborBuilder()
+        .setAfiSafis(new AfiSafisBuilder().setAfiSafi(families).build())
+        .setNeighborAddress(ip)
+        .setKey(new NeighborKey(ip))
+        .setConfig(new ConfigBuilder().setAuthPassword(passwd).setPeerAs(as).setPeerType(peerType).build())
+        .setRouteReflector(new RouteReflectorBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.route.reflector.ConfigBuilder().setRouteReflectorClient(role == PeerRole.RrClient).build()).build())
+        .setTimers(new TimersBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder().setHoldTime(BigDecimal.valueOf(timer)).build()).build())
+        .setTransport(new TransportBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().setPassiveMode(passive).build()).build())
+        .build();
+    }
 }