SetContentUrlCommand extends SetAVTransportURI implements UpnpSetCommand { @Override public final void success(ActionInvocation invocation) { success(); } SetContentUrlCommand(UpnpDevice device, String contentUrl, String metadata, CommandFailureHandler failureHandler); @Override final void failure(ActionInvocation invocation, UpnpResponse response, String defaultMsg); @Override final void success(ActionInvocation invocation);  }
@Test public void testSetContentUrlCommandSuccess() { UpnpDevice device = createMock(UpnpDevice.class); CommandFailureHandler failureHandler = createMock(CommandFailureHandler.class); ActionInvocation invocation = createMock(ActionInvocation.class); RemoteService avTransportService = createMock(RemoteService.class); Action<RemoteService> setContentUrlAction = createMock(Action.class); ActionArgument<RemoteService> actionArgument = createMock(ActionArgument.class); ActionArgument<RemoteService> currentURIActionArgument = createMock(ActionArgument.class); ActionArgument<RemoteService> currentURIMetadataActionArgument = createMock(ActionArgument.class); Datatype dataType = createMock(Datatype.class); expect(device.getAvTransportService()).andReturn(avTransportService); expect(avTransportService.getAction("SetAVTransportURI")).andReturn(setContentUrlAction); expect(setContentUrlAction.getInputArgument("InstanceID")).andReturn(actionArgument); expect(setContentUrlAction.getInputArgument("CurrentURI")).andReturn(currentURIActionArgument); expect(setContentUrlAction.getInputArgument("CurrentURIMetaData")).andReturn(currentURIMetadataActionArgument); expect(actionArgument.getDatatype()).andReturn(dataType); expect(actionArgument.getName()).andReturn("name"); expect(currentURIActionArgument.getDatatype()).andReturn(dataType); expect(currentURIActionArgument.getName()).andReturn("name"); expect(currentURIMetadataActionArgument.getDatatype()).andReturn(dataType); expect(currentURIMetadataActionArgument.getName()).andReturn("name"); expect(dataType.isValid(anyObject())).andReturn(TRUE).atLeastOnce(); expect(dataType.getString(anyObject())).andReturn("").atLeastOnce(); expect(dataType.valueOf("contentUrl")).andReturn("contentUrl"); expect(dataType.valueOf("metadata")).andReturn("metadata"); replay(device, failureHandler, invocation, avTransportService, setContentUrlAction, actionArgument, currentURIActionArgument, currentURIMetadataActionArgument, dataType); SetContentUrlCommand command = new SetContentUrlCommand(device, "contentUrl", "metadata", failureHandler) { @Override public void success() { } }; command.success(invocation); verify(device, failureHandler, invocation, avTransportService, setContentUrlAction, actionArgument, currentURIActionArgument, currentURIMetadataActionArgument, dataType); }