+ doReturn(new MultivaluedHashMap<String, String>()).when(this.uriInfo).getQueryParameters();
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(this.read).read(LogicalDatastoreType.CONFIGURATION,
+ this.iidBase);
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(this.read).read(LogicalDatastoreType.OPERATIONAL,
+ this.iidBase);
+ this.dataService.readData("example-jukebox:jukebox", this.uriInfo);
+ }
+
+ /**
+ * Read data from config datastore according to content parameter
+ */
+ @Test
+ public void testReadDataConfigTest() {
+ final MultivaluedHashMap<String, String> parameters = new MultivaluedHashMap<>();
+ parameters.put("content", Collections.singletonList("config"));
+
+ doReturn(parameters).when(this.uriInfo).getQueryParameters();
+ doReturn(Futures.immediateCheckedFuture(Optional.of(this.buildBaseContConfig))).when(this.read)
+ .read(LogicalDatastoreType.CONFIGURATION, this.iidBase);
+ doReturn(Futures.immediateCheckedFuture(Optional.of(this.buildBaseContOperational))).when(this.read)
+ .read(LogicalDatastoreType.OPERATIONAL, this.iidBase);
+
+ final Response response = this.dataService.readData("example-jukebox:jukebox", this.uriInfo);
+
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+
+ // response must contain only config data
+ final NormalizedNode<?, ?> data = ((NormalizedNodeContext) response.getEntity()).getData();
+
+ // config data present
+ assertTrue(((ContainerNode) data).getChild(this.buildPlayerCont.getIdentifier()).isPresent());
+ assertTrue(((ContainerNode) data).getChild(this.buildLibraryCont.getIdentifier()).isPresent());
+
+ // state data absent
+ assertFalse(((ContainerNode) data).getChild(this.buildPlaylistList.getIdentifier()).isPresent());
+ }
+
+ /**
+ * Read data from operational datastore according to content parameter
+ */
+ @Test
+ public void testReadDataOperationalTest() {
+ final MultivaluedHashMap<String, String> parameters = new MultivaluedHashMap<>();
+ parameters.put("content", Collections.singletonList("nonconfig"));
+
+ doReturn(parameters).when(this.uriInfo).getQueryParameters();
+ doReturn(Futures.immediateCheckedFuture(Optional.of(this.buildBaseContConfig))).when(this.read)
+ .read(LogicalDatastoreType.CONFIGURATION, this.iidBase);
+ doReturn(Futures.immediateCheckedFuture(Optional.of(this.buildBaseContOperational))).when(this.read)
+ .read(LogicalDatastoreType.OPERATIONAL, this.iidBase);
+
+ final Response response = this.dataService.readData("example-jukebox:jukebox", this.uriInfo);
+
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+
+ // response must contain only operational data
+ final NormalizedNode<?, ?> data = ((NormalizedNodeContext) response.getEntity()).getData();
+
+ // state data present
+ assertTrue(((ContainerNode) data).getChild(this.buildPlayerCont.getIdentifier()).isPresent());
+ assertTrue(((ContainerNode) data).getChild(this.buildPlaylistList.getIdentifier()).isPresent());
+
+ // config data absent
+ assertFalse(((ContainerNode) data).getChild(this.buildLibraryCont.getIdentifier()).isPresent());