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.ArgumentMatchers.any;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.verify;
15 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.DOM_DATA_TREE_IDENTIFIER;
16 import static org.opendaylight.mdsal.dom.store.inmemory.TestUtils.resetMocks;
18 import com.google.common.collect.ImmutableMap;
19 import com.google.common.collect.ImmutableSet;
20 import org.junit.Test;
21 import org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeSnapshot;
23 public class InMemoryDOMDataTreeShardProducerTest {
26 public void basicTest() throws Exception {
27 final InMemoryDOMDataTreeShard inMemoryDOMDataTreeShard = mock(InMemoryDOMDataTreeShard.class);
28 final InmemoryDOMDataTreeShardWriteTransaction inmemoryDOMDataTreeShardWriteTransaction =
29 mock(InmemoryDOMDataTreeShardWriteTransaction.class);
30 final CursorAwareDataTreeSnapshot snapshot = mock(CursorAwareDataTreeSnapshot.class);
31 doReturn(snapshot).when(inMemoryDOMDataTreeShard).takeSnapshot();
33 doReturn(inmemoryDOMDataTreeShardWriteTransaction).when(inMemoryDOMDataTreeShard)
34 .createTransaction(any(String.class), any(InMemoryDOMDataTreeShardProducer.class),
35 any(CursorAwareDataTreeSnapshot.class));
37 final InMemoryDOMDataTreeShardProducer inMemoryDOMDataTreeShardProducer =
38 new InMemoryDOMDataTreeShardProducer(inMemoryDOMDataTreeShard,
39 ImmutableSet.of(DOM_DATA_TREE_IDENTIFIER),
40 new InMemoryShardDataModificationFactory(DOM_DATA_TREE_IDENTIFIER, ImmutableMap.of(),
43 assertNotNull(inMemoryDOMDataTreeShardProducer.createTransaction());
44 verify(inMemoryDOMDataTreeShard).createTransaction(
46 any(InMemoryDOMDataTreeShardProducer.class),
47 any(CursorAwareDataTreeSnapshot.class));