import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
import java.io.FileNotFoundException;
-import java.net.URI;
import java.util.List;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class RestPutListDataTest {
+ private static SchemaContext schemaContextTestModule;
private static BrokerFacade brokerFacade;
private static RestconfImpl restconfImpl;
- private static SchemaContext schemaContextTestModule;
private static final String TEST_MODULE_NS_STRING = "test:module";
- private static final URI TEST_MODULE_NS;
private static final String TEST_MODULE_REVISION = "2014-01-09";
- static {
- TEST_MODULE_NS = URI.create("test:module");
+ @BeforeClass
+ public static void staticSetup() throws FileNotFoundException {
+ schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module");
}
@Before
- public void initialize() throws FileNotFoundException, ReactorException {
- final ControllerContext controllerContext = ControllerContext.getInstance();
- schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module");
- controllerContext.setSchemas(schemaContextTestModule);
+ public void initialize() throws FileNotFoundException {
+ final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContextTestModule);
brokerFacade = mock(BrokerFacade.class);
- restconfImpl = RestconfImpl.getInstance();
- restconfImpl.setBroker(brokerFacade);
- restconfImpl.setControllerContext(controllerContext);
+ restconfImpl = RestconfImpl.newInstance(brokerFacade, controllerContext);
final PutResult result = mock(PutResult.class);
when(brokerFacade.commitConfigurationDataPut(any(SchemaContext.class), any(YangInstanceIdentifier.class),
any(NormalizedNode.class), Mockito.anyString(), Mockito.anyString()))
.thenReturn(result);
- when(result.getFutureOfPutData()).thenReturn(mock(CheckedFuture.class));
+ when(result.getFutureOfPutData()).thenReturn(mock(FluentFuture.class));
when(result.getStatus()).thenReturn(Status.OK);
}
final DataSchemaNode testNodeSchemaNode = schemaContextTestModule.getDataChildByName(lstWithCompositeKey);
assertTrue(testNodeSchemaNode != null);
assertTrue(testNodeSchemaNode instanceof ListSchemaNode);
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> testNodeContainer =
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> testNodeContainer =
Builders.mapEntryBuilder((ListSchemaNode) testNodeSchemaNode);
List<DataSchemaNode> testChildren = ControllerContext.findInstanceDataChildrenByName(
final DataSchemaNode testLeafKey1SchemaNode = Iterables.getFirst(testChildren, null);
assertTrue(testLeafKey1SchemaNode != null);
assertTrue(testLeafKey1SchemaNode instanceof LeafSchemaNode);
- final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafKey1 =
+ final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafKey1 =
Builders.leafBuilder((LeafSchemaNode) testLeafKey1SchemaNode);
leafKey1.withValue(payloadKey1);
testNodeContainer.withChild(leafKey1.build());
final DataSchemaNode testLeafKey2SchemaNode = Iterables.getFirst(testChildren, null);
assertTrue(testLeafKey2SchemaNode != null);
assertTrue(testLeafKey2SchemaNode instanceof LeafSchemaNode);
- final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafKey2 =
+ final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafKey2 =
Builders.leafBuilder((LeafSchemaNode) testLeafKey2SchemaNode);
leafKey2.withValue(payloadKey2);
testNodeContainer.withChild(leafKey2.build());
}
return uriBuilder.toString();
}
-
}