2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.dom.store.inmemory;
10 import static org.junit.Assert.assertNotNull;
11 import static org.mockito.Matchers.any;
12 import static org.mockito.Matchers.anyCollectionOf;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.mock;
15 import static org.mockito.Mockito.verify;
16 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.DOM_DATA_TREE_IDENTIFIER;
17 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.resetMocks;
19 import com.google.common.collect.ImmutableSet;
20 import org.junit.Test;
21 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
22 import org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeSnapshot;
24 public class InMemoryDOMDataTreeShardProducerTest {
27 public void basicTest() throws Exception {
28 final InMemoryDOMDataTreeShard inMemoryDOMDataTreeShard = mock(InMemoryDOMDataTreeShard.class);
29 final InmemoryDOMDataTreeShardWriteTransaction inmemoryDOMDataTreeShardWriteTransaction =
30 mock(InmemoryDOMDataTreeShardWriteTransaction.class);
31 final CursorAwareDataTreeSnapshot snapshot = mock(CursorAwareDataTreeSnapshot.class);
32 doReturn(snapshot).when(inMemoryDOMDataTreeShard).takeSnapshot();
34 doReturn(inmemoryDOMDataTreeShardWriteTransaction).when(inMemoryDOMDataTreeShard)
35 .createTransaction(any(String.class), any(InMemoryDOMDataTreeShardProducer.class),
36 anyCollectionOf((DOMDataTreeIdentifier.class)), any(CursorAwareDataTreeSnapshot.class));
38 final InMemoryDOMDataTreeShardProducer inMemoryDOMDataTreeShardProducer =
39 new InMemoryDOMDataTreeShardProducer(inMemoryDOMDataTreeShard,
40 ImmutableSet.of(DOM_DATA_TREE_IDENTIFIER));
42 assertNotNull(inMemoryDOMDataTreeShardProducer.createTransaction());
43 verify(inMemoryDOMDataTreeShard).createTransaction(
45 any(InMemoryDOMDataTreeShardProducer.class),
46 anyCollectionOf(DOMDataTreeIdentifier.class),
47 any(CursorAwareDataTreeSnapshot.class));