Merge "Implement basic ShardTransactionChain#CloseTransactionChain"
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / MediaTypesTest.java
index 5a2c964b8b15a8eb46c6fea2cc46e77c350cdcdf..319603dfc14b1f6a4965d6de46e99bf1a6199f8f 100644 (file)
@@ -38,11 +38,11 @@ import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 
 public class MediaTypesTest extends JerseyTest {
-    
+
     private static RestconfService restconfService;
     private static String jsonData;
     private static String xmlData;
-    
+
     @BeforeClass
     public static void init() throws IOException {
         restconfService = mock(RestconfService.class);
@@ -51,7 +51,7 @@ public class MediaTypesTest extends JerseyTest {
         InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
         xmlData = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
     }
-    
+
     @Override
     protected Application configure() {
         /* enable/disable Jersey logs to console */
@@ -65,7 +65,7 @@ public class MediaTypesTest extends JerseyTest {
                 JsonToCompositeNodeProvider.INSTANCE);
         return resourceConfig;
     }
-    
+
   @Test
   public void testPostOperationsWithInputDataMediaTypes() throws UnsupportedEncodingException {
       String uriPrefix = "/operations/";
@@ -84,58 +84,58 @@ public class MediaTypesTest extends JerseyTest {
       verify(restconfService, times(5)).invokeRpc(eq(uriPath), any(CompositeNode.class));
       post(uri, null, MediaType.TEXT_XML, xmlData);
       verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(CompositeNode.class));
-      
+
       // negative tests
       post(uri, MediaType.TEXT_PLAIN, MediaType.TEXT_XML, xmlData);
       verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(CompositeNode.class));
       post(uri, MediaType.TEXT_XML, MediaType.TEXT_PLAIN, xmlData);
       verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(CompositeNode.class));
   }
-  
+
     @Test
     public void testGetConfigMediaTypes() throws UnsupportedEncodingException {
         String uriPrefix = "/config/";
         String uriPath = "ietf-interfaces:interfaces";
         String uri = uriPrefix + uriPath;
-        when(restconfService.readConfigurationData(uriPath)).thenReturn(null);
+        when(restconfService.readConfigurationData(eq(uriPath), any(UriInfo.class))).thenReturn(null);
         get(uri, Draft02.MediaTypes.DATA+JSON);
-        verify(restconfService, times(1)).readConfigurationData(uriPath);
+        verify(restconfService, times(1)).readConfigurationData(eq(uriPath), any(UriInfo.class));
         get(uri, Draft02.MediaTypes.DATA+XML);
-        verify(restconfService, times(2)).readConfigurationData(uriPath);
+        verify(restconfService, times(2)).readConfigurationData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.APPLICATION_JSON);
-        verify(restconfService, times(3)).readConfigurationData(uriPath);
+        verify(restconfService, times(3)).readConfigurationData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.APPLICATION_XML);
-        verify(restconfService, times(4)).readConfigurationData(uriPath);
+        verify(restconfService, times(4)).readConfigurationData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.TEXT_XML);
-        verify(restconfService, times(5)).readConfigurationData(uriPath);
-        
+        verify(restconfService, times(5)).readConfigurationData(eq(uriPath), any(UriInfo.class));
+
         // negative tests
         get(uri, MediaType.TEXT_PLAIN);
-        verify(restconfService, times(5)).readConfigurationData(uriPath);
+        verify(restconfService, times(5)).readConfigurationData(eq(uriPath), any(UriInfo.class));
     }
-    
+
     @Test
     public void testGetOperationalMediaTypes() throws UnsupportedEncodingException {
         String uriPrefix = "/operational/";
         String uriPath = "ietf-interfaces:interfaces";
         String uri = uriPrefix + uriPath;
-        when(restconfService.readOperationalData(uriPath)).thenReturn(null);
+        when(restconfService.readOperationalData(eq(uriPath), any(UriInfo.class))).thenReturn(null);
         get(uri, Draft02.MediaTypes.DATA+JSON);
-        verify(restconfService, times(1)).readOperationalData(uriPath);
+        verify(restconfService, times(1)).readOperationalData(eq(uriPath), any(UriInfo.class));
         get(uri, Draft02.MediaTypes.DATA+XML);
-        verify(restconfService, times(2)).readOperationalData(uriPath);
+        verify(restconfService, times(2)).readOperationalData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.APPLICATION_JSON);
-        verify(restconfService, times(3)).readOperationalData(uriPath);
+        verify(restconfService, times(3)).readOperationalData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.APPLICATION_XML);
-        verify(restconfService, times(4)).readOperationalData(uriPath);
+        verify(restconfService, times(4)).readOperationalData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.TEXT_XML);
-        verify(restconfService, times(5)).readOperationalData(uriPath);
-        
+        verify(restconfService, times(5)).readOperationalData(eq(uriPath), any(UriInfo.class));
+
         // negative tests
         get(uri, MediaType.TEXT_PLAIN);
-        verify(restconfService, times(5)).readOperationalData(uriPath);
+        verify(restconfService, times(5)).readOperationalData(eq(uriPath), any(UriInfo.class));
     }
-    
+
     @Test
     public void testPutConfigMediaTypes() throws UnsupportedEncodingException {
         String uriPrefix = "/config/";
@@ -155,7 +155,7 @@ public class MediaTypesTest extends JerseyTest {
         put(uri, "fooMediaType", MediaType.TEXT_XML, xmlData);
         verify(restconfService, times(6)).updateConfigurationData(eq(uriPath), any(CompositeNode.class));
     }
-    
+
     @Test
     public void testPostConfigWithPathMediaTypes() throws UnsupportedEncodingException {
         String uriPrefix = "/config/";
@@ -175,7 +175,7 @@ public class MediaTypesTest extends JerseyTest {
         post(uri, "fooMediaType", MediaType.TEXT_XML, xmlData);
         verify(restconfService, times(6)).createConfigurationData(eq(uriPath), any(CompositeNode.class));
     }
-    
+
     @Test
     public void testPostConfigMediaTypes() throws UnsupportedEncodingException {
         String uriPrefix = "/config/";
@@ -194,7 +194,7 @@ public class MediaTypesTest extends JerseyTest {
         post(uri, "fooMediaType", MediaType.TEXT_XML, xmlData);
         verify(restconfService, times(6)).createConfigurationData(any(CompositeNode.class));
     }
-    
+
     @Test
     public void testDeleteConfigMediaTypes() throws UnsupportedEncodingException {
         String uriPrefix = "/config/";
@@ -204,18 +204,18 @@ public class MediaTypesTest extends JerseyTest {
         target(uri).request("fooMediaType").delete();
         verify(restconfService, times(1)).deleteConfigurationData(uriPath);
     }
-    
+
     private int get(String uri, String acceptMediaType) {
         return target(uri).request(acceptMediaType).get().getStatus();
     }
-    
+
     private int put(String uri, String acceptMediaType, String contentTypeMediaType, String data) {
         if (acceptMediaType == null) {
             return target(uri).request().put(Entity.entity(data, contentTypeMediaType)).getStatus();
         }
         return target(uri).request(acceptMediaType).put(Entity.entity(data, contentTypeMediaType)).getStatus();
     }
-    
+
     private int post(String uri, String acceptMediaType, String contentTypeMediaType, String data) {
         if (acceptMediaType == null) {
             if (contentTypeMediaType == null || data == null) {