public void WhenCheckedConnection() { HandlePluginCommand("CheckConnection", new PluginProfileDto { Name = "Test Profile", Settings = _settings }.Serialize()); _response = Context.Transport.TpQueue.GetMessages <PluginCommandResponseMessage>().Single(); _errors = _response.ResponseData.Deserialize <PluginProfileErrorCollection>(); }
public PluginCommandResponseMessage Execute(string arguments) { Arguments = arguments; var pluginCustomCommandResponse = new PluginCommandResponseMessage { ResponseData = "Some Response" }; ResponseMessage = pluginCustomCommandResponse; return(pluginCustomCommandResponse); }
public void RequestAutomapping() { var settings = new ConnectionSettings { UserMapping = _settings.UserMapping }; var args = new AutomapVcsToTpUsersCommandArgs { Connection = settings, TpUsers = Context.TpUsers.ToList() }; HandlePluginCommand(ObjectFactory.GetInstance <AutomapVcsToTpUsersCommand>().Name, args.Serialize()); _response = Context.Transport.TpQueue.GetMessages <PluginCommandResponseMessage>().Single(); }
public void WhenSaved() { HandlePluginCommand("AddProfile", new PluginProfileDto { Name = "Test Profile", Settings = _settings }.Serialize()); _response = TransportMock.TpQueue.GetMessages <PluginCommandResponseMessage>().Single(); _errors = new PluginProfileErrorCollection(); if (_response.PluginCommandStatus == PluginCommandStatus.Fail) { _errors = _response.ResponseData.Deserialize <PluginProfileErrorCollection>(); } }
public void Handle(ExecutePluginCommandCommand message) { _log.Info("Executing plugin command : {0}".Fmt(message.CommandName)); try { var replyMessage = new PluginCommandResponseMessage(); var commandsToExecute = _pluginCommandRepository.Where(x => x.Name == message.CommandName).ToArray(); if (commandsToExecute.Count() > 1) { replyMessage.ResponseData = string.Format("There are more than one command with name '{0}'", message.CommandName); replyMessage.PluginCommandStatus = PluginCommandStatus.Error; } else if (!commandsToExecute.Any()) { replyMessage.ResponseData = string.Format("No command with name '{0}' was found", message.CommandName); replyMessage.PluginCommandStatus = PluginCommandStatus.Error; } else { replyMessage = commandsToExecute[0].Execute(message.Arguments); } _tpBus.Reply(replyMessage); _log.Info("plugin command executed: {0}".Fmt(message.CommandName)); } catch (PluginProfileValidationException validationException) { _log.Info("Profile validation failed during executing command {0} : {1}".Fmt(message.CommandName, validationException.Errors.Serialize())); _tpBus.Reply(new PluginCommandResponseMessage { ResponseData = validationException.Errors.Serialize(), PluginCommandStatus = PluginCommandStatus.Fail }); } catch (Exception e) { _log.Error(string.Format("Plugin {0} command processing failed.", message.CommandName), e); _tpBus.Reply(new PluginCommandResponseMessage { ResponseData = string.Format("Plugin {0} command processing error: {1}", message.CommandName, e.Message), PluginCommandStatus = PluginCommandStatus.Error }); } }
public void GetProfileCommandReceived(string accountName, string profileName) { ObjectFactory.GetInstance <PluginContextMock>().AccountName = accountName; _response = ObjectFactory.GetInstance <GetProfileCommand>().Execute(profileName); }
private PluginCommandResponseMessage OnExecute() { var resultMessage = new PluginCommandResponseMessage { ResponseData = string.Empty, PluginCommandStatus = PluginCommandStatus.Succeed }; var profile = _storageRepository.GetProfile <TestRunImportPluginProfile>(); if (profile.FrameworkType == FrameworkTypes.FrameworkTypes.Selenium && profile.PostResultsToRemoteUrl) { return(resultMessage); } try { var uri = new Uri(profile.ResultsFilePath); var factoryResult = _streamFactory.OpenStreamIfModified(uri, new LastModifyResult(), profile.PassiveMode); if (factoryResult != null) { _storageRepository.Get <LastModifyResult>().Clear(); _storageRepository.Get <LastModifyResult>().Add(factoryResult.LastModifyResult); using (factoryResult.Stream) { using (var reader = new StreamReader(factoryResult.Stream)) { try { var result = _resultsReaderFactory.GetResolver(profile, reader).GetTestRunImportResults(); if (result.Count > 0) { _localBus.SendLocal(new TestRunImportResultDetectedLocalMessage { TestRunImportInfo = new TestRunImportInfo { TestRunImportResults = result.ToArray() } }); } } catch (ApplicationException ex) { resultMessage.ResponseData = ex.Message; resultMessage.PluginCommandStatus = PluginCommandStatus.Error; } catch (XmlException ex) { resultMessage.ResponseData = string.Format("Error parsing results XML file; {0}", ex.Message); resultMessage.PluginCommandStatus = PluginCommandStatus.Error; } catch (Exception ex) { resultMessage.ResponseData = string.Format("Error parsing results XML file; {0}", ex.Message); resultMessage.PluginCommandStatus = PluginCommandStatus.Error; } } } } } catch (UriFormatException ex) { resultMessage.ResponseData = string.Format("Specified path has invalid format. {0}", ex.Message); resultMessage.PluginCommandStatus = PluginCommandStatus.Error; } catch (ApplicationException ex) { resultMessage.ResponseData = string.Format("Specified path has invalid format. {0}", ex.Message); resultMessage.PluginCommandStatus = PluginCommandStatus.Error; } catch (Exception ex) { resultMessage.ResponseData = string.Format("Could not read file \"{0}\": {1}", profile.ResultsFilePath, ex.Message); resultMessage.PluginCommandStatus = PluginCommandStatus.Error; } return(resultMessage); }