2 * Copyright (c) 2015 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
9 package org.opendaylight.controller.sal.rest.impl.test.providers;
11 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
13 import java.io.InputStream;
14 import javax.ws.rs.core.MediaType;
15 import org.junit.BeforeClass;
16 import org.junit.Test;
17 import org.opendaylight.netconf.sal.rest.impl.JsonToPATCHBodyReader;
18 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 public class TestJsonPATCHBodyReader extends AbstractBodyReaderTest {
23 private final JsonToPATCHBodyReader jsonPATCHBodyReader;
24 private static SchemaContext schemaContext;
26 public TestJsonPATCHBodyReader() throws NoSuchFieldException, SecurityException {
28 jsonPATCHBodyReader = new JsonToPATCHBodyReader();
32 protected MediaType getMediaType() {
33 return new MediaType(APPLICATION_JSON, null);
37 public static void initialization() {
38 schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
39 controllerContext.setSchemas(schemaContext);
43 public void modulePATCHDataTest() throws Exception {
44 final String uri = "instance-identifier-patch-module:patch-cont/my-list1/leaf1";
45 mockBodyReader(uri, jsonPATCHBodyReader, false);
47 final InputStream inputStream = TestJsonBodyReader.class
48 .getResourceAsStream("/instanceidentifier/json/jsonPATCHdata.json");
50 final PATCHContext returnValue = jsonPATCHBodyReader
51 .readFrom(null, null, null, mediaType, null, inputStream);
52 checkPATCHContext(returnValue);