//[Fact] public void Actually_Call_Api_Tasks() { ITalendAdminApi api = new TalendAdminApi(_settings.TalendAdminAddress, _settings.TalendAdminUsername, _settings.TalendAdminPassword); var items = api.GetTaskList(); items.ShouldNotBeEmpty(); }
public void TestGetTaskListFailsIfInvalid() { // GIVEN var taskList = new Models.TalendApiListResponseRaw <Models.Task> { ReturnCode = 5 }; var response = Substitute.For <RestResponse <Models.TalendApiListResponseRaw <Models.Task> > >(); response.Data = taskList; var restClient = Substitute.For <IRestClient>(); restClient.Execute <Models.TalendApiListResponseRaw <Models.Task> >(Arg.Any <RestRequest>()).Returns(response); // WHEN & THEN ITalendAdminApi api = new TalendAdminApi(_settings.TalendAdminAddress, _settings.TalendAdminUsername, _settings.TalendAdminPassword, restClient); Assert.Throws <System.Exception>(() => api.GetTaskList()); }
public void TestGetTaskListReturnsItems() { // GIVEN var taskList = new Models.TalendApiListResponseRaw <Models.Task> { ReturnCode = 0, ExecutionTime = new Models.TalendApiResponse.Executiontime { millis = 500, seconds = 2 }, Results = new System.Collections.Generic.List <Models.Task> { new Models.Task { active = "true", id = "123", label = "test-task", addStatisticsCodeEnabled = "true", applicationBundleName = "org.rsc", applicationFeatureURL = "url", applicationGroup = "org.rsc", applicationId = "50", applicationName = "one", applicationType = "first", applicationVersion = "0.1.1", applyContextToChildren = "true", artifactGroupId = "org.rsc", artifactId = "org.rsc", artifactVersion = "0.5", awaitingExecutions = "true", branch = "branch", commandLineVersion = "0.1", concurrentExecution = "true", contextName = "context", description = "describe this", errorStatus = "errored", execStatisticsEnabled = "false", executionServerId = "013", featuresName = "feature2", featuresVersion = "feature0.5.1", framework = "framework1", frozenExecutions = "execute2", idQuartzJob = "id1", jobscriptarchivefilename = "/first/folder", jobServerLabelHost = "label", lastDeploymentDate = "one", lastEndedRunDate = "1/1/1999", lastRunDate = "first", lastScriptGenerationDate = "1/12/2011", lastTaskTraceError = "errored somewhere", latestVersion = "0.2", log4jLevel = "WARN", nextFireDate = "05/05/2022", onlineStatus = "online", onUnknownStateJob = "unknown", originType = "origin", pid = "123", processingState = "BLOCKED", projectId = "42", projectName = "project one", regenerateJobOnChange = "regenerate", remaingTimeForNextFire = "10 minutes", repositoryName = "repo2", runAsUser = "******", snapshot = "true", status = "active", svnConnectionAvailable = "false", svnRevision = "0.1.5.2", taskType = "ESB", timeOut = "5 minutes", triggersStatus = "status", virtualServerLabel = "virtual label" } } }; var response = Substitute.For <RestResponse <Models.TalendApiListResponseRaw <Models.Task> > >(); response.Data = taskList; var apiCommand = new Models.ApiCommandRequest { authPass = _settings.TalendAdminPassword, authUser = _settings.TalendAdminUsername, actionName = TalendAdminApiCommands.LIST_TASKS }; var encodedApiCommand = GetMetaservletCommand(apiCommand); var restClient = Substitute.For <IRestClient>(); restClient.Execute <Models.TalendApiListResponseRaw <Models.Task> >( Arg.Do <RestRequest>(x => x.Resource.ShouldEqual($"metaServlet?{encodedApiCommand}"))).Returns(response); // WHEN ITalendAdminApi api = new TalendAdminApi(_settings.TalendAdminAddress, _settings.TalendAdminUsername, _settings.TalendAdminPassword, restClient); var items = api.GetTaskList(); // THEN items.ShouldNotBeEmpty(); items.First().id.ShouldEqual("123"); items.First().label.ShouldEqual("test-task"); }