package org.opendaylight.controller.sal.restconf.impl.test;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
+import java.util.Optional;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
-import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
-import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class Bug8072Test {
private static final QName TYPE_QNAME = QName.create("test:module", "2014-01-09", "type");
private static final QName MODULE_TYPE_QNAME = QName.create("test:module", "2014-01-09", "module-type");
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final ControllerContext controllerContext;
public Bug8072Test() throws FileNotFoundException {
- final SchemaContext mountPointContext = TestUtils.loadSchemaContext("/full-versions/test-module");
+ final EffectiveModelContext mountPointContext = TestUtils.loadSchemaContext("/full-versions/test-module");
final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mountInstance);
- doReturn(mountPointContext).when(mountInstance).getSchemaContext();
-
- final BrokerFacade brokerFacade = mock(BrokerFacade.class);
- final RestconfImpl restconfImpl = RestconfImpl.getInstance();
- restconfImpl.setBroker(brokerFacade);
- restconfImpl.setControllerContext(controllerContext);
+ doReturn(Optional.of(FixedDOMSchemaService.of(() -> mountPointContext))).when(mountInstance)
+ .getService(DOMSchemaService.class);
}
@BeforeClass
public static void init() throws FileNotFoundException, ReactorException {
schemaContext = TestUtils.loadSchemaContext("/full-versions/yangs");
assertEquals(0, schemaContext.findModules(EXTERNAL_MODULE_NAME).size());
- final Set<Module> allModules = schemaContext.getModules();
- assertNotNull(allModules);
}
@Test
keyValues.put(NAME_QNAME, "name");
keyValues.put(TYPE_QNAME, MODULE_TYPE_QNAME);
final YangInstanceIdentifier expectedYII = YangInstanceIdentifier.of(MODULES_QNAME).node(MODULE_QNAME)
- .node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(MODULE_QNAME, keyValues));
+ .node(NodeIdentifierWithPredicates.of(MODULE_QNAME, keyValues));
assertEquals(expectedYII, ctx.getInstanceIdentifier());
}