GetMediaInfoCommand extends GetMediaInfo implements UpnpGetCommand<MediaInfo> { @Override public final void failure(ActionInvocation invocation, UpnpResponse response, String defaultMsg) { failureHandler.handle(defaultMsg); } GetMediaInfoCommand(UpnpDevice device, CommandFailureHandler failureHandler); @Override final void failure(ActionInvocation invocation, UpnpResponse response, String defaultMsg); @Override final void received(ActionInvocation invocation, MediaInfo mediaInfo);  }
@Test public void testGetMediaInfoCommandFailure() { UpnpDevice device = createMock(UpnpDevice.class); CommandFailureHandler failureHandler = createMock(CommandFailureHandler.class); ActionInvocation invocation = createMock(ActionInvocation.class); RemoteService avTransportService = createMock(RemoteService.class); Action<RemoteService> getMediaInfoAction = createMock(Action.class); ActionArgument<RemoteService> actionArgument = createMock(ActionArgument.class); UpnpResponse response = createMock(UpnpResponse.class); Datatype dataType = createMock(Datatype.class); final MediaInfo mediaInfo = new MediaInfo(); expect(device.getAvTransportService()).andReturn(avTransportService); expect(avTransportService.getAction("GetMediaInfo")).andReturn(getMediaInfoAction); expect(getMediaInfoAction.getInputArgument("InstanceID")).andReturn(actionArgument); expect(actionArgument.getDatatype()).andReturn(dataType); expect(actionArgument.getName()).andReturn("name"); expect(dataType.isValid(anyObject())).andReturn(TRUE); expect(dataType.getString(anyObject())).andReturn(""); failureHandler.handle("message"); expectLastCall(); replay(device, failureHandler, avTransportService, getMediaInfoAction, actionArgument, dataType, response, invocation); GetMediaInfoCommand command = new GetMediaInfoCommand(device, failureHandler) { @Override public void received(MediaInfo result) { assertEquals(mediaInfo, result); } }; command.failure(invocation, response, "message"); verify(device, failureHandler, avTransportService, getMediaInfoAction, actionArgument, dataType, response, invocation); }