コード例 #1
0
        public void CreateWorkspace_Success()
        {
            Console.WriteLine("\nCalling CreateWorkspace()...");
            CreateWorkspace workspace = new CreateWorkspace()
            {
                Name        = _createdWorkspaceName,
                Description = _createdWorkspaceDescription,
                Language    = _createdWorkspaceLanguage
            };

            var result = conversation.CreateWorkspace(workspace);


            if (result != null)
            {
                Console.WriteLine(string.Format("Workspace Name: {0}, id: {1}, description: {2}", result.Name, result.WorkspaceId, result.Description));
                if (!string.IsNullOrEmpty(result.WorkspaceId))
                {
                    _createdWorkspaceId = result.WorkspaceId;
                }
            }
            else
            {
                Console.WriteLine("Result is null.");
            }

            Assert.IsNotNull(result);
        }
コード例 #2
0
        public WorkspaceResponse CreateWorkspace(CreateWorkspace request)
        {
            WorkspaceResponse result = null;

            if (request == null)
            {
                throw new ArgumentNullException("parameter: request");
            }

            try
            {
                result =
                    this.Client.WithAuthentication(this.UserName, this.Password)
                    .PostAsync($"{this.Endpoint}{PATH_CONVERSATION}")
                    .WithArgument("version", VERSION_DATE_2017_05_26)
                    .WithHeader("accept", HttpMediaType.TEXT_HTML)
                    .WithBody <CreateWorkspace>(request, MediaTypeHeaderValue.Parse(HttpMediaType.APPLICATION_JSON))
                    .As <WorkspaceResponse>()
                    .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
コード例 #3
0
        public WorkspaceResponse CreateWorkspace(CreateWorkspace body = null)
        {
            if (string.IsNullOrEmpty(VersionDate))
            {
                throw new ArgumentNullException("versionDate cannot be null. Use 'CONVERSATION_VERSION_DATE_2017_05_26'");
            }

            WorkspaceResponse result = null;

            try
            {
                result = this.Client.WithAuthentication(this.UserName, this.Password)
                         .PostAsync($"{this.Endpoint}/v1/workspaces")
                         .WithArgument("version", VersionDate)
                         .WithBody <CreateWorkspace>(body)
                         .As <WorkspaceResponse>()
                         .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
コード例 #4
0
        public void Execute_TestFixtureSetup()
        {
            //Setup for testing
            //Setup for testing
            TestHelper helper = new TestHelper();

            servicesManager = helper.GetServicesManager();

            // implement_IHelper
            //create client
            _client        = helper.GetServicesManager().GetProxy <IRSAPIClient>(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD);
            _eddsDbContext = helper.GetDBContext(-1);

            //Create workspace
            _workspaceId = CreateWorkspace.CreateWorkspaceAsync(_workspaceName, ConfigurationHelper.TEST_WORKSPACE_TEMPLATE_NAME, servicesManager, ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD).Result;
            dbContext    = helper.GetDBContext(_workspaceId);
            _client.APIOptions.WorkspaceID = _workspaceId;

            _rootFolderArtifactId = APIHelpers.GetRootFolderArtifactID(_client, _workspaceName);

            //Import Application containing script, fields, and choices
            Relativity.Test.Helpers.Application.ApplicationHelpers.ImportApplication(_client, _workspaceId, true, FilepathData);

            //Import custodians
            var custodians = GetCustodiansDatatable();

            var identityFieldArtifactId = GetArtifactIDOfCustodianField("Full Name", _workspaceId, _client);

            ImportAPIHelpers.ImportObjects(_workspaceId, "Custodian", identityFieldArtifactId, custodians, String.Empty);

            //Import Documents
            var documents = GetDocumentDataTable(_rootFolderArtifactId, _workspaceId);

            ImportAPIHelpers.CreateDocuments(_workspaceId, _rootFolderArtifactId, documents);
        }
コード例 #5
0
        public async Task SetupWorkspaceAudits(string baseTemplateName, string primaryServerName, string username, string password, string injectAuditDataQuery, IServicesMgr servicesManager)
        {
            // Setup
            var testWorkspaceName = "TestWorkspaceName";

            DataSetup.Setup();

            // Create Workspace
            var workspaceId = await CreateWorkspace.CreateWorkspaceAsync(testWorkspaceName, baseTemplateName, servicesManager, username, password);

            // Inject Audits by running SQL script against the workspace database
            using (var conn = await connectionFactory.GetWorkspaceConnectionAsync(workspaceId))
            {
                await conn.ExecuteAsync(
                    injectAuditDataQuery,
                    new
                {
                    workspace = workspaceId,
                    startHour = DateTime.UtcNow.AddDays(-7),
                    endHour   = DateTime.UtcNow,
                    suggestedExecutionTime = (int?)null,
                    usersPerHour           = 3,
                    minExecutionTime       = 1000,
                    maxExecutionTime       = 10000,
                    auditsPerHour          = 1000,
                    primaryServerName
                });
            }
        }
コード例 #6
0
        private int createTestWorkspace()
        {
            int workspaceID;

            using (var client = TestEnvironment.Instance.ServicesManager.CreateProxy <IRSAPIClient>(Relativity.API.ExecutionIdentity.System))
            {
                workspaceID = CreateWorkspace.Create(client, ConfigurationHelper.TEST_WORKSPACE_NAME, ConfigurationHelper.TEST_WORKSPACE_TEMPLATE_NAME);
            }
            driver.Navigate().Refresh();
            return(workspaceID);
        }
コード例 #7
0
        public void ExecuteCreateWorkspaceTest()
        {
            var activity = new CreateWorkspace();

            activity.LocalPath        = @"C:\TFSUpload";
            activity.ServerPath       = "$/Markus_Test/UploadTest2";
            activity.TFSCollectionUrl = new InArgument <Uri>(new LambdaValue <Uri>((env) => (new Uri("http://localhost:8080/tfs/DefaultCollection"))));
            activity.WorkspaceName    = "TestMethodWorkspace";
            activity.WorkspaceComment = "TestMethodWorkspace";
            var output = WorkflowInvoker.Invoke(activity);

            Assert.IsNotNull(output["Workspace"]);
        }
コード例 #8
0
        public Workspace CreateWorkspace(CreateWorkspace properties = null)
        {
            try
            {
                var result = AssistantRepository.CreateWorkspace(properties);

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error("AssistantService.CreateWorkspace failed", this, ex);
            }

            return(null);
        }
コード例 #9
0
        public Workspace CriarAreaTrabalho(String nome, String descricao, String linguagem)
        {
            Conectar();

            CreateWorkspace workspace = new CreateWorkspace()
            {
                Name        = nome,
                Description = descricao,
                Language    = linguagem
            };

            Workspace response = _assistant.CreateWorkspace(workspace);

            return(response);
        }
コード例 #10
0
        public void SetUp()
        {
            // Setup helper
            _helper = new TestHelper(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD);

            // Create new workspace to test in
            _workspaceId = CreateWorkspace.CreateWorkspaceAsync(ConfigurationHelper.TEST_WORKSPACE_NAME, ConfigurationHelper.TEST_WORKSPACE_TEMPLATE_NAME,
                                                                _helper.GetServicesManager(), ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD).Result;

            // Gather sql scripts to use for DAPI
            _sqlList = GatherSqlScripts();

            // Setup DapiHelper
            Sut = new DapiHelper(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD, ConfigurationHelper.SERVER_BINDING_TYPE, ConfigurationHelper.REST_SERVER_ADDRESS,
                                 _workspaceId, YamlFileName, YamlFileFullPath, DapiFullFilePath, _sqlList);
        }
コード例 #11
0
        public void Execute_TestFixtureSetup()
        {
            //Setup for testing
            //Create a new instance of the Test Helper

            var helper = Relativity.Test.Helpers.TestHelper.System();
            _servicesManager = helper.GetServicesManager();

            //create client
            _client = helper.GetServicesManager().GetProxy<IRSAPIClient>(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD);
            _objectManagerClient = helper.GetServicesManager().GetProxy<IObjectManager>(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD);
            //Get workspace ID of the workspace for Nserio or Create a workspace
            _workspaceId = GetWorkspaceId(_workspaceName, _objectManagerClient);
            if (_workspaceId == 0) //-- if no workspace found, create it
            {
                _workspaceId = CreateWorkspace.Create(_client, _workspaceName, _workspaceTemplateName);
                _workspaceCreatedByTest = true;
            }

            _client.APIOptions.WorkspaceID = _workspaceId;

            var path = GetLocalDocumentsFolderPath();

            //Import Application to the workspace
            //File path of the Test App
            string[] path1 = { path, "RA_Delimiter-Count-By-Saved-Search-Test-APP.rap" };
            string filepathTestApp = Path.Combine(path1);

            //File path of the application containing the actual script
            string[] path2 = { path, "RA_Delimiter-Count-By-Saved-Search.rap" };
            string filepathApp = Path.Combine(path2);


            //Importing the applications
            Relativity.Test.Helpers.Application.ApplicationHelpers.ImportApplication(_client, _workspaceId, true, filepathTestApp);
            Relativity.Test.Helpers.Application.ApplicationHelpers.ImportApplication(_client, _workspaceId, true, filepathApp);

            //set artifacttypeid
            _artifactTypeID = (int)ArtifactType.Document;

            //Import Documents to workspace
            ImportHelper.Import.ImportDocument(_workspaceId, path);
        }
コード例 #12
0
        public override IEnumerator RunTest()
        {
            LogSystem.InstallDefaultReactors();

            VcapCredentials vcapCredentials = new VcapCredentials();
            fsData          data            = null;

            string result = null;
            string credentialsFilepath = "../sdk-credentials/credentials.json";

            //  Load credentials file if it exists. If it doesn't exist, don't run the tests.
            if (File.Exists(credentialsFilepath))
            {
                result = File.ReadAllText(credentialsFilepath);
            }
            else
            {
                yield break;
            }

            //  Add in a parent object because Unity does not like to deserialize root level collection types.
            result = Utility.AddTopLevelObjectToJson(result, "VCAP_SERVICES");

            //  Convert json to fsResult
            fsResult r = fsJsonParser.Parse(result, out data);

            if (!r.Succeeded)
            {
                throw new WatsonException(r.FormattedMessages);
            }

            //  Convert fsResult to VcapCredentials
            object obj = vcapCredentials;

            r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
            if (!r.Succeeded)
            {
                throw new WatsonException(r.FormattedMessages);
            }

            //  Set credentials from imported credntials
            Credential credential = vcapCredentials.GetCredentialByname("assistant-sdk")[0].Credentials;

            _username    = credential.Username.ToString();
            _password    = credential.Password.ToString();
            _url         = credential.Url.ToString();
            _workspaceId = credential.WorkspaceId.ToString();

            //  Create credential and instantiate service
            Credentials credentials = new Credentials(_username, _password, _url);

            _service             = new Assistant(credentials);
            _service.VersionDate = _assistantVersionDate;

            //  List Workspaces
            _service.ListWorkspaces(OnListWorkspaces, OnFail);
            while (!_listWorkspacesTested)
            {
                yield return(null);
            }
            //  Create Workspace
            CreateWorkspace workspace = new CreateWorkspace()
            {
                Name           = _createdWorkspaceName,
                Description    = _createdWorkspaceDescription,
                Language       = _createdWorkspaceLanguage,
                LearningOptOut = true
            };

            _service.CreateWorkspace(OnCreateWorkspace, OnFail, workspace);
            while (!_createWorkspaceTested)
            {
                yield return(null);
            }
            //  Get Workspace
            _service.GetWorkspace(OnGetWorkspace, OnFail, _createdWorkspaceId);
            while (!_getWorkspaceTested)
            {
                yield return(null);
            }
            //  Update Workspace
            UpdateWorkspace updateWorkspace = new UpdateWorkspace()
            {
                Name        = _createdWorkspaceName + "-updated",
                Description = _createdWorkspaceDescription + "-updated",
                Language    = _createdWorkspaceLanguage
            };

            _service.UpdateWorkspace(OnUpdateWorkspace, OnFail, _createdWorkspaceId, updateWorkspace);
            while (!_updateWorkspaceTested)
            {
                yield return(null);
            }

            //  Message with customerID
            //  Create customData object
            Dictionary <string, object> customData = new Dictionary <string, object>();
            //  Create a dictionary of custom headers
            Dictionary <string, string> customHeaders = new Dictionary <string, string>();

            //  Add to the header dictionary
            customHeaders.Add("X-Watson-Metadata", "customer_id=" + _unitySdkTestCustomerID);
            //  Add the header dictionary to the custom data object
            customData.Add(Constants.String.CUSTOM_REQUEST_HEADERS, customHeaders);
            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("text", _inputString);
            MessageRequest messageRequest = new MessageRequest()
            {
                Input = input
            };

            _service.Message(OnMessage, OnFail, _workspaceId, messageRequest, null, customData);
            while (!_messageTested)
            {
                yield return(null);
            }
            _messageTested = false;

            input["text"] = _conversationString0;
            MessageRequest messageRequest0 = new MessageRequest()
            {
                Input   = input,
                Context = _context
            };

            _service.Message(OnMessage, OnFail, _workspaceId, messageRequest0);
            while (!_messageTested)
            {
                yield return(null);
            }
            _messageTested = false;

            input["text"] = _conversationString1;
            MessageRequest messageRequest1 = new MessageRequest()
            {
                Input   = input,
                Context = _context
            };

            _service.Message(OnMessage, OnFail, _workspaceId, messageRequest1);
            while (!_messageTested)
            {
                yield return(null);
            }
            _messageTested = false;

            input["text"] = _conversationString2;
            MessageRequest messageRequest2 = new MessageRequest()
            {
                Input   = input,
                Context = _context
            };

            _service.Message(OnMessage, OnFail, _workspaceId, messageRequest2);
            while (!_messageTested)
            {
                yield return(null);
            }

            //  List Intents
            _service.ListIntents(OnListIntents, OnFail, _createdWorkspaceId);
            while (!_listIntentsTested)
            {
                yield return(null);
            }
            //  Create Intent
            CreateIntent createIntent = new CreateIntent()
            {
                Intent      = _createdIntent,
                Description = _createdIntentDescription
            };

            _service.CreateIntent(OnCreateIntent, OnFail, _createdWorkspaceId, createIntent);
            while (!_createIntentTested)
            {
                yield return(null);
            }
            //  Get Intent
            _service.GetIntent(OnGetIntent, OnFail, _createdWorkspaceId, _createdIntent);
            while (!_getIntentTested)
            {
                yield return(null);
            }
            //  Update Intents
            string       updatedIntent            = _createdIntent + "-updated";
            string       updatedIntentDescription = _createdIntentDescription + "-updated";
            UpdateIntent updateIntent             = new UpdateIntent()
            {
                Intent      = updatedIntent,
                Description = updatedIntentDescription
            };

            _service.UpdateIntent(OnUpdateIntent, OnFail, _createdWorkspaceId, _createdIntent, updateIntent);
            while (!_updateIntentTested)
            {
                yield return(null);
            }

            //  List Examples
            _service.ListExamples(OnListExamples, OnFail, _createdWorkspaceId, updatedIntent);
            while (!_listExamplesTested)
            {
                yield return(null);
            }
            //  Create Examples
            CreateExample createExample = new CreateExample()
            {
                Text = _createdExample
            };

            _service.CreateExample(OnCreateExample, OnFail, _createdWorkspaceId, updatedIntent, createExample);
            while (!_createExampleTested)
            {
                yield return(null);
            }
            //  Get Example
            _service.GetExample(OnGetExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample);
            while (!_getExampleTested)
            {
                yield return(null);
            }
            //  Update Examples
            string        updatedExample = _createdExample + "-updated";
            UpdateExample updateExample  = new UpdateExample()
            {
                Text = updatedExample
            };

            _service.UpdateExample(OnUpdateExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample, updateExample);
            while (!_updateExampleTested)
            {
                yield return(null);
            }

            //  List Entities
            _service.ListEntities(OnListEntities, OnFail, _createdWorkspaceId);
            while (!_listEntitiesTested)
            {
                yield return(null);
            }
            //  Create Entities
            CreateEntity entity = new CreateEntity()
            {
                Entity      = _createdEntity,
                Description = _createdEntityDescription
            };

            _service.CreateEntity(OnCreateEntity, OnFail, _createdWorkspaceId, entity);
            while (!_createEntityTested)
            {
                yield return(null);
            }
            //  Get Entity
            _service.GetEntity(OnGetEntity, OnFail, _createdWorkspaceId, _createdEntity);
            while (!_getEntityTested)
            {
                yield return(null);
            }
            //  Update Entities
            string       updatedEntity            = _createdEntity + "-updated";
            string       updatedEntityDescription = _createdEntityDescription + "-updated";
            UpdateEntity updateEntity             = new UpdateEntity()
            {
                Entity      = updatedEntity,
                Description = updatedEntityDescription
            };

            _service.UpdateEntity(OnUpdateEntity, OnFail, _createdWorkspaceId, _createdEntity, updateEntity);
            while (!_updateEntityTested)
            {
                yield return(null);
            }

            //  List Values
            _service.ListValues(OnListValues, OnFail, _createdWorkspaceId, updatedEntity);
            while (!_listValuesTested)
            {
                yield return(null);
            }
            //  Create Values
            CreateValue value = new CreateValue()
            {
                Value = _createdValue
            };

            _service.CreateValue(OnCreateValue, OnFail, _createdWorkspaceId, updatedEntity, value);
            while (!_createValueTested)
            {
                yield return(null);
            }
            //  Get Value
            _service.GetValue(OnGetValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue);
            while (!_getValueTested)
            {
                yield return(null);
            }
            //  Update Values
            string      updatedValue = _createdValue + "-updated";
            UpdateValue updateValue  = new UpdateValue()
            {
                Value = updatedValue
            };

            _service.UpdateValue(OnUpdateValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue, updateValue);
            while (!_updateValueTested)
            {
                yield return(null);
            }

            //  List Synonyms
            _service.ListSynonyms(OnListSynonyms, OnFail, _createdWorkspaceId, updatedEntity, updatedValue);
            while (!_listSynonymsTested)
            {
                yield return(null);
            }
            //  Create Synonyms
            CreateSynonym synonym = new CreateSynonym()
            {
                Synonym = _createdSynonym
            };

            _service.CreateSynonym(OnCreateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, synonym);
            while (!_createSynonymTested)
            {
                yield return(null);
            }
            //  Get Synonym
            _service.GetSynonym(OnGetSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym);
            while (!_getSynonymTested)
            {
                yield return(null);
            }
            //  Update Synonyms
            string        updatedSynonym = _createdSynonym + "-updated";
            UpdateSynonym updateSynonym  = new UpdateSynonym()
            {
                Synonym = updatedSynonym
            };

            _service.UpdateSynonym(OnUpdateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym, updateSynonym);
            while (!_updateSynonymTested)
            {
                yield return(null);
            }

            //  List Dialog Nodes
            _service.ListDialogNodes(OnListDialogNodes, OnFail, _createdWorkspaceId);
            while (!_listDialogNodesTested)
            {
                yield return(null);
            }
            //  Create Dialog Nodes
            CreateDialogNode createDialogNode = new CreateDialogNode()
            {
                DialogNode  = _dialogNodeName,
                Description = _dialogNodeDesc
            };

            _service.CreateDialogNode(OnCreateDialogNode, OnFail, _createdWorkspaceId, createDialogNode);
            while (!_createDialogNodeTested)
            {
                yield return(null);
            }
            //  Get Dialog Node
            _service.GetDialogNode(OnGetDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName);
            while (!_getDialogNodeTested)
            {
                yield return(null);
            }
            //  Update Dialog Nodes
            string           updatedDialogNodeName        = _dialogNodeName + "_updated";
            string           updatedDialogNodeDescription = _dialogNodeDesc + "_updated";
            UpdateDialogNode updateDialogNode             = new UpdateDialogNode()
            {
                DialogNode  = updatedDialogNodeName,
                Description = updatedDialogNodeDescription
            };

            _service.UpdateDialogNode(OnUpdateDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName, updateDialogNode);
            while (!_updateDialogNodeTested)
            {
                yield return(null);
            }

            //  List Logs In Workspace
            _service.ListLogs(OnListLogs, OnFail, _createdWorkspaceId);
            while (!_listLogsInWorkspaceTested)
            {
                yield return(null);
            }
            //  List All Logs
            var filter = "(language::en,request.context.metadata.deployment::deployment_1)";

            _service.ListAllLogs(OnListAllLogs, OnFail, filter);
            while (!_listAllLogsTested)
            {
                yield return(null);
            }

            //  List Counterexamples
            _service.ListCounterexamples(OnListCounterexamples, OnFail, _createdWorkspaceId);
            while (!_listCounterexamplesTested)
            {
                yield return(null);
            }
            //  Create Counterexamples
            CreateCounterexample example = new CreateCounterexample()
            {
                Text = _createdCounterExampleText
            };

            _service.CreateCounterexample(OnCreateCounterexample, OnFail, _createdWorkspaceId, example);
            while (!_createCounterexampleTested)
            {
                yield return(null);
            }
            //  Get Counterexample
            _service.GetCounterexample(OnGetCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText);
            while (!_getCounterexampleTested)
            {
                yield return(null);
            }
            //  Update Counterexamples
            string updatedCounterExampleText          = _createdCounterExampleText + "-updated";
            UpdateCounterexample updateCounterExample = new UpdateCounterexample()
            {
                Text = updatedCounterExampleText
            };

            _service.UpdateCounterexample(OnUpdateCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText, updateCounterExample);
            while (!_updateCounterexampleTested)
            {
                yield return(null);
            }

            //  Delete Counterexample
            _service.DeleteCounterexample(OnDeleteCounterexample, OnFail, _createdWorkspaceId, updatedCounterExampleText);
            while (!_deleteCounterexampleTested)
            {
                yield return(null);
            }
            //  Delete Dialog Node
            _service.DeleteDialogNode(OnDeleteDialogNode, OnFail, _createdWorkspaceId, updatedDialogNodeName);
            while (!_deleteDialogNodeTested)
            {
                yield return(null);
            }
            //  Delete Synonym
            _service.DeleteSynonym(OnDeleteSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, updatedSynonym);
            while (!_deleteSynonymTested)
            {
                yield return(null);
            }
            //  Delete Value
            _service.DeleteValue(OnDeleteValue, OnFail, _createdWorkspaceId, updatedEntity, updatedValue);
            while (!_deleteValueTested)
            {
                yield return(null);
            }
            //  Delete Entity
            _service.DeleteEntity(OnDeleteEntity, OnFail, _createdWorkspaceId, updatedEntity);
            while (!_deleteEntityTested)
            {
                yield return(null);
            }
            //  Delete Example
            _service.DeleteExample(OnDeleteExample, OnFail, _createdWorkspaceId, updatedIntent, updatedExample);
            while (!_deleteExampleTested)
            {
                yield return(null);
            }
            //  Delete Intent
            _service.DeleteIntent(OnDeleteIntent, OnFail, _createdWorkspaceId, updatedIntent);
            while (!_deleteIntentTested)
            {
                yield return(null);
            }
            //  Delete Workspace
            _service.DeleteWorkspace(OnDeleteWorkspace, OnFail, _createdWorkspaceId);
            while (!_deleteWorkspaceTested)
            {
                yield return(null);
            }
            //  Delete User Data
            _service.DeleteUserData(OnDeleteUserData, OnFail, _unitySdkTestCustomerID);
            while (!_deleteUserDataTested)
            {
                yield return(null);
            }

            Log.Debug("TestAssistant.RunTest()", "Assistant examples complete.");

            yield break;
        }
コード例 #13
0
    private IEnumerator Examples()
    {
        //  List Workspaces
        _service.ListWorkspaces(OnListWorkspaces, OnFail);
        while (!_listWorkspacesTested)
        {
            yield return(null);
        }
        //  Create Workspace
        CreateWorkspace workspace = new CreateWorkspace()
        {
            Name           = _createdWorkspaceName,
            Description    = _createdWorkspaceDescription,
            Language       = _createdWorkspaceLanguage,
            LearningOptOut = true
        };

        _service.CreateWorkspace(OnCreateWorkspace, OnFail, workspace);
        while (!_createWorkspaceTested)
        {
            yield return(null);
        }
        //  Get Workspace
        _service.GetWorkspace(OnGetWorkspace, OnFail, _createdWorkspaceId);
        while (!_getWorkspaceTested)
        {
            yield return(null);
        }
        //  Update Workspace
        UpdateWorkspace updateWorkspace = new UpdateWorkspace()
        {
            Name        = _createdWorkspaceName + "-updated",
            Description = _createdWorkspaceDescription + "-updated",
            Language    = _createdWorkspaceLanguage
        };

        _service.UpdateWorkspace(OnUpdateWorkspace, OnFail, _createdWorkspaceId, updateWorkspace);
        while (!_updateWorkspaceTested)
        {
            yield return(null);
        }

        //  Message
        Dictionary <string, object> input = new Dictionary <string, object>();

        input.Add("text", _inputString);
        MessageRequest messageRequest = new MessageRequest()
        {
            Input = input
        };

        _service.Message(OnMessage, OnFail, _workspaceId, messageRequest);
        while (!_messageTested)
        {
            yield return(null);
        }
        _messageTested = false;

        input["text"] = _conversationString0;
        MessageRequest messageRequest0 = new MessageRequest()
        {
            Input   = input,
            Context = _context
        };

        _service.Message(OnMessage, OnFail, _workspaceId, messageRequest0);
        while (!_messageTested)
        {
            yield return(null);
        }
        _messageTested = false;

        input["text"] = _conversationString1;
        MessageRequest messageRequest1 = new MessageRequest()
        {
            Input   = input,
            Context = _context
        };

        _service.Message(OnMessage, OnFail, _workspaceId, messageRequest1);
        while (!_messageTested)
        {
            yield return(null);
        }
        _messageTested = false;

        input["text"] = _conversationString2;
        MessageRequest messageRequest2 = new MessageRequest()
        {
            Input   = input,
            Context = _context
        };

        _service.Message(OnMessage, OnFail, _workspaceId, messageRequest2);
        while (!_messageTested)
        {
            yield return(null);
        }

        //  List Intents
        _service.ListIntents(OnListIntents, OnFail, _createdWorkspaceId);
        while (!_listIntentsTested)
        {
            yield return(null);
        }
        //  Create Intent
        CreateIntent createIntent = new CreateIntent()
        {
            Intent      = _createdIntent,
            Description = _createdIntentDescription
        };

        _service.CreateIntent(OnCreateIntent, OnFail, _createdWorkspaceId, createIntent);
        while (!_createIntentTested)
        {
            yield return(null);
        }
        //  Get Intent
        _service.GetIntent(OnGetIntent, OnFail, _createdWorkspaceId, _createdIntent);
        while (!_getIntentTested)
        {
            yield return(null);
        }
        //  Update Intents
        string       updatedIntent            = _createdIntent + "-updated";
        string       updatedIntentDescription = _createdIntentDescription + "-updated";
        UpdateIntent updateIntent             = new UpdateIntent()
        {
            Intent      = updatedIntent,
            Description = updatedIntentDescription
        };

        _service.UpdateIntent(OnUpdateIntent, OnFail, _createdWorkspaceId, _createdIntent, updateIntent);
        while (!_updateIntentTested)
        {
            yield return(null);
        }

        //  List Examples
        _service.ListExamples(OnListExamples, OnFail, _createdWorkspaceId, updatedIntent);
        while (!_listExamplesTested)
        {
            yield return(null);
        }
        //  Create Examples
        CreateExample createExample = new CreateExample()
        {
            Text = _createdExample
        };

        _service.CreateExample(OnCreateExample, OnFail, _createdWorkspaceId, updatedIntent, createExample);
        while (!_createExampleTested)
        {
            yield return(null);
        }
        //  Get Example
        _service.GetExample(OnGetExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample);
        while (!_getExampleTested)
        {
            yield return(null);
        }
        //  Update Examples
        string        updatedExample = _createdExample + "-updated";
        UpdateExample updateExample  = new UpdateExample()
        {
            Text = updatedExample
        };

        _service.UpdateExample(OnUpdateExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample, updateExample);
        while (!_updateExampleTested)
        {
            yield return(null);
        }

        //  List Entities
        _service.ListEntities(OnListEntities, OnFail, _createdWorkspaceId);
        while (!_listEntitiesTested)
        {
            yield return(null);
        }
        //  Create Entities
        CreateEntity entity = new CreateEntity()
        {
            Entity      = _createdEntity,
            Description = _createdEntityDescription
        };

        _service.CreateEntity(OnCreateEntity, OnFail, _createdWorkspaceId, entity);
        while (!_createEntityTested)
        {
            yield return(null);
        }
        //  Get Entity
        _service.GetEntity(OnGetEntity, OnFail, _createdWorkspaceId, _createdEntity);
        while (!_getEntityTested)
        {
            yield return(null);
        }
        //  Update Entities
        string       updatedEntity            = _createdEntity + "-updated";
        string       updatedEntityDescription = _createdEntityDescription + "-updated";
        UpdateEntity updateEntity             = new UpdateEntity()
        {
            Entity      = updatedEntity,
            Description = updatedEntityDescription
        };

        _service.UpdateEntity(OnUpdateEntity, OnFail, _createdWorkspaceId, _createdEntity, updateEntity);
        while (!_updateEntityTested)
        {
            yield return(null);
        }

        //  List Values
        _service.ListValues(OnListValues, OnFail, _createdWorkspaceId, updatedEntity);
        while (!_listValuesTested)
        {
            yield return(null);
        }
        //  Create Values
        CreateValue value = new CreateValue()
        {
            Value = _createdValue
        };

        _service.CreateValue(OnCreateValue, OnFail, _createdWorkspaceId, updatedEntity, value);
        while (!_createValueTested)
        {
            yield return(null);
        }
        //  Get Value
        _service.GetValue(OnGetValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue);
        while (!_getValueTested)
        {
            yield return(null);
        }
        //  Update Values
        string      updatedValue = _createdValue + "-updated";
        UpdateValue updateValue  = new UpdateValue()
        {
            Value = updatedValue
        };

        _service.UpdateValue(OnUpdateValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue, updateValue);
        while (!_updateValueTested)
        {
            yield return(null);
        }

        //  List Synonyms
        _service.ListSynonyms(OnListSynonyms, OnFail, _createdWorkspaceId, updatedEntity, updatedValue);
        while (!_listSynonymsTested)
        {
            yield return(null);
        }
        //  Create Synonyms
        CreateSynonym synonym = new CreateSynonym()
        {
            Synonym = _createdSynonym
        };

        _service.CreateSynonym(OnCreateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, synonym);
        while (!_createSynonymTested)
        {
            yield return(null);
        }
        //  Get Synonym
        _service.GetSynonym(OnGetSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym);
        while (!_getSynonymTested)
        {
            yield return(null);
        }
        //  Update Synonyms
        string        updatedSynonym = _createdSynonym + "-updated";
        UpdateSynonym updateSynonym  = new UpdateSynonym()
        {
            Synonym = updatedSynonym
        };

        _service.UpdateSynonym(OnUpdateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym, updateSynonym);
        while (!_updateSynonymTested)
        {
            yield return(null);
        }

        //  List Dialog Nodes
        _service.ListDialogNodes(OnListDialogNodes, OnFail, _createdWorkspaceId);
        while (!_listDialogNodesTested)
        {
            yield return(null);
        }
        //  Create Dialog Nodes
        CreateDialogNode createDialogNode = new CreateDialogNode()
        {
            DialogNode  = _dialogNodeName,
            Description = _dialogNodeDesc
        };

        _service.CreateDialogNode(OnCreateDialogNode, OnFail, _createdWorkspaceId, createDialogNode);
        while (!_createDialogNodeTested)
        {
            yield return(null);
        }
        //  Get Dialog Node
        _service.GetDialogNode(OnGetDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName);
        while (!_getDialogNodeTested)
        {
            yield return(null);
        }
        //  Update Dialog Nodes
        string           updatedDialogNodeName        = _dialogNodeName + "_updated";
        string           updatedDialogNodeDescription = _dialogNodeDesc + "_updated";
        UpdateDialogNode updateDialogNode             = new UpdateDialogNode()
        {
            DialogNode  = updatedDialogNodeName,
            Description = updatedDialogNodeDescription
        };

        _service.UpdateDialogNode(OnUpdateDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName, updateDialogNode);
        while (!_updateDialogNodeTested)
        {
            yield return(null);
        }

        //  List Logs In Workspace
        _service.ListLogs(OnListLogs, OnFail, _createdWorkspaceId);
        while (!_listLogsInWorkspaceTested)
        {
            yield return(null);
        }
        //  List All Logs
        var filter = "(language::en,request.context.metadata.deployment::deployment_1)";

        _service.ListAllLogs(OnListAllLogs, OnFail, filter);
        while (!_listAllLogsTested)
        {
            yield return(null);
        }

        //  List Counterexamples
        _service.ListCounterexamples(OnListCounterexamples, OnFail, _createdWorkspaceId);
        while (!_listCounterexamplesTested)
        {
            yield return(null);
        }
        //  Create Counterexamples
        CreateCounterexample example = new CreateCounterexample()
        {
            Text = _createdCounterExampleText
        };

        _service.CreateCounterexample(OnCreateCounterexample, OnFail, _createdWorkspaceId, example);
        while (!_createCounterexampleTested)
        {
            yield return(null);
        }
        //  Get Counterexample
        _service.GetCounterexample(OnGetCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText);
        while (!_getCounterexampleTested)
        {
            yield return(null);
        }
        //  Update Counterexamples
        string updatedCounterExampleText          = _createdCounterExampleText + "-updated";
        UpdateCounterexample updateCounterExample = new UpdateCounterexample()
        {
            Text = updatedCounterExampleText
        };

        _service.UpdateCounterexample(OnUpdateCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText, updateCounterExample);
        while (!_updateCounterexampleTested)
        {
            yield return(null);
        }

        //  Delete Counterexample
        _service.DeleteCounterexample(OnDeleteCounterexample, OnFail, _createdWorkspaceId, updatedCounterExampleText);
        while (!_deleteCounterexampleTested)
        {
            yield return(null);
        }
        //  Delete Dialog Node
        _service.DeleteDialogNode(OnDeleteDialogNode, OnFail, _createdWorkspaceId, updatedDialogNodeName);
        while (!_deleteDialogNodeTested)
        {
            yield return(null);
        }
        //  Delete Synonym
        _service.DeleteSynonym(OnDeleteSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, updatedSynonym);
        while (!_deleteSynonymTested)
        {
            yield return(null);
        }
        //  Delete Value
        _service.DeleteValue(OnDeleteValue, OnFail, _createdWorkspaceId, updatedEntity, updatedValue);
        while (!_deleteValueTested)
        {
            yield return(null);
        }
        //  Delete Entity
        _service.DeleteEntity(OnDeleteEntity, OnFail, _createdWorkspaceId, updatedEntity);
        while (!_deleteEntityTested)
        {
            yield return(null);
        }
        //  Delete Example
        _service.DeleteExample(OnDeleteExample, OnFail, _createdWorkspaceId, updatedIntent, updatedExample);
        while (!_deleteExampleTested)
        {
            yield return(null);
        }
        //  Delete Intent
        _service.DeleteIntent(OnDeleteIntent, OnFail, _createdWorkspaceId, updatedIntent);
        while (!_deleteIntentTested)
        {
            yield return(null);
        }
        //  Delete Workspace
        _service.DeleteWorkspace(OnDeleteWorkspace, OnFail, _createdWorkspaceId);
        while (!_deleteWorkspaceTested)
        {
            yield return(null);
        }

        Log.Debug("TestAssistant.RunTest()", "Assistant examples complete.");

        yield break;
    }
コード例 #14
0
        public override IEnumerator RunTest()
        {
            LogSystem.InstallDefaultReactors();

            VcapCredentials vcapCredentials = new VcapCredentials();
            fsData          data            = null;

            string result = null;

            var vcapUrl      = Environment.GetEnvironmentVariable("VCAP_URL");
            var vcapUsername = Environment.GetEnvironmentVariable("VCAP_USERNAME");
            var vcapPassword = Environment.GetEnvironmentVariable("VCAP_PASSWORD");

            using (SimpleGet simpleGet = new SimpleGet(vcapUrl, vcapUsername, vcapPassword))
            {
                while (!simpleGet.IsComplete)
                {
                    yield return(null);
                }

                result = simpleGet.Result;
            }

            //  Add in a parent object because Unity does not like to deserialize root level collection types.
            result = Utility.AddTopLevelObjectToJson(result, "VCAP_SERVICES");

            //  Convert json to fsResult
            fsResult r = fsJsonParser.Parse(result, out data);

            if (!r.Succeeded)
            {
                throw new WatsonException(r.FormattedMessages);
            }

            //  Convert fsResult to VcapCredentials
            object obj = vcapCredentials;

            r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
            if (!r.Succeeded)
            {
                throw new WatsonException(r.FormattedMessages);
            }

            //  Set credentials from imported credntials
            Credential credential = vcapCredentials.VCAP_SERVICES["conversation"];

            _username = credential.Username.ToString();
            _password = credential.Password.ToString();
            _url      = credential.Url.ToString();
            //_workspaceId = credential.WorkspaceId.ToString();

            //  Create credential and instantiate service
            Credentials credentials = new Credentials(_username, _password, _url);

            _service             = new Assistant(credentials);
            _service.VersionDate = _assistantVersionDate;

            //  List Workspaces
            _service.ListWorkspaces(OnListWorkspaces, OnFail);
            while (!_listWorkspacesTested)
            {
                yield return(null);
            }
            //  Create Workspace
            CreateWorkspace workspace = new CreateWorkspace()
            {
                Name           = _createdWorkspaceName,
                Description    = _createdWorkspaceDescription,
                Language       = _createdWorkspaceLanguage,
                LearningOptOut = true
            };

            _service.CreateWorkspace(OnCreateWorkspace, OnFail, workspace);
            while (!_createWorkspaceTested)
            {
                yield return(null);
            }
            //  Get Workspace
            _service.GetWorkspace(OnGetWorkspace, OnFail, _createdWorkspaceId);
            while (!_getWorkspaceTested)
            {
                yield return(null);
            }
            //  Update Workspace
            UpdateWorkspace updateWorkspace = new UpdateWorkspace()
            {
                Name        = _createdWorkspaceName + "-updated",
                Description = _createdWorkspaceDescription + "-updated",
                Language    = _createdWorkspaceLanguage
            };

            _service.UpdateWorkspace(OnUpdateWorkspace, OnFail, _createdWorkspaceId, updateWorkspace);
            while (!_updateWorkspaceTested)
            {
                yield return(null);
            }

            //  Message
            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("text", _inputString);
            MessageRequest messageRequest = new MessageRequest()
            {
                Input            = input,
                AlternateIntents = true
            };

            _service.Message(OnMessage, OnFail, _workspaceId, messageRequest);
            while (!_messageTested)
            {
                yield return(null);
            }

            //  List Intents
            _service.ListIntents(OnListIntents, OnFail, _createdWorkspaceId);
            while (!_listIntentsTested)
            {
                yield return(null);
            }
            //  Create Intent
            CreateIntent createIntent = new CreateIntent()
            {
                Intent      = _createdIntent,
                Description = _createdIntentDescription
            };

            _service.CreateIntent(OnCreateIntent, OnFail, _createdWorkspaceId, createIntent);
            while (!_createIntentTested)
            {
                yield return(null);
            }
            //  Get Intent
            _service.GetIntent(OnGetIntent, OnFail, _createdWorkspaceId, _createdIntent);
            while (!_getIntentTested)
            {
                yield return(null);
            }
            //  Update Intents
            string       updatedIntent            = _createdIntent + "-updated";
            string       updatedIntentDescription = _createdIntentDescription + "-updated";
            UpdateIntent updateIntent             = new UpdateIntent()
            {
                Intent      = updatedIntent,
                Description = updatedIntentDescription
            };

            _service.UpdateIntent(OnUpdateIntent, OnFail, _createdWorkspaceId, _createdIntent, updateIntent);
            while (!_updateIntentTested)
            {
                yield return(null);
            }

            //  List Examples
            _service.ListExamples(OnListExamples, OnFail, _createdWorkspaceId, updatedIntent);
            while (!_listExamplesTested)
            {
                yield return(null);
            }
            //  Create Examples
            CreateExample createExample = new CreateExample()
            {
                Text = _createdExample
            };

            _service.CreateExample(OnCreateExample, OnFail, _createdWorkspaceId, updatedIntent, createExample);
            while (!_createExampleTested)
            {
                yield return(null);
            }
            //  Get Example
            _service.GetExample(OnGetExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample);
            while (!_getExampleTested)
            {
                yield return(null);
            }
            //  Update Examples
            string        updatedExample = _createdExample + "-updated";
            UpdateExample updateExample  = new UpdateExample()
            {
                Text = updatedExample
            };

            _service.UpdateExample(OnUpdateExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample, updateExample);
            while (!_updateExampleTested)
            {
                yield return(null);
            }

            //  List Entities
            _service.ListEntities(OnListEntities, OnFail, _createdWorkspaceId);
            while (!_listEntitiesTested)
            {
                yield return(null);
            }
            //  Create Entities
            CreateEntity entity = new CreateEntity()
            {
                Entity      = _createdEntity,
                Description = _createdEntityDescription
            };

            _service.CreateEntity(OnCreateEntity, OnFail, _createdWorkspaceId, entity);
            while (!_createEntityTested)
            {
                yield return(null);
            }
            //  Get Entity
            _service.GetEntity(OnGetEntity, OnFail, _createdWorkspaceId, _createdEntity);
            while (!_getEntityTested)
            {
                yield return(null);
            }
            //  Update Entities
            string       updatedEntity            = _createdEntity + "-updated";
            string       updatedEntityDescription = _createdEntityDescription + "-updated";
            UpdateEntity updateEntity             = new UpdateEntity()
            {
                Entity      = updatedEntity,
                Description = updatedEntityDescription
            };

            _service.UpdateEntity(OnUpdateEntity, OnFail, _createdWorkspaceId, _createdEntity, updateEntity);
            while (!_updateEntityTested)
            {
                yield return(null);
            }

            //  List Values
            _service.ListValues(OnListValues, OnFail, _createdWorkspaceId, updatedEntity);
            while (!_listValuesTested)
            {
                yield return(null);
            }
            //  Create Values
            CreateValue value = new CreateValue()
            {
                Value = _createdValue
            };

            _service.CreateValue(OnCreateValue, OnFail, _createdWorkspaceId, updatedEntity, value);
            while (!_createValueTested)
            {
                yield return(null);
            }
            //  Get Value
            _service.GetValue(OnGetValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue);
            while (!_getValueTested)
            {
                yield return(null);
            }
            //  Update Values
            string      updatedValue = _createdValue + "-updated";
            UpdateValue updateValue  = new UpdateValue()
            {
                Value = updatedValue
            };

            _service.UpdateValue(OnUpdateValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue, updateValue);
            while (!_updateValueTested)
            {
                yield return(null);
            }

            //  List Synonyms
            _service.ListSynonyms(OnListSynonyms, OnFail, _createdWorkspaceId, updatedEntity, updatedValue);
            while (!_listSynonymsTested)
            {
                yield return(null);
            }
            //  Create Synonyms
            CreateSynonym synonym = new CreateSynonym()
            {
                Synonym = _createdSynonym
            };

            _service.CreateSynonym(OnCreateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, synonym);
            while (!_createSynonymTested)
            {
                yield return(null);
            }
            //  Get Synonym
            _service.GetSynonym(OnGetSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym);
            while (!_getSynonymTested)
            {
                yield return(null);
            }
            //  Update Synonyms
            string        updatedSynonym = _createdSynonym + "-updated";
            UpdateSynonym updateSynonym  = new UpdateSynonym()
            {
                Synonym = updatedSynonym
            };

            _service.UpdateSynonym(OnUpdateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym, updateSynonym);
            while (!_updateSynonymTested)
            {
                yield return(null);
            }

            //  List Dialog Nodes
            _service.ListDialogNodes(OnListDialogNodes, OnFail, _createdWorkspaceId);
            while (!_listDialogNodesTested)
            {
                yield return(null);
            }
            //  Create Dialog Nodes
            CreateDialogNode createDialogNode = new CreateDialogNode()
            {
                DialogNode  = _dialogNodeName,
                Description = _dialogNodeDesc
            };

            _service.CreateDialogNode(OnCreateDialogNode, OnFail, _createdWorkspaceId, createDialogNode);
            while (!_createDialogNodeTested)
            {
                yield return(null);
            }
            //  Get Dialog Node
            _service.GetDialogNode(OnGetDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName);
            while (!_getDialogNodeTested)
            {
                yield return(null);
            }
            //  Update Dialog Nodes
            string           updatedDialogNodeName        = _dialogNodeName + "_updated";
            string           updatedDialogNodeDescription = _dialogNodeDesc + "_updated";
            UpdateDialogNode updateDialogNode             = new UpdateDialogNode()
            {
                DialogNode  = updatedDialogNodeName,
                Description = updatedDialogNodeDescription
            };

            _service.UpdateDialogNode(OnUpdateDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName, updateDialogNode);
            while (!_updateDialogNodeTested)
            {
                yield return(null);
            }

            //  List Logs In Workspace
            _service.ListLogs(OnListLogs, OnFail, _createdWorkspaceId);
            while (!_listLogsInWorkspaceTested)
            {
                yield return(null);
            }
            //  List All Logs
            var filter = "(language::en,request.context.metadata.deployment::deployment_1)";

            _service.ListAllLogs(OnListAllLogs, OnFail, filter);
            while (!_listAllLogsTested)
            {
                yield return(null);
            }

            //  List Counterexamples
            _service.ListCounterexamples(OnListCounterexamples, OnFail, _createdWorkspaceId);
            while (!_listCounterexamplesTested)
            {
                yield return(null);
            }
            //  Create Counterexamples
            CreateCounterexample example = new CreateCounterexample()
            {
                Text = _createdCounterExampleText
            };

            _service.CreateCounterexample(OnCreateCounterexample, OnFail, _createdWorkspaceId, example);
            while (!_createCounterexampleTested)
            {
                yield return(null);
            }
            //  Get Counterexample
            _service.GetCounterexample(OnGetCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText);
            while (!_getCounterexampleTested)
            {
                yield return(null);
            }
            //  Update Counterexamples
            string updatedCounterExampleText          = _createdCounterExampleText + "-updated";
            UpdateCounterexample updateCounterExample = new UpdateCounterexample()
            {
                Text = updatedCounterExampleText
            };

            _service.UpdateCounterexample(OnUpdateCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText, updateCounterExample);
            while (!_updateCounterexampleTested)
            {
                yield return(null);
            }

            //  Delete Counterexample
            _service.DeleteCounterexample(OnDeleteCounterexample, OnFail, _createdWorkspaceId, updatedCounterExampleText);
            while (!_deleteCounterexampleTested)
            {
                yield return(null);
            }
            //  Delete Dialog Node
            _service.DeleteDialogNode(OnDeleteDialogNode, OnFail, _createdWorkspaceId, updatedDialogNodeName);
            while (!_deleteDialogNodeTested)
            {
                yield return(null);
            }
            //  Delete Synonym
            _service.DeleteSynonym(OnDeleteSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, updatedSynonym);
            while (!_deleteSynonymTested)
            {
                yield return(null);
            }
            //  Delete Value
            _service.DeleteValue(OnDeleteValue, OnFail, _createdWorkspaceId, updatedEntity, updatedValue);
            while (!_deleteValueTested)
            {
                yield return(null);
            }
            //  Delete Entity
            _service.DeleteEntity(OnDeleteEntity, OnFail, _createdWorkspaceId, updatedEntity);
            while (!_deleteEntityTested)
            {
                yield return(null);
            }
            //  Delete Example
            _service.DeleteExample(OnDeleteExample, OnFail, _createdWorkspaceId, updatedIntent, updatedExample);
            while (!_deleteExampleTested)
            {
                yield return(null);
            }
            //  Delete Intent
            _service.DeleteIntent(OnDeleteIntent, OnFail, _createdWorkspaceId, updatedIntent);
            while (!_deleteIntentTested)
            {
                yield return(null);
            }
            //  Delete Workspace
            _service.DeleteWorkspace(OnDeleteWorkspace, OnFail, _createdWorkspaceId);
            while (!_deleteWorkspaceTested)
            {
                yield return(null);
            }

            Log.Debug("TestAssistant.RunTest()", "Assistant examples complete.");

            yield break;
        }
コード例 #15
0
        public void Execute_TestFixtureSetup()
        {
            try
            {
                //Start of test and setup
                Console.WriteLine("Test START.....");
                Console.WriteLine("Enter Test Fixture Setup.....");
                var helper = new TestHelper();

                //Setup for testing
                Console.WriteLine("Creating Test Helper Services Manager based on App.Config file settings.");
                _servicesManager = helper.GetServicesManager();
                Console.WriteLine("Services Manager Created.");

                Console.WriteLine("Creating workspace.....");
                if (!_debug)
                {
                    _workspaceId =
                        CreateWorkspace.CreateWorkspaceAsync(_workspaceName,
                                                             ConfigurationHelper.TEST_WORKSPACE_TEMPLATE_NAME, _servicesManager, ConfigurationHelper.ADMIN_USERNAME,
                                                             ConfigurationHelper.DEFAULT_PASSWORD).Result;
                    Console.WriteLine($"Workspace created [WorkspaceArtifactId= {_workspaceId}].....");
                }
                else
                {
                    //must point _workspaceId = valid workspace with application already installed
                    _workspaceId = _debugWorkspaceId;
                    Console.WriteLine($"Using existing workspace [WorkspaceArtifactId= {_workspaceId}].....");
                }


                Console.WriteLine("Creating RSAPI and Service Factory.....");
                try
                {
                    _eddsDbContext = helper.GetDBContext(-1);
                    _dbContext     = helper.GetDBContext(_workspaceId);

                    //create client
                    _client = _servicesManager.GetProxy <IRSAPIClient>(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD);

                    LogStart("Application Import");
                    if (!_debug)
                    {
                        //Import Application
                        Relativity.Test.Helpers.Application.ApplicationHelpers.ImportApplication(_client, _workspaceId, true, _applicationFilePath, _applicationName);
                        LogEnd("Application Import");
                    }
                    else
                    {
                        Console.WriteLine($"Using existing application");
                    }



                    _client.APIOptions.WorkspaceID = _workspaceId;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error encountered while creating new RSAPI Client and/or Service Proxy.", ex);
                }
                finally
                {
                    Console.WriteLine("Created RSAPI and Service Factory.....");
                }

                Console.WriteLine("Creating TestObject Helper.");
                //1 retry setting because I want to know if it fails quickly while debugging, may bump up for production
                _testObjectHelper = new TestObjectHelper(_servicesManager, _workspaceId, 1);
                Console.WriteLine("TestObject Helper Created.");
            }
            catch (Exception ex)
            {
                throw new Exception("Error encountered in Test Setup.", ex);
            }
            finally
            {
                Console.WriteLine("Exit Test Fixture Setup.....");
            }
        }
コード例 #16
0
        public void CreateWorkspace()
        {
            #region worskpace

            CreateWorkspace workspace = new CreateWorkspace()
            {
                Name = "Test SDK",
                Description = "Test Conversation SDK",
                Language = "en",
                Metadata = new object() { },
                CounterExamples = new List<CreateExample>()
               {
                   new CreateExample()
                   {
                       Text = "How to increase revenue"
                   }
               },
                DialogNodes = new List<CreateDialogNode>()
               {
                   new CreateDialogNode()
                   {
                       DialogNode = "node_2",
                       Description = null,
                       Conditions = null,
                       Parent = "node_1",
                       PreviousSibling = null,
                       Output = new DialogNodeOutput()
                       {
                           Text = "But now... Back to business"
                       },
                       Context = null,
                       Metadata = new object() { },
                       GoTo = null
                   },
                   new CreateDialogNode()
                   {
                       DialogNode = "node_1",
                       Description = null,
                       Conditions = "revenue",
                       Parent = null,
                       PreviousSibling = null,
                       Output = new DialogNodeOutput()
                       {
                           Text = "ok.. you have been putting a few pounds lately, so I recommend you go to the Green Bowl for a salad - it has 5 star rating on yelp and I recommend the cesar salad for \\$9.75. :-)"
                       },
                       Context = null,
                       Metadata = new object() { },
                       GoTo = new DialogNodeGoTo()
                       {
                           Return = true,
                           Selector = "body",
                           DialogNode = "node_2"
                       }
                   }
               },
                Entities = new List<CreateEntity>()
               {
                   new CreateEntity()
                   {
                       Entity = "Metrics",
                       Description = null,
                       Source = null,
                       OpenList = false,
                       Type = null,
                       Values = new List<CreateValue>()
                       {
                           new CreateValue()
                           {
                               Value = "Market Share",
                               Metadata = new object() { },
                               Synonyms = new List<string>() {"closing the gap", "ground", "share"}
                           },
                           new CreateValue()
                           {
                               Value = "Profit",
                               Metadata = new object() { },
                               Synonyms = new List<string>() {"bottomline", "earnings", "gain", "margin", "margins", "net", "profit", "profits", "return", "yield"}
                           },
                           new CreateValue()
                           {
                               Value = "Revenue",
                               Metadata = new object() { },
                               Synonyms = new List<string>() {"income", "sales", "topline"}
                           }
                       }
                   }
               },
                Intents = new List<CreateIntent>()
              {
                  new CreateIntent()
                  {
                      Intent = "not_happy",
                      Description = null,
                      Examples = new List<CreateExample>()
                      {
                          new CreateExample()
                          {
                              Text = "I'm not happy with my company results"
                          }
                      }
                  }
              }
            };

            #endregion

            ConversationService service = new ConversationService(_userName, _password);
            service.Endpoint = _endpoint;

            var results = service.CreateWorkspace(workspace);
            _tempWorkspace = results.WorkspaceId;

            Assert.IsNotNull(results);
        }