* 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.restconf.restful.services.impl;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+
import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import java.lang.reflect.Field;
import java.util.ArrayList;
import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
import org.opendaylight.restconf.handlers.SchemaContextHandler;
import org.opendaylight.restconf.handlers.TransactionChainHandler;
+import org.opendaylight.restconf.restful.services.api.RestconfStreamsSubscriptionService;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class RestconfDataServiceImplTest {
private DOMDataBroker mountDataBroker;
@Mock
private DOMTransactionChain transactionChain;
+ @Mock
+ private RestconfStreamsSubscriptionService delegRestconfSubscrService;
@Before
public void setUp() throws Exception {
.node(this.baseQName)
.build();
- this.contextRef = new SchemaContextRef(TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT));
+ this.contextRef = new SchemaContextRef(
+ YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
this.schemaNode = DataSchemaContextTree.from(this.contextRef.get()).getChild(this.iidBase).getDataSchemaNode();
- final SchemaContextHandler schemaContextHandler = new SchemaContextHandler();
+ final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
+ final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
+ Mockito.when(txHandler.get()).thenReturn(domTx);
+ final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
+ Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
+ final CheckedFuture checked = Mockito.mock(CheckedFuture.class);
+ Mockito.when(wTx.submit()).thenReturn(checked);
+ final Object valueObj = null;
+ Mockito.when(checked.checkedGet()).thenReturn(valueObj);
+ final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(txHandler);
schemaContextHandler.onGlobalContextUpdated(this.contextRef.get());
- this.dataService = new RestconfDataServiceImpl(schemaContextHandler, this.transactionChainHandler, this.mountPointServiceHandler);
+ this.dataService = new RestconfDataServiceImpl(schemaContextHandler, this.transactionChainHandler,
+ this.mountPointServiceHandler, this.delegRestconfSubscrService);
doReturn(this.domTransactionChain).when(this.transactionChainHandler).get();
doReturn(this.read).when(this.domTransactionChain).newReadOnlyTransaction();
doReturn(this.readWrite).when(this.domTransactionChain).newReadWriteTransaction();