import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.stmt.ListEffectiveStatement;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
current = next;
} while (current.isMixin());
+ // We need to unwind the last identifier if it a NodeIdentifierWithPredicates, as it does not have
+ // any predicates at all. The real identifier is then added below
+ if (stack.currentStatement() instanceof ListEffectiveStatement) {
+ iiToDataList.remove(iiToDataList.size() - 1);
+ }
+
inference = stack.toInference();
} else {
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.OperationDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.stmt.ListEffectiveStatement;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
current = next;
} while (current.isMixin());
+ // We need to unwind the last identifier if it a NodeIdentifierWithPredicates, as it does not have
+ // any predicates at all. The real identifier is then added below
+ if (stack.currentStatement() instanceof ListEffectiveStatement) {
+ iiToDataList.remove(iiToDataList.size() - 1);
+ }
+
inference = stack.toInference();
} else {
// PUT
parsed = mapNode.body().iterator().next();
}
- if (schemaNode instanceof ListSchemaNode && isPost()) {
+ if (schemaNode instanceof ListSchemaNode && isPost()) {
iiToDataList.add(parsed.getIdentifier());
}
} else {
import javax.ws.rs.core.MediaType;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
public class XmlBodyReaderTest extends AbstractBodyReaderTest {
private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
XMLNamespace.of("instance:identifier:module"), Revision.of("2014-01-17"));
+ private static final QName TOP_LEVEL_LIST = QName.create("foo", "2017-08-09", "top-level-list");
private static EffectiveModelContext schemaContext;
XmlBodyReaderTest.class.getResourceAsStream("/foo-xml-test/foo.xml"));
assertNotNull(payload);
+ final InstanceIdentifierContext iid = payload.getInstanceIdentifierContext();
+ assertEquals(YangInstanceIdentifier.create(
+ new NodeIdentifier(TOP_LEVEL_LIST),
+ NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST, QName.create(TOP_LEVEL_LIST, "key-leaf"), "key-value")),
+ iid.getInstanceIdentifier());
+
assertThat(payload.getData(), instanceOf(MapEntryNode.class));
final MapEntryNode data = (MapEntryNode) payload.getData();
assertEquals(2, data.size());