StreamingHandler { @GET @Path("/devices") @Produces(APPLICATION_JSON) public List<PlaybackDevice> getDevices() { Collection<Device> devices = streamingManager.getDevices(); List<PlaybackDevice> playbackDevices = new ArrayList<>(devices.size()); playbackDevices.addAll(devices.stream().map(this::buildPlaybackDevice).collect(toList())); return playbackDevices; } @Inject  StreamingHandler(final MediaManager mediaManager, final StreamingManager streamingManager); @GET @Path("/devices") @Produces(APPLICATION_JSON) List<PlaybackDevice> getDevices(); @GET @Path("/play/{deviceId}/{contentId}") @Produces(TEXT_PLAIN) String play(@PathParam("deviceId") final String deviceId, @PathParam("contentId") final String contentId); @GET @Path("/pause/{deviceId}") @Produces(TEXT_PLAIN) String pause(@PathParam("deviceId") final String deviceId); @GET @Path("/stop/{deviceId}") @Produces(TEXT_PLAIN) String stop(@PathParam("deviceId") final String deviceId); @GET @Path("/resume/{deviceId}") @Produces(TEXT_PLAIN) String resume(@PathParam("deviceId") final String deviceId); @GET @Path("/status/{deviceId}") @Produces(APPLICATION_JSON) PlaybackStatus status(@PathParam("deviceId") final String deviceId); @GET @Path("/browse/{deviceId}/{nodeId}") @Produces(APPLICATION_JSON) DeviceBrowseResult browse(@PathParam("deviceId") final String deviceId, @PathParam("nodeId") final String nodeId);  }
@Test public void testGetDevices() { MediaManager mediaManager = createMock(MediaManager.class); StreamingManager streamingManager = createMock(StreamingManager.class); Device device = createMock(Device.class); expect(streamingManager.getDevices()).andReturn(newArrayList(device)).atLeastOnce(); expect(device.getId()).andReturn("deviceId").atLeastOnce(); expect(device.getName()).andReturn("deviceName").atLeastOnce(); expect(device.getType()).andReturn("deviceType").atLeastOnce(); expect(device.isVideoSupported()).andReturn(true).atLeastOnce(); expect(device.isAudioSupported()).andReturn(true).atLeastOnce(); expect(device.isImageSupported()).andReturn(true).atLeastOnce(); expect(device.isSlideShowSupported()).andReturn(true).atLeastOnce(); replay(mediaManager, streamingManager, device); StreamingHandler streamingHandler = new StreamingHandler(mediaManager, streamingManager); List<PlaybackDevice> devices = streamingHandler.getDevices(); assertNotNull(devices); assertEquals(1, devices.size()); PlaybackDevice playbackDevice = devices.get(0); assertEquals("deviceId", playbackDevice.getDeviceId()); assertEquals("deviceName", playbackDevice.getDeviceName()); assertEquals("deviceType", playbackDevice.getDeviceType()); assertTrue(playbackDevice.isVideoSupported()); assertTrue(playbackDevice.isAudioSupported()); assertTrue(playbackDevice.isImageSupported()); assertTrue(playbackDevice.isSlideShowSupported()); verify(mediaManager, streamingManager, device); }