0f3f05269264932590ee0923f3cc20c1213d913b
[groupbasedpolicy.git] / renderers / faas / src / test / java / org / opendaylight / groupbasedpolicy / renderer / faas / FaasRendererCovrgTest.java
1 /*
2  * Copyright (c) 2016 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.groupbasedpolicy.renderer.faas;
9
10 import static org.mockito.Matchers.any;
11 import static org.mockito.Mockito.doNothing;
12 import static org.mockito.Mockito.mock;
13 import static org.mockito.Mockito.when;
14
15 import com.google.common.util.concurrent.CheckedFuture;
16 import org.junit.Test;
17 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
18 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
19 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
20 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
21 import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
22 import org.opendaylight.yangtools.yang.binding.DataObject;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24
25 public class FaasRendererCovrgTest {
26
27     @SuppressWarnings("unchecked")
28     @Test
29     public void testConstructor() throws Exception {
30         DataBroker dataProvider = mock(DataBroker.class);
31         EpRendererAugmentationRegistry epRendererAugmentationRegistry = mock(EpRendererAugmentationRegistry.class);
32
33         WriteTransaction wTx = mock(WriteTransaction.class);
34         CheckedFuture<Void, TransactionCommitFailedException> futureVoid = mock(CheckedFuture.class);
35         when(wTx.submit()).thenReturn(futureVoid);
36         doNothing().when(wTx).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class),
37                 any(DataObject.class));
38         when(dataProvider.newWriteOnlyTransaction()).thenReturn(wTx);
39
40         FaasRenderer renderer = new FaasRenderer(dataProvider, epRendererAugmentationRegistry);
41         renderer.close();
42     }
43 }