ibm_watson 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/README.md +258 -0
 - data/bin/console +14 -0
 - data/bin/setup +8 -0
 - data/lib/ibm_watson.rb +16 -0
 - data/lib/ibm_watson/assistant_v1.rb +1997 -0
 - data/lib/ibm_watson/detailed_response.rb +21 -0
 - data/lib/ibm_watson/discovery_v1.rb +2039 -0
 - data/lib/ibm_watson/iam_token_manager.rb +166 -0
 - data/lib/ibm_watson/language_translator_v3.rb +411 -0
 - data/lib/ibm_watson/natural_language_classifier_v1.rb +309 -0
 - data/lib/ibm_watson/natural_language_understanding_v1.rb +297 -0
 - data/lib/ibm_watson/personality_insights_v3.rb +260 -0
 - data/lib/ibm_watson/speech_to_text_v1.rb +2153 -0
 - data/lib/ibm_watson/text_to_speech_v1.rb +716 -0
 - data/lib/ibm_watson/tone_analyzer_v3.rb +287 -0
 - data/lib/ibm_watson/version.rb +3 -0
 - data/lib/ibm_watson/visual_recognition_v3.rb +579 -0
 - data/lib/ibm_watson/watson_api_exception.rb +41 -0
 - data/lib/ibm_watson/watson_service.rb +180 -0
 - data/lib/ibm_watson/websocket/recognize_callback.rb +32 -0
 - data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +162 -0
 - data/rakefile +45 -0
 - data/test/integration/test_assistant_v1.rb +645 -0
 - data/test/integration/test_discovery_v1.rb +200 -0
 - data/test/integration/test_iam_assistant_v1.rb +707 -0
 - data/test/integration/test_language_translator_v3.rb +81 -0
 - data/test/integration/test_natural_language_classifier_v1.rb +69 -0
 - data/test/integration/test_natural_language_understanding_v1.rb +98 -0
 - data/test/integration/test_personality_insights_v3.rb +95 -0
 - data/test/integration/test_speech_to_text_v1.rb +187 -0
 - data/test/integration/test_text_to_speech_v1.rb +81 -0
 - data/test/integration/test_tone_analyzer_v3.rb +72 -0
 - data/test/integration/test_visual_recognition_v3.rb +64 -0
 - data/test/test_helper.rb +22 -0
 - data/test/unit/test_assistant_v1.rb +1598 -0
 - data/test/unit/test_discovery_v1.rb +1144 -0
 - data/test/unit/test_iam_token_manager.rb +165 -0
 - data/test/unit/test_language_translator_v3.rb +461 -0
 - data/test/unit/test_natural_language_classifier_v1.rb +187 -0
 - data/test/unit/test_natural_language_understanding_v1.rb +132 -0
 - data/test/unit/test_personality_insights_v3.rb +172 -0
 - data/test/unit/test_speech_to_text_v1.rb +755 -0
 - data/test/unit/test_text_to_speech_v1.rb +336 -0
 - data/test/unit/test_tone_analyzer_v3.rb +200 -0
 - data/test/unit/test_vcap_using_personality_insights.rb +150 -0
 - data/test/unit/test_visual_recognition_v3.rb +345 -0
 - metadata +302 -0
 
| 
         @@ -0,0 +1,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative("./../test_helper.rb")
         
     | 
| 
      
 4 
     | 
    
         
            +
            require("minitest/hooks/test")
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Integration tests for the Text to Speech V1 Service
         
     | 
| 
      
 7 
     | 
    
         
            +
            class TextToSpeechV1Test < Minitest::Test
         
     | 
| 
      
 8 
     | 
    
         
            +
              include Minitest::Hooks
         
     | 
| 
      
 9 
     | 
    
         
            +
              attr_accessor :service
         
     | 
| 
      
 10 
     | 
    
         
            +
              def before_all
         
     | 
| 
      
 11 
     | 
    
         
            +
                @service = IBMWatson::TextToSpeechV1.new(
         
     | 
| 
      
 12 
     | 
    
         
            +
                  username: ENV["TEXT_TO_SPEECH_USERNAME"],
         
     | 
| 
      
 13 
     | 
    
         
            +
                  password: ENV["TEXT_TO_SPEECH_PASSWORD"]
         
     | 
| 
      
 14 
     | 
    
         
            +
                )
         
     | 
| 
      
 15 
     | 
    
         
            +
                @service.add_default_headers(
         
     | 
| 
      
 16 
     | 
    
         
            +
                  headers: {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    "X-Watson-Learning-Opt-Out" => "1",
         
     | 
| 
      
 18 
     | 
    
         
            +
                    "X-Watson-Test" => "1"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  }
         
     | 
| 
      
 20 
     | 
    
         
            +
                )
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def test_voices
         
     | 
| 
      
 24 
     | 
    
         
            +
                output = @service.list_voices.result
         
     | 
| 
      
 25 
     | 
    
         
            +
                refute(output["voices"].nil?)
         
     | 
| 
      
 26 
     | 
    
         
            +
                voice = @service.get_voice(voice: output["voices"][0]["name"])
         
     | 
| 
      
 27 
     | 
    
         
            +
                refute(voice.nil?)
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              def test_speak
         
     | 
| 
      
 31 
     | 
    
         
            +
                output = @service.synthesize(
         
     | 
| 
      
 32 
     | 
    
         
            +
                  text: "my voice is my passport",
         
     | 
| 
      
 33 
     | 
    
         
            +
                  accept: "audio/wav",
         
     | 
| 
      
 34 
     | 
    
         
            +
                  voice: "en-US_AllisonVoice"
         
     | 
| 
      
 35 
     | 
    
         
            +
                ).result
         
     | 
| 
      
 36 
     | 
    
         
            +
                refute(output.nil?)
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def test_pronunciation
         
     | 
| 
      
 40 
     | 
    
         
            +
                output = @service.get_pronunciation(
         
     | 
| 
      
 41 
     | 
    
         
            +
                  text: "hello"
         
     | 
| 
      
 42 
     | 
    
         
            +
                ).result
         
     | 
| 
      
 43 
     | 
    
         
            +
                refute(output["pronunciation"].nil?)
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              def test_customizations
         
     | 
| 
      
 47 
     | 
    
         
            +
                service_response = @service.list_voice_models
         
     | 
| 
      
 48 
     | 
    
         
            +
                refute(service_response.nil?)
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              def test_custom_words
         
     | 
| 
      
 52 
     | 
    
         
            +
                customization_id = @service.create_voice_model(
         
     | 
| 
      
 53 
     | 
    
         
            +
                  name: "test_integration_customization",
         
     | 
| 
      
 54 
     | 
    
         
            +
                  description: "customization for tests"
         
     | 
| 
      
 55 
     | 
    
         
            +
                ).result["customization_id"]
         
     | 
| 
      
 56 
     | 
    
         
            +
                words = @service.list_words(customization_id: customization_id).result["words"]
         
     | 
| 
      
 57 
     | 
    
         
            +
                assert(words.length.zero?)
         
     | 
| 
      
 58 
     | 
    
         
            +
                @service.add_word(
         
     | 
| 
      
 59 
     | 
    
         
            +
                  customization_id: customization_id,
         
     | 
| 
      
 60 
     | 
    
         
            +
                  word: "ACLs",
         
     | 
| 
      
 61 
     | 
    
         
            +
                  translation: "ackles"
         
     | 
| 
      
 62 
     | 
    
         
            +
                )
         
     | 
| 
      
 63 
     | 
    
         
            +
                words = [{ "word" => "MACLs", "translation" => "mackles" }]
         
     | 
| 
      
 64 
     | 
    
         
            +
                @service.add_words(
         
     | 
| 
      
 65 
     | 
    
         
            +
                  customization_id: customization_id,
         
     | 
| 
      
 66 
     | 
    
         
            +
                  words: words
         
     | 
| 
      
 67 
     | 
    
         
            +
                )
         
     | 
| 
      
 68 
     | 
    
         
            +
                @service.delete_word(
         
     | 
| 
      
 69 
     | 
    
         
            +
                  customization_id: customization_id,
         
     | 
| 
      
 70 
     | 
    
         
            +
                  word: "ACLs"
         
     | 
| 
      
 71 
     | 
    
         
            +
                )
         
     | 
| 
      
 72 
     | 
    
         
            +
                word = @service.get_word(
         
     | 
| 
      
 73 
     | 
    
         
            +
                  customization_id: customization_id,
         
     | 
| 
      
 74 
     | 
    
         
            +
                  word: "MACLs"
         
     | 
| 
      
 75 
     | 
    
         
            +
                ).result
         
     | 
| 
      
 76 
     | 
    
         
            +
                assert(word["translation"] == "mackles")
         
     | 
| 
      
 77 
     | 
    
         
            +
                @service.delete_voice_model(
         
     | 
| 
      
 78 
     | 
    
         
            +
                  customization_id: customization_id
         
     | 
| 
      
 79 
     | 
    
         
            +
                )
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,72 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require("json")
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative("./../test_helper.rb")
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Integration tests for the Tone Analyzer V3 Service
         
     | 
| 
      
 7 
     | 
    
         
            +
            class ToneAnalyzerV3Test < Minitest::Test
         
     | 
| 
      
 8 
     | 
    
         
            +
              def test_tone
         
     | 
| 
      
 9 
     | 
    
         
            +
                tone_text = File.read(Dir.getwd + "/resources/personality.txt")
         
     | 
| 
      
 10 
     | 
    
         
            +
                service = IBMWatson::ToneAnalyzerV3.new(
         
     | 
| 
      
 11 
     | 
    
         
            +
                  version: "2017-09-21",
         
     | 
| 
      
 12 
     | 
    
         
            +
                  username: ENV["TONE_ANALYZER_USERNAME"],
         
     | 
| 
      
 13 
     | 
    
         
            +
                  password: ENV["TONE_ANALYZER_PASSWORD"]
         
     | 
| 
      
 14 
     | 
    
         
            +
                )
         
     | 
| 
      
 15 
     | 
    
         
            +
                service.add_default_headers(
         
     | 
| 
      
 16 
     | 
    
         
            +
                  headers: {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    "X-Watson-Learning-Opt-Out" => "1",
         
     | 
| 
      
 18 
     | 
    
         
            +
                    "X-Watson-Test" => "1"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  }
         
     | 
| 
      
 20 
     | 
    
         
            +
                )
         
     | 
| 
      
 21 
     | 
    
         
            +
                service_response = service.tone(
         
     | 
| 
      
 22 
     | 
    
         
            +
                  tone_input: tone_text,
         
     | 
| 
      
 23 
     | 
    
         
            +
                  content_type: "text/plain"
         
     | 
| 
      
 24 
     | 
    
         
            +
                )
         
     | 
| 
      
 25 
     | 
    
         
            +
                assert((200..299).cover?(service_response.status))
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              def test_tone_with_args
         
     | 
| 
      
 29 
     | 
    
         
            +
                tone_text = File.read(Dir.getwd + "/resources/personality.txt")
         
     | 
| 
      
 30 
     | 
    
         
            +
                service = IBMWatson::ToneAnalyzerV3.new(
         
     | 
| 
      
 31 
     | 
    
         
            +
                  version: "2017-09-21",
         
     | 
| 
      
 32 
     | 
    
         
            +
                  username: ENV["TONE_ANALYZER_USERNAME"],
         
     | 
| 
      
 33 
     | 
    
         
            +
                  password: ENV["TONE_ANALYZER_PASSWORD"]
         
     | 
| 
      
 34 
     | 
    
         
            +
                )
         
     | 
| 
      
 35 
     | 
    
         
            +
                service.add_default_headers(
         
     | 
| 
      
 36 
     | 
    
         
            +
                  headers: {
         
     | 
| 
      
 37 
     | 
    
         
            +
                    "X-Watson-Learning-Opt-Out" => "1",
         
     | 
| 
      
 38 
     | 
    
         
            +
                    "X-Watson-Test" => "1"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  }
         
     | 
| 
      
 40 
     | 
    
         
            +
                )
         
     | 
| 
      
 41 
     | 
    
         
            +
                service_response = service.tone(
         
     | 
| 
      
 42 
     | 
    
         
            +
                  tone_input: tone_text,
         
     | 
| 
      
 43 
     | 
    
         
            +
                  content_type: "text/plain",
         
     | 
| 
      
 44 
     | 
    
         
            +
                  sentences: false
         
     | 
| 
      
 45 
     | 
    
         
            +
                )
         
     | 
| 
      
 46 
     | 
    
         
            +
                assert((200..299).cover?(service_response.status))
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              def test_tone_chat
         
     | 
| 
      
 50 
     | 
    
         
            +
                service = IBMWatson::ToneAnalyzerV3.new(
         
     | 
| 
      
 51 
     | 
    
         
            +
                  version: "2017-09-21",
         
     | 
| 
      
 52 
     | 
    
         
            +
                  username: ENV["TONE_ANALYZER_USERNAME"],
         
     | 
| 
      
 53 
     | 
    
         
            +
                  password: ENV["TONE_ANALYZER_PASSWORD"]
         
     | 
| 
      
 54 
     | 
    
         
            +
                )
         
     | 
| 
      
 55 
     | 
    
         
            +
                service.add_default_headers(
         
     | 
| 
      
 56 
     | 
    
         
            +
                  headers: {
         
     | 
| 
      
 57 
     | 
    
         
            +
                    "X-Watson-Learning-Opt-Out" => "1",
         
     | 
| 
      
 58 
     | 
    
         
            +
                    "X-Watson-Test" => "1"
         
     | 
| 
      
 59 
     | 
    
         
            +
                  }
         
     | 
| 
      
 60 
     | 
    
         
            +
                )
         
     | 
| 
      
 61 
     | 
    
         
            +
                utterances = [
         
     | 
| 
      
 62 
     | 
    
         
            +
                  {
         
     | 
| 
      
 63 
     | 
    
         
            +
                    "text" => "I am very happy",
         
     | 
| 
      
 64 
     | 
    
         
            +
                    "user" => "glenn"
         
     | 
| 
      
 65 
     | 
    
         
            +
                  }
         
     | 
| 
      
 66 
     | 
    
         
            +
                ]
         
     | 
| 
      
 67 
     | 
    
         
            +
                service_response = service.tone_chat(
         
     | 
| 
      
 68 
     | 
    
         
            +
                  utterances: utterances
         
     | 
| 
      
 69 
     | 
    
         
            +
                )
         
     | 
| 
      
 70 
     | 
    
         
            +
                assert((200..299).cover?(service_response.status))
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require("json")
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative("./../test_helper.rb")
         
     | 
| 
      
 5 
     | 
    
         
            +
            require("minitest/hooks/test")
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            # Integration tests for the Visual Recognition V3 Service
         
     | 
| 
      
 8 
     | 
    
         
            +
            class VisualRecognitionV3Test < Minitest::Test
         
     | 
| 
      
 9 
     | 
    
         
            +
              include Minitest::Hooks
         
     | 
| 
      
 10 
     | 
    
         
            +
              attr_accessor :service, :classifier_id
         
     | 
| 
      
 11 
     | 
    
         
            +
              def before_all
         
     | 
| 
      
 12 
     | 
    
         
            +
                @service = IBMWatson::VisualRecognitionV3.new(
         
     | 
| 
      
 13 
     | 
    
         
            +
                  iam_api_key: ENV["VISUAL_RECOGNITION_IAM_APIKEY"],
         
     | 
| 
      
 14 
     | 
    
         
            +
                  version: "2018-03-19",
         
     | 
| 
      
 15 
     | 
    
         
            +
                  url: ENV["VISUAL_RECOGNITION_IAM_URL"]
         
     | 
| 
      
 16 
     | 
    
         
            +
                )
         
     | 
| 
      
 17 
     | 
    
         
            +
                @classifier_id = "doxnotxdeletexsdksxintegration_718351350"
         
     | 
| 
      
 18 
     | 
    
         
            +
                @service.add_default_headers(
         
     | 
| 
      
 19 
     | 
    
         
            +
                  headers: {
         
     | 
| 
      
 20 
     | 
    
         
            +
                    "X-Watson-Learning-Opt-Out" => "1",
         
     | 
| 
      
 21 
     | 
    
         
            +
                    "X-Watson-Test" => "1"
         
     | 
| 
      
 22 
     | 
    
         
            +
                  }
         
     | 
| 
      
 23 
     | 
    
         
            +
                )
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              def test_classify
         
     | 
| 
      
 27 
     | 
    
         
            +
                image_file = File.open(Dir.getwd + "/resources/dog.jpg")
         
     | 
| 
      
 28 
     | 
    
         
            +
                dog_results = @service.classify(
         
     | 
| 
      
 29 
     | 
    
         
            +
                  images_file: image_file,
         
     | 
| 
      
 30 
     | 
    
         
            +
                  threshold: "0.1",
         
     | 
| 
      
 31 
     | 
    
         
            +
                  classifier_ids: "default"
         
     | 
| 
      
 32 
     | 
    
         
            +
                ).result
         
     | 
| 
      
 33 
     | 
    
         
            +
                refute(dog_results.nil?)
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              def test_detect_faces
         
     | 
| 
      
 37 
     | 
    
         
            +
                output = @service.detect_faces(
         
     | 
| 
      
 38 
     | 
    
         
            +
                  url: "https://www.ibm.com/ibm/ginni/images/ginni_bio_780x981_v4_03162016.jpg"
         
     | 
| 
      
 39 
     | 
    
         
            +
                ).result
         
     | 
| 
      
 40 
     | 
    
         
            +
                refute(output.nil?)
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def test_custom_classifier
         
     | 
| 
      
 44 
     | 
    
         
            +
                skip "Time Consuming"
         
     | 
| 
      
 45 
     | 
    
         
            +
                cars = File.open(Dir.getwd + "/resources/cars.zip")
         
     | 
| 
      
 46 
     | 
    
         
            +
                trucks = File.open(Dir.getwd + "/resources/trucks.zip")
         
     | 
| 
      
 47 
     | 
    
         
            +
                classifier = @service.create_classifier(
         
     | 
| 
      
 48 
     | 
    
         
            +
                  name: "CarsVsTrucks",
         
     | 
| 
      
 49 
     | 
    
         
            +
                  classname_positive_examples: cars,
         
     | 
| 
      
 50 
     | 
    
         
            +
                  negative_examples: trucks
         
     | 
| 
      
 51 
     | 
    
         
            +
                ).result
         
     | 
| 
      
 52 
     | 
    
         
            +
                refute(classifier.nil?)
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                classifier_id = classifier["classifier_id"]
         
     | 
| 
      
 55 
     | 
    
         
            +
                output = @service.get_classifier(
         
     | 
| 
      
 56 
     | 
    
         
            +
                  classifier_id: classifier_id
         
     | 
| 
      
 57 
     | 
    
         
            +
                ).result
         
     | 
| 
      
 58 
     | 
    
         
            +
                refute(output.nil?)
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                @service.delete_classifier(
         
     | 
| 
      
 61 
     | 
    
         
            +
                  classifier_id: classifier_id
         
     | 
| 
      
 62 
     | 
    
         
            +
                )
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
            end
         
     | 
    
        data/test/test_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require("simplecov")
         
     | 
| 
      
 4 
     | 
    
         
            +
            require("codecov")
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            if ENV["COVERAGE"]
         
     | 
| 
      
 7 
     | 
    
         
            +
              SimpleCov.formatter = SimpleCov::Formatter::Codecov if ENV["CI"]
         
     | 
| 
      
 8 
     | 
    
         
            +
              unless SimpleCov.running
         
     | 
| 
      
 9 
     | 
    
         
            +
                SimpleCov.start do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  add_filter "/test/"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  add_filter do |src_file|
         
     | 
| 
      
 12 
     | 
    
         
            +
                    File.basename(src_file.filename) == "version.rb"
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  add_group "lib", "/lib/"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  command_name "Minitest"
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            require("minitest/autorun")
         
     | 
| 
      
 22 
     | 
    
         
            +
            require_relative("./../lib/ibm_watson.rb")
         
     | 
| 
         @@ -0,0 +1,1598 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require("json")
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative("./../test_helper.rb")
         
     | 
| 
      
 5 
     | 
    
         
            +
            require("webmock/minitest")
         
     | 
| 
      
 6 
     | 
    
         
            +
            SimpleCov.command_name "test:unit"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            WebMock.disable_net_connect!(allow_localhost: true)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            # Unit tests for the Watson Assistant V1 Service
         
     | 
| 
      
 11 
     | 
    
         
            +
            class AssistantV1Test < Minitest::Test
         
     | 
| 
      
 12 
     | 
    
         
            +
              def test_plain_to_json
         
     | 
| 
      
 13 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 14 
     | 
    
         
            +
                  "text" => "I want financial advice today.",
         
     | 
| 
      
 15 
     | 
    
         
            +
                  "created" => "2016-07-11T16:39:01.774Z",
         
     | 
| 
      
 16 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 17 
     | 
    
         
            +
                }
         
     | 
| 
      
 18 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 19 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 20 
     | 
    
         
            +
                }
         
     | 
| 
      
 21 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/counterexamples?version=2018-02-16")
         
     | 
| 
      
 22 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 23 
     | 
    
         
            +
                    body: "{\"text\":\"I want financial advice today.\"}",
         
     | 
| 
      
 24 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 25 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 26 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 27 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 28 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 29 
     | 
    
         
            +
                    }
         
     | 
| 
      
 30 
     | 
    
         
            +
                  ).to_return(status: 201, body: response.to_json, headers: headers)
         
     | 
| 
      
 31 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 32 
     | 
    
         
            +
                  version: "2018-02-16",
         
     | 
| 
      
 33 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 34 
     | 
    
         
            +
                  password: "password"
         
     | 
| 
      
 35 
     | 
    
         
            +
                )
         
     | 
| 
      
 36 
     | 
    
         
            +
                service_response = service.create_counterexample(
         
     | 
| 
      
 37 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 38 
     | 
    
         
            +
                  text: "I want financial advice today."
         
     | 
| 
      
 39 
     | 
    
         
            +
                )
         
     | 
| 
      
 40 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def test_rate_limit_exceeded
         
     | 
| 
      
 44 
     | 
    
         
            +
                error_code = 429
         
     | 
| 
      
 45 
     | 
    
         
            +
                error_msg = "Rate limit exceeded"
         
     | 
| 
      
 46 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 47 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 48 
     | 
    
         
            +
                }
         
     | 
| 
      
 49 
     | 
    
         
            +
                error_response = {
         
     | 
| 
      
 50 
     | 
    
         
            +
                  "code" => error_code,
         
     | 
| 
      
 51 
     | 
    
         
            +
                  "error" => error_msg
         
     | 
| 
      
 52 
     | 
    
         
            +
                }
         
     | 
| 
      
 53 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/counterexamples?version=2018-02-16")
         
     | 
| 
      
 54 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 55 
     | 
    
         
            +
                    body: "{\"text\":\"I want financial advice today.\"}",
         
     | 
| 
      
 56 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 57 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 58 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 59 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 60 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 61 
     | 
    
         
            +
                    }
         
     | 
| 
      
 62 
     | 
    
         
            +
                  ).to_return(status: 429, body: error_response.to_json, headers: headers)
         
     | 
| 
      
 63 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 64 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 65 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 66 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 67 
     | 
    
         
            +
                )
         
     | 
| 
      
 68 
     | 
    
         
            +
                begin
         
     | 
| 
      
 69 
     | 
    
         
            +
                  service.create_counterexample(
         
     | 
| 
      
 70 
     | 
    
         
            +
                    workspace_id: "boguswid",
         
     | 
| 
      
 71 
     | 
    
         
            +
                    text: "I want financial advice today."
         
     | 
| 
      
 72 
     | 
    
         
            +
                  )
         
     | 
| 
      
 73 
     | 
    
         
            +
                rescue WatsonApiException => e
         
     | 
| 
      
 74 
     | 
    
         
            +
                  assert_equal(error_code, e.code)
         
     | 
| 
      
 75 
     | 
    
         
            +
                  assert_equal(error_msg, e.error)
         
     | 
| 
      
 76 
     | 
    
         
            +
                  assert(e.to_s.instance_of?(String))
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              def test_unknown_error
         
     | 
| 
      
 81 
     | 
    
         
            +
                error_msg = "Unknown error"
         
     | 
| 
      
 82 
     | 
    
         
            +
                error_code = 407
         
     | 
| 
      
 83 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 84 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 85 
     | 
    
         
            +
                }
         
     | 
| 
      
 86 
     | 
    
         
            +
                error_response = {
         
     | 
| 
      
 87 
     | 
    
         
            +
                  "error" => error_msg,
         
     | 
| 
      
 88 
     | 
    
         
            +
                  "code" => error_code
         
     | 
| 
      
 89 
     | 
    
         
            +
                }
         
     | 
| 
      
 90 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/counterexamples?version=2018-02-16")
         
     | 
| 
      
 91 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 92 
     | 
    
         
            +
                    body: "{\"text\":\"I want financial advice today.\"}",
         
     | 
| 
      
 93 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 94 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 95 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 96 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 97 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 98 
     | 
    
         
            +
                    }
         
     | 
| 
      
 99 
     | 
    
         
            +
                  ).to_return(status: 407, body: error_response.to_json, headers: headers)
         
     | 
| 
      
 100 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 101 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 102 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 103 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 104 
     | 
    
         
            +
                )
         
     | 
| 
      
 105 
     | 
    
         
            +
                begin
         
     | 
| 
      
 106 
     | 
    
         
            +
                  service.create_counterexample(
         
     | 
| 
      
 107 
     | 
    
         
            +
                    workspace_id: "boguswid",
         
     | 
| 
      
 108 
     | 
    
         
            +
                    text: "I want financial advice today."
         
     | 
| 
      
 109 
     | 
    
         
            +
                  )
         
     | 
| 
      
 110 
     | 
    
         
            +
                rescue WatsonApiException => e
         
     | 
| 
      
 111 
     | 
    
         
            +
                  assert_equal(error_code, e.code)
         
     | 
| 
      
 112 
     | 
    
         
            +
                  assert_equal(error_msg, e.error)
         
     | 
| 
      
 113 
     | 
    
         
            +
                end
         
     | 
| 
      
 114 
     | 
    
         
            +
              end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
              def test_delete_counterexample
         
     | 
| 
      
 117 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 118 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 119 
     | 
    
         
            +
                }
         
     | 
| 
      
 120 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/counterexamples/I%20want%20financial%20advice%20today?version=2018-02-16")
         
     | 
| 
      
 121 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 122 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 123 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 124 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 125 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 126 
     | 
    
         
            +
                    }
         
     | 
| 
      
 127 
     | 
    
         
            +
                  ).to_return(status: 200, body: {}.to_json, headers: headers)
         
     | 
| 
      
 128 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 129 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 130 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 131 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 132 
     | 
    
         
            +
                )
         
     | 
| 
      
 133 
     | 
    
         
            +
                service_response = service.delete_counterexample(
         
     | 
| 
      
 134 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 135 
     | 
    
         
            +
                  text: "I want financial advice today"
         
     | 
| 
      
 136 
     | 
    
         
            +
                )
         
     | 
| 
      
 137 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 138 
     | 
    
         
            +
              end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
              def test_get_counterexample
         
     | 
| 
      
 141 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 142 
     | 
    
         
            +
                  "text" => "What are you wearing?",
         
     | 
| 
      
 143 
     | 
    
         
            +
                  "created" => "2016-07-11T23:53:59.153Z",
         
     | 
| 
      
 144 
     | 
    
         
            +
                  "updated" => "2016-12-07T18:53:59.153Z"
         
     | 
| 
      
 145 
     | 
    
         
            +
                }
         
     | 
| 
      
 146 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 147 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 148 
     | 
    
         
            +
                }
         
     | 
| 
      
 149 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/counterexamples/What%20are%20you%20wearing%3F?version=2018-02-16")
         
     | 
| 
      
 150 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 151 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 152 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 153 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 154 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 155 
     | 
    
         
            +
                    }
         
     | 
| 
      
 156 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 157 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 158 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 159 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 160 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 161 
     | 
    
         
            +
                )
         
     | 
| 
      
 162 
     | 
    
         
            +
                service_response = service.get_counterexample(
         
     | 
| 
      
 163 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 164 
     | 
    
         
            +
                  text: "What are you wearing?"
         
     | 
| 
      
 165 
     | 
    
         
            +
                )
         
     | 
| 
      
 166 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 167 
     | 
    
         
            +
              end
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
              def test_list_counterexamples
         
     | 
| 
      
 170 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 171 
     | 
    
         
            +
                  "counterexamples" => [
         
     | 
| 
      
 172 
     | 
    
         
            +
                    {
         
     | 
| 
      
 173 
     | 
    
         
            +
                      "text" => "I want financial advice today.",
         
     | 
| 
      
 174 
     | 
    
         
            +
                      "created" => "2016-07-11T16:39:01.774Z",
         
     | 
| 
      
 175 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 176 
     | 
    
         
            +
                    }, {
         
     | 
| 
      
 177 
     | 
    
         
            +
                      "text" => "What are you wearing today",
         
     | 
| 
      
 178 
     | 
    
         
            +
                      "created" => "2016-07-11T16:39:01.774Z",
         
     | 
| 
      
 179 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 180 
     | 
    
         
            +
                    }
         
     | 
| 
      
 181 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 182 
     | 
    
         
            +
                  "pagination" => {
         
     | 
| 
      
 183 
     | 
    
         
            +
                    "refresh_url" => "/v1/workspaces/pizza_app-e0f3/counterexamples?version=2017-12-18&page_limit=2",
         
     | 
| 
      
 184 
     | 
    
         
            +
                    "next_url" => "/v1/workspaces/pizza_app-e0f3/counterexamples?cursor=base64=&version=2017-12-18&page_limit=2"
         
     | 
| 
      
 185 
     | 
    
         
            +
                  }
         
     | 
| 
      
 186 
     | 
    
         
            +
                }
         
     | 
| 
      
 187 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 188 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 189 
     | 
    
         
            +
                }
         
     | 
| 
      
 190 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/counterexamples?version=2018-02-16")
         
     | 
| 
      
 191 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 192 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 193 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 194 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 195 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 196 
     | 
    
         
            +
                    }
         
     | 
| 
      
 197 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 198 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 199 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 200 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 201 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 202 
     | 
    
         
            +
                )
         
     | 
| 
      
 203 
     | 
    
         
            +
                service_response = service.list_counterexamples(
         
     | 
| 
      
 204 
     | 
    
         
            +
                  workspace_id: "boguswid"
         
     | 
| 
      
 205 
     | 
    
         
            +
                )
         
     | 
| 
      
 206 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 207 
     | 
    
         
            +
              end
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
              def test_update_counterexample
         
     | 
| 
      
 210 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 211 
     | 
    
         
            +
                  "text" => "What are you wearing?",
         
     | 
| 
      
 212 
     | 
    
         
            +
                  "created" => "2016-07-11T23:53:59.153Z",
         
     | 
| 
      
 213 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 214 
     | 
    
         
            +
                }
         
     | 
| 
      
 215 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 216 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 217 
     | 
    
         
            +
                }
         
     | 
| 
      
 218 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/counterexamples/What%20are%20you%20wearing%3F?version=2018-02-16")
         
     | 
| 
      
 219 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 220 
     | 
    
         
            +
                    body: "{\"text\":\"What are you wearing?\"}",
         
     | 
| 
      
 221 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 222 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 223 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 224 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 225 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 226 
     | 
    
         
            +
                    }
         
     | 
| 
      
 227 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 228 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 229 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 230 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 231 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 232 
     | 
    
         
            +
                )
         
     | 
| 
      
 233 
     | 
    
         
            +
                service_response = service.update_counterexample(
         
     | 
| 
      
 234 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 235 
     | 
    
         
            +
                  text: "What are you wearing?",
         
     | 
| 
      
 236 
     | 
    
         
            +
                  new_text: "What are you wearing?"
         
     | 
| 
      
 237 
     | 
    
         
            +
                )
         
     | 
| 
      
 238 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 239 
     | 
    
         
            +
              end
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
              def test_create_entity
         
     | 
| 
      
 242 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 243 
     | 
    
         
            +
                  "entity" => "pizza_toppings",
         
     | 
| 
      
 244 
     | 
    
         
            +
                  "description" => "Tasty pizza toppings",
         
     | 
| 
      
 245 
     | 
    
         
            +
                  "created" => "2015-12-06T04:32:20.000Z",
         
     | 
| 
      
 246 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z",
         
     | 
| 
      
 247 
     | 
    
         
            +
                  "metadata" => {
         
     | 
| 
      
 248 
     | 
    
         
            +
                    "property" => "value"
         
     | 
| 
      
 249 
     | 
    
         
            +
                  }
         
     | 
| 
      
 250 
     | 
    
         
            +
                }
         
     | 
| 
      
 251 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 252 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 253 
     | 
    
         
            +
                }
         
     | 
| 
      
 254 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities?version=2018-02-16")
         
     | 
| 
      
 255 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 256 
     | 
    
         
            +
                    body: "{\"entity\":\"pizza_toppings\",\"description\":\"Tasty pizza toppings\",\"metadata\":{\"property\":\"value\"}}",
         
     | 
| 
      
 257 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 258 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 259 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 260 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 261 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 262 
     | 
    
         
            +
                    }
         
     | 
| 
      
 263 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 264 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 265 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 266 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 267 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 268 
     | 
    
         
            +
                )
         
     | 
| 
      
 269 
     | 
    
         
            +
                service_response = service.create_entity(
         
     | 
| 
      
 270 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 271 
     | 
    
         
            +
                  entity: "pizza_toppings",
         
     | 
| 
      
 272 
     | 
    
         
            +
                  description: "Tasty pizza toppings",
         
     | 
| 
      
 273 
     | 
    
         
            +
                  metadata: { "property" => "value" },
         
     | 
| 
      
 274 
     | 
    
         
            +
                  values: nil,
         
     | 
| 
      
 275 
     | 
    
         
            +
                  fuzzy_match: nil
         
     | 
| 
      
 276 
     | 
    
         
            +
                )
         
     | 
| 
      
 277 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 278 
     | 
    
         
            +
              end
         
     | 
| 
      
 279 
     | 
    
         
            +
             
     | 
| 
      
 280 
     | 
    
         
            +
              def test_delete_entity
         
     | 
| 
      
 281 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 282 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 283 
     | 
    
         
            +
                }
         
     | 
| 
      
 284 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/pizza_toppings?version=2018-02-16")
         
     | 
| 
      
 285 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 286 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 287 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 288 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 289 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 290 
     | 
    
         
            +
                    }
         
     | 
| 
      
 291 
     | 
    
         
            +
                  ).to_return(status: 200, body: "{}", headers: headers)
         
     | 
| 
      
 292 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 293 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 294 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 295 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 296 
     | 
    
         
            +
                )
         
     | 
| 
      
 297 
     | 
    
         
            +
                service_response = service.delete_entity(
         
     | 
| 
      
 298 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 299 
     | 
    
         
            +
                  entity: "pizza_toppings"
         
     | 
| 
      
 300 
     | 
    
         
            +
                )
         
     | 
| 
      
 301 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 302 
     | 
    
         
            +
              end
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
      
 304 
     | 
    
         
            +
              def test_get_entity
         
     | 
| 
      
 305 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 306 
     | 
    
         
            +
                  "entity" => "pizza_toppings",
         
     | 
| 
      
 307 
     | 
    
         
            +
                  "description" => "Tasty pizza toppings",
         
     | 
| 
      
 308 
     | 
    
         
            +
                  "created" => "2015-12-06T04:32:20.000Z",
         
     | 
| 
      
 309 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z",
         
     | 
| 
      
 310 
     | 
    
         
            +
                  "metadata" => {
         
     | 
| 
      
 311 
     | 
    
         
            +
                    "property" => "value"
         
     | 
| 
      
 312 
     | 
    
         
            +
                  }
         
     | 
| 
      
 313 
     | 
    
         
            +
                }
         
     | 
| 
      
 314 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 315 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 316 
     | 
    
         
            +
                }
         
     | 
| 
      
 317 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/pizza_toppings?export=true&version=2018-02-16")
         
     | 
| 
      
 318 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 319 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 320 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 321 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 322 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 323 
     | 
    
         
            +
                    }
         
     | 
| 
      
 324 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 325 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 326 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 327 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 328 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 329 
     | 
    
         
            +
                )
         
     | 
| 
      
 330 
     | 
    
         
            +
                service_response = service.get_entity(
         
     | 
| 
      
 331 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 332 
     | 
    
         
            +
                  entity: "pizza_toppings",
         
     | 
| 
      
 333 
     | 
    
         
            +
                  export: true
         
     | 
| 
      
 334 
     | 
    
         
            +
                )
         
     | 
| 
      
 335 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 336 
     | 
    
         
            +
              end
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
              def test_list_entities
         
     | 
| 
      
 339 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 340 
     | 
    
         
            +
                  "entities" => [
         
     | 
| 
      
 341 
     | 
    
         
            +
                    {
         
     | 
| 
      
 342 
     | 
    
         
            +
                      "entity" => "pizza_toppings",
         
     | 
| 
      
 343 
     | 
    
         
            +
                      "description" => "Tasty pizza toppings",
         
     | 
| 
      
 344 
     | 
    
         
            +
                      "created" => "2015-12-06T04:32:20.000Z",
         
     | 
| 
      
 345 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z",
         
     | 
| 
      
 346 
     | 
    
         
            +
                      "metadata" => {
         
     | 
| 
      
 347 
     | 
    
         
            +
                        "property" => "value"
         
     | 
| 
      
 348 
     | 
    
         
            +
                      }
         
     | 
| 
      
 349 
     | 
    
         
            +
                    }
         
     | 
| 
      
 350 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 351 
     | 
    
         
            +
                  "pagination" => {
         
     | 
| 
      
 352 
     | 
    
         
            +
                    "refresh_url" => "/v1/workspaces/pizza_app-e0f3/entities?version=2017-12-18&filter=name:pizza&include_count=true&page_limit=1",
         
     | 
| 
      
 353 
     | 
    
         
            +
                    "next_url" => "/v1/workspaces/pizza_app-e0f3/entities?cursor=base64=&version=2017-12-18&filter=name:pizza&page_limit=1",
         
     | 
| 
      
 354 
     | 
    
         
            +
                    "total" => 1,
         
     | 
| 
      
 355 
     | 
    
         
            +
                    "matched" => 1
         
     | 
| 
      
 356 
     | 
    
         
            +
                  }
         
     | 
| 
      
 357 
     | 
    
         
            +
                }
         
     | 
| 
      
 358 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 359 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 360 
     | 
    
         
            +
                }
         
     | 
| 
      
 361 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities?export=true&version=2018-02-16")
         
     | 
| 
      
 362 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 363 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 364 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 365 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 366 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 367 
     | 
    
         
            +
                    }
         
     | 
| 
      
 368 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 369 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 370 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 371 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 372 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 373 
     | 
    
         
            +
                )
         
     | 
| 
      
 374 
     | 
    
         
            +
                service_response = service.list_entities(
         
     | 
| 
      
 375 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 376 
     | 
    
         
            +
                  export: true
         
     | 
| 
      
 377 
     | 
    
         
            +
                )
         
     | 
| 
      
 378 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 379 
     | 
    
         
            +
              end
         
     | 
| 
      
 380 
     | 
    
         
            +
             
     | 
| 
      
 381 
     | 
    
         
            +
              def test_update_entity
         
     | 
| 
      
 382 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 383 
     | 
    
         
            +
                  "entity" => "pizza_toppings",
         
     | 
| 
      
 384 
     | 
    
         
            +
                  "description" => "Tasty pizza toppings",
         
     | 
| 
      
 385 
     | 
    
         
            +
                  "created" => "2015-12-06T04:32:20.000Z",
         
     | 
| 
      
 386 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z",
         
     | 
| 
      
 387 
     | 
    
         
            +
                  "metadata" => {
         
     | 
| 
      
 388 
     | 
    
         
            +
                    "property" => "value"
         
     | 
| 
      
 389 
     | 
    
         
            +
                  }
         
     | 
| 
      
 390 
     | 
    
         
            +
                }
         
     | 
| 
      
 391 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 392 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 393 
     | 
    
         
            +
                }
         
     | 
| 
      
 394 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/pizza_toppings?version=2018-02-16")
         
     | 
| 
      
 395 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 396 
     | 
    
         
            +
                    body: "{\"entity\":\"pizza_toppings\"}",
         
     | 
| 
      
 397 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 398 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 399 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 400 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 401 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 402 
     | 
    
         
            +
                    }
         
     | 
| 
      
 403 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 404 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 405 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 406 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 407 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 408 
     | 
    
         
            +
                )
         
     | 
| 
      
 409 
     | 
    
         
            +
                service_response = service.update_entity(
         
     | 
| 
      
 410 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 411 
     | 
    
         
            +
                  entity: "pizza_toppings",
         
     | 
| 
      
 412 
     | 
    
         
            +
                  new_entity: "pizza_toppings"
         
     | 
| 
      
 413 
     | 
    
         
            +
                )
         
     | 
| 
      
 414 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 415 
     | 
    
         
            +
              end
         
     | 
| 
      
 416 
     | 
    
         
            +
             
     | 
| 
      
 417 
     | 
    
         
            +
              def test_create_example
         
     | 
| 
      
 418 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 419 
     | 
    
         
            +
                  "text" => "Gimme a pizza with pepperoni",
         
     | 
| 
      
 420 
     | 
    
         
            +
                  "created" => "2016-07-11T16:39:01.774Z",
         
     | 
| 
      
 421 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 422 
     | 
    
         
            +
                }
         
     | 
| 
      
 423 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 424 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 425 
     | 
    
         
            +
                }
         
     | 
| 
      
 426 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order/examples?version=2018-02-16")
         
     | 
| 
      
 427 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 428 
     | 
    
         
            +
                    body: "{\"text\":\"Gimme a pizza with pepperoni\"}",
         
     | 
| 
      
 429 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 430 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 431 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 432 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 433 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 434 
     | 
    
         
            +
                    }
         
     | 
| 
      
 435 
     | 
    
         
            +
                  ).to_return(status: 201, body: response.to_json, headers: headers)
         
     | 
| 
      
 436 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 437 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 438 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 439 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 440 
     | 
    
         
            +
                )
         
     | 
| 
      
 441 
     | 
    
         
            +
                service_response = service.create_example(
         
     | 
| 
      
 442 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 443 
     | 
    
         
            +
                  intent: "pizza_order",
         
     | 
| 
      
 444 
     | 
    
         
            +
                  text: "Gimme a pizza with pepperoni"
         
     | 
| 
      
 445 
     | 
    
         
            +
                )
         
     | 
| 
      
 446 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 447 
     | 
    
         
            +
              end
         
     | 
| 
      
 448 
     | 
    
         
            +
             
     | 
| 
      
 449 
     | 
    
         
            +
              def test_delete_example
         
     | 
| 
      
 450 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 451 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 452 
     | 
    
         
            +
                }
         
     | 
| 
      
 453 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order/examples/Gimme%20a%20pizza%20with%20pepperoni?version=2018-02-16")
         
     | 
| 
      
 454 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 455 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 456 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 457 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 458 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 459 
     | 
    
         
            +
                    }
         
     | 
| 
      
 460 
     | 
    
         
            +
                  ).to_return(status: 200, body: "{}", headers: headers)
         
     | 
| 
      
 461 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 462 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 463 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 464 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 465 
     | 
    
         
            +
                )
         
     | 
| 
      
 466 
     | 
    
         
            +
                service_response = service.delete_example(
         
     | 
| 
      
 467 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 468 
     | 
    
         
            +
                  intent: "pizza_order",
         
     | 
| 
      
 469 
     | 
    
         
            +
                  text: "Gimme a pizza with pepperoni"
         
     | 
| 
      
 470 
     | 
    
         
            +
                )
         
     | 
| 
      
 471 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 472 
     | 
    
         
            +
              end
         
     | 
| 
      
 473 
     | 
    
         
            +
             
     | 
| 
      
 474 
     | 
    
         
            +
              def test_get_example
         
     | 
| 
      
 475 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 476 
     | 
    
         
            +
                  "text" => "Gimme a pizza with pepperoni",
         
     | 
| 
      
 477 
     | 
    
         
            +
                  "created" => "2016-07-11T23:53:59.153Z",
         
     | 
| 
      
 478 
     | 
    
         
            +
                  "updated" => "2016-12-07T18:53:59.153Z"
         
     | 
| 
      
 479 
     | 
    
         
            +
                }
         
     | 
| 
      
 480 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 481 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 482 
     | 
    
         
            +
                }
         
     | 
| 
      
 483 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order/examples/Gimme%20a%20pizza%20with%20pepperoni?version=2018-02-16")
         
     | 
| 
      
 484 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 485 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 486 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 487 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 488 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 489 
     | 
    
         
            +
                    }
         
     | 
| 
      
 490 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 491 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 492 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 493 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 494 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 495 
     | 
    
         
            +
                )
         
     | 
| 
      
 496 
     | 
    
         
            +
                service_response = service.get_example(
         
     | 
| 
      
 497 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 498 
     | 
    
         
            +
                  intent: "pizza_order",
         
     | 
| 
      
 499 
     | 
    
         
            +
                  text: "Gimme a pizza with pepperoni"
         
     | 
| 
      
 500 
     | 
    
         
            +
                )
         
     | 
| 
      
 501 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 502 
     | 
    
         
            +
              end
         
     | 
| 
      
 503 
     | 
    
         
            +
             
     | 
| 
      
 504 
     | 
    
         
            +
              def test_list_examples
         
     | 
| 
      
 505 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 506 
     | 
    
         
            +
                  "examples" => [
         
     | 
| 
      
 507 
     | 
    
         
            +
                    {
         
     | 
| 
      
 508 
     | 
    
         
            +
                      "text" => "Can I order a pizza?",
         
     | 
| 
      
 509 
     | 
    
         
            +
                      "created" => "2016-07-11T16:39:01.774Z",
         
     | 
| 
      
 510 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 511 
     | 
    
         
            +
                    }, {
         
     | 
| 
      
 512 
     | 
    
         
            +
                      "text" => "Gimme a pizza with pepperoni",
         
     | 
| 
      
 513 
     | 
    
         
            +
                      "created" => "2016-07-11T16:39:01.774Z",
         
     | 
| 
      
 514 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 515 
     | 
    
         
            +
                    }
         
     | 
| 
      
 516 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 517 
     | 
    
         
            +
                  "pagination" => {
         
     | 
| 
      
 518 
     | 
    
         
            +
                    "refresh_url" => "/v1/workspaces/pizza_app-e0f3/intents/order/examples?version=2017-12-18&page_limit=2",
         
     | 
| 
      
 519 
     | 
    
         
            +
                    "next_url" => "/v1/workspaces/pizza_app-e0f3/intents/order/examples?cursor=base64=&version=2017-12-18&page_limit=2"
         
     | 
| 
      
 520 
     | 
    
         
            +
                  }
         
     | 
| 
      
 521 
     | 
    
         
            +
                }
         
     | 
| 
      
 522 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 523 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 524 
     | 
    
         
            +
                }
         
     | 
| 
      
 525 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order/examples?version=2018-02-16")
         
     | 
| 
      
 526 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 527 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 528 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 529 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 530 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 531 
     | 
    
         
            +
                    }
         
     | 
| 
      
 532 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 533 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 534 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 535 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 536 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 537 
     | 
    
         
            +
                )
         
     | 
| 
      
 538 
     | 
    
         
            +
                service_response = service.list_examples(
         
     | 
| 
      
 539 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 540 
     | 
    
         
            +
                  intent: "pizza_order"
         
     | 
| 
      
 541 
     | 
    
         
            +
                )
         
     | 
| 
      
 542 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 543 
     | 
    
         
            +
              end
         
     | 
| 
      
 544 
     | 
    
         
            +
             
     | 
| 
      
 545 
     | 
    
         
            +
              def test_update_example
         
     | 
| 
      
 546 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 547 
     | 
    
         
            +
                  "text" => "Gimme a pizza with pepperoni",
         
     | 
| 
      
 548 
     | 
    
         
            +
                  "created" => "2016-07-11T23:53:59.153Z",
         
     | 
| 
      
 549 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 550 
     | 
    
         
            +
                }
         
     | 
| 
      
 551 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 552 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 553 
     | 
    
         
            +
                }
         
     | 
| 
      
 554 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order/examples/Gimme%20a%20pizza%20with%20pepperoni?version=2018-02-16")
         
     | 
| 
      
 555 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 556 
     | 
    
         
            +
                    body: "{\"text\":\"Gimme a pizza with pepperoni\"}",
         
     | 
| 
      
 557 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 558 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 559 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 560 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 561 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 562 
     | 
    
         
            +
                    }
         
     | 
| 
      
 563 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 564 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 565 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 566 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 567 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 568 
     | 
    
         
            +
                )
         
     | 
| 
      
 569 
     | 
    
         
            +
                service_response = service.update_example(
         
     | 
| 
      
 570 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 571 
     | 
    
         
            +
                  intent: "pizza_order",
         
     | 
| 
      
 572 
     | 
    
         
            +
                  text: "Gimme a pizza with pepperoni",
         
     | 
| 
      
 573 
     | 
    
         
            +
                  new_text: "Gimme a pizza with pepperoni"
         
     | 
| 
      
 574 
     | 
    
         
            +
                )
         
     | 
| 
      
 575 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 576 
     | 
    
         
            +
              end
         
     | 
| 
      
 577 
     | 
    
         
            +
             
     | 
| 
      
 578 
     | 
    
         
            +
              def test_create_intent
         
     | 
| 
      
 579 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 580 
     | 
    
         
            +
                  "intent" => "pizza_order",
         
     | 
| 
      
 581 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 582 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z",
         
     | 
| 
      
 583 
     | 
    
         
            +
                  "description" => "User wants to start a new pizza order"
         
     | 
| 
      
 584 
     | 
    
         
            +
                }
         
     | 
| 
      
 585 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 586 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 587 
     | 
    
         
            +
                }
         
     | 
| 
      
 588 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents?version=2018-02-16")
         
     | 
| 
      
 589 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 590 
     | 
    
         
            +
                    body: "{\"intent\":\"pizza_order\",\"description\":\"User wants to start a new pizza order\"}",
         
     | 
| 
      
 591 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 592 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 593 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 594 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 595 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 596 
     | 
    
         
            +
                    }
         
     | 
| 
      
 597 
     | 
    
         
            +
                  ).to_return(status: 201, body: response.to_json, headers: headers)
         
     | 
| 
      
 598 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 599 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 600 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 601 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 602 
     | 
    
         
            +
                )
         
     | 
| 
      
 603 
     | 
    
         
            +
                service_response = service.create_intent(
         
     | 
| 
      
 604 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 605 
     | 
    
         
            +
                  intent: "pizza_order",
         
     | 
| 
      
 606 
     | 
    
         
            +
                  description: "User wants to start a new pizza order"
         
     | 
| 
      
 607 
     | 
    
         
            +
                )
         
     | 
| 
      
 608 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 609 
     | 
    
         
            +
              end
         
     | 
| 
      
 610 
     | 
    
         
            +
             
     | 
| 
      
 611 
     | 
    
         
            +
              def test_delete_intent
         
     | 
| 
      
 612 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 613 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 614 
     | 
    
         
            +
                }
         
     | 
| 
      
 615 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order?version=2018-02-16")
         
     | 
| 
      
 616 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 617 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 618 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 619 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 620 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 621 
     | 
    
         
            +
                    }
         
     | 
| 
      
 622 
     | 
    
         
            +
                  ).to_return(status: 200, body: "{}", headers: headers)
         
     | 
| 
      
 623 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 624 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 625 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 626 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 627 
     | 
    
         
            +
                )
         
     | 
| 
      
 628 
     | 
    
         
            +
                service_response = service.delete_intent(
         
     | 
| 
      
 629 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 630 
     | 
    
         
            +
                  intent: "pizza_order"
         
     | 
| 
      
 631 
     | 
    
         
            +
                )
         
     | 
| 
      
 632 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 633 
     | 
    
         
            +
              end
         
     | 
| 
      
 634 
     | 
    
         
            +
             
     | 
| 
      
 635 
     | 
    
         
            +
              def test_get_intent
         
     | 
| 
      
 636 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 637 
     | 
    
         
            +
                  "intent" => "pizza_order",
         
     | 
| 
      
 638 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 639 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z",
         
     | 
| 
      
 640 
     | 
    
         
            +
                  "description" => "User wants to start a new pizza order"
         
     | 
| 
      
 641 
     | 
    
         
            +
                }
         
     | 
| 
      
 642 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 643 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 644 
     | 
    
         
            +
                }
         
     | 
| 
      
 645 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order?export=false&version=2018-02-16")
         
     | 
| 
      
 646 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 647 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 648 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 649 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 650 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 651 
     | 
    
         
            +
                    }
         
     | 
| 
      
 652 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 653 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 654 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 655 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 656 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 657 
     | 
    
         
            +
                )
         
     | 
| 
      
 658 
     | 
    
         
            +
                service_response = service.get_intent(
         
     | 
| 
      
 659 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 660 
     | 
    
         
            +
                  intent: "pizza_order",
         
     | 
| 
      
 661 
     | 
    
         
            +
                  export: false
         
     | 
| 
      
 662 
     | 
    
         
            +
                )
         
     | 
| 
      
 663 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 664 
     | 
    
         
            +
              end
         
     | 
| 
      
 665 
     | 
    
         
            +
             
     | 
| 
      
 666 
     | 
    
         
            +
              def test_list_intents
         
     | 
| 
      
 667 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 668 
     | 
    
         
            +
                  "intents" => [
         
     | 
| 
      
 669 
     | 
    
         
            +
                    {
         
     | 
| 
      
 670 
     | 
    
         
            +
                      "intent" => "pizza_order",
         
     | 
| 
      
 671 
     | 
    
         
            +
                      "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 672 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z",
         
     | 
| 
      
 673 
     | 
    
         
            +
                      "description" => "User wants to start a new pizza order"
         
     | 
| 
      
 674 
     | 
    
         
            +
                    }
         
     | 
| 
      
 675 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 676 
     | 
    
         
            +
                  "pagination" => {
         
     | 
| 
      
 677 
     | 
    
         
            +
                    "refresh_url" => "/v1/workspaces/pizza_app-e0f3/intents?version=2017-12-18&page_limit=1",
         
     | 
| 
      
 678 
     | 
    
         
            +
                    "next_url" => "/v1/workspaces/pizza_app-e0f3/intents?cursor=base64=&version=2017-12-18&page_limit=1"
         
     | 
| 
      
 679 
     | 
    
         
            +
                  }
         
     | 
| 
      
 680 
     | 
    
         
            +
                }
         
     | 
| 
      
 681 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 682 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 683 
     | 
    
         
            +
                }
         
     | 
| 
      
 684 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents?export=false&version=2018-02-16")
         
     | 
| 
      
 685 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 686 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 687 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 688 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 689 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 690 
     | 
    
         
            +
                    }
         
     | 
| 
      
 691 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 692 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 693 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 694 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 695 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 696 
     | 
    
         
            +
                )
         
     | 
| 
      
 697 
     | 
    
         
            +
                service_response = service.list_intents(
         
     | 
| 
      
 698 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 699 
     | 
    
         
            +
                  export: false
         
     | 
| 
      
 700 
     | 
    
         
            +
                )
         
     | 
| 
      
 701 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 702 
     | 
    
         
            +
              end
         
     | 
| 
      
 703 
     | 
    
         
            +
             
     | 
| 
      
 704 
     | 
    
         
            +
              def test_update_intent
         
     | 
| 
      
 705 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 706 
     | 
    
         
            +
                  "intent" => "pizza_order",
         
     | 
| 
      
 707 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 708 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z",
         
     | 
| 
      
 709 
     | 
    
         
            +
                  "description" => "User wants to start a new pizza order"
         
     | 
| 
      
 710 
     | 
    
         
            +
                }
         
     | 
| 
      
 711 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 712 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 713 
     | 
    
         
            +
                }
         
     | 
| 
      
 714 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order?version=2018-02-16")
         
     | 
| 
      
 715 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 716 
     | 
    
         
            +
                    body: "{\"intent\":\"pizza_order\",\"description\":\"User wants to start a new pizza order\"}",
         
     | 
| 
      
 717 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 718 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 719 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 720 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 721 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 722 
     | 
    
         
            +
                    }
         
     | 
| 
      
 723 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 724 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 725 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 726 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 727 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 728 
     | 
    
         
            +
                )
         
     | 
| 
      
 729 
     | 
    
         
            +
                service_response = service.update_intent(
         
     | 
| 
      
 730 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 731 
     | 
    
         
            +
                  intent: "pizza_order",
         
     | 
| 
      
 732 
     | 
    
         
            +
                  new_intent: "pizza_order",
         
     | 
| 
      
 733 
     | 
    
         
            +
                  new_description: "User wants to start a new pizza order"
         
     | 
| 
      
 734 
     | 
    
         
            +
                )
         
     | 
| 
      
 735 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 736 
     | 
    
         
            +
              end
         
     | 
| 
      
 737 
     | 
    
         
            +
             
     | 
| 
      
 738 
     | 
    
         
            +
              def test_list_logs
         
     | 
| 
      
 739 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 740 
     | 
    
         
            +
                  "logs" => [
         
     | 
| 
      
 741 
     | 
    
         
            +
                    {
         
     | 
| 
      
 742 
     | 
    
         
            +
                      "request" => {
         
     | 
| 
      
 743 
     | 
    
         
            +
                        "input" => {
         
     | 
| 
      
 744 
     | 
    
         
            +
                          "text" => "Can you turn off the AC"
         
     | 
| 
      
 745 
     | 
    
         
            +
                        },
         
     | 
| 
      
 746 
     | 
    
         
            +
                        "context" => {
         
     | 
| 
      
 747 
     | 
    
         
            +
                          "conversation_id" => "f2c7e362-4cc8-4761-8b0f-9ccd70c63bca",
         
     | 
| 
      
 748 
     | 
    
         
            +
                          "system" => {}
         
     | 
| 
      
 749 
     | 
    
         
            +
                        }
         
     | 
| 
      
 750 
     | 
    
         
            +
                      },
         
     | 
| 
      
 751 
     | 
    
         
            +
                      "response" => {
         
     | 
| 
      
 752 
     | 
    
         
            +
                        "input" => {
         
     | 
| 
      
 753 
     | 
    
         
            +
                          "text" => "Can you turn off the AC"
         
     | 
| 
      
 754 
     | 
    
         
            +
                        },
         
     | 
| 
      
 755 
     | 
    
         
            +
                        "context" => {
         
     | 
| 
      
 756 
     | 
    
         
            +
                          "conversation_id" => "f2c7e362-4cc8-4761-8b0f-9ccd70c63bca",
         
     | 
| 
      
 757 
     | 
    
         
            +
                          "system" => {
         
     | 
| 
      
 758 
     | 
    
         
            +
                            "dialog_stack" => ["root"],
         
     | 
| 
      
 759 
     | 
    
         
            +
                            "dialog_turn_counter" => 1,
         
     | 
| 
      
 760 
     | 
    
         
            +
                            "dialog_request_counter" => 1
         
     | 
| 
      
 761 
     | 
    
         
            +
                          },
         
     | 
| 
      
 762 
     | 
    
         
            +
                          "defaultCounter" => 0
         
     | 
| 
      
 763 
     | 
    
         
            +
                        },
         
     | 
| 
      
 764 
     | 
    
         
            +
                        "entities" => [],
         
     | 
| 
      
 765 
     | 
    
         
            +
                        "intents" => [
         
     | 
| 
      
 766 
     | 
    
         
            +
                          {
         
     | 
| 
      
 767 
     | 
    
         
            +
                            "intent" => "turn_off",
         
     | 
| 
      
 768 
     | 
    
         
            +
                            "confidence" => 0.9332477126694649
         
     | 
| 
      
 769 
     | 
    
         
            +
                          }
         
     | 
| 
      
 770 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 771 
     | 
    
         
            +
                        "output" => {
         
     | 
| 
      
 772 
     | 
    
         
            +
                          "log_messages" => [],
         
     | 
| 
      
 773 
     | 
    
         
            +
                          "text" => [
         
     | 
| 
      
 774 
     | 
    
         
            +
                            "Hi. It looks like a nice drive today. What would you like me to do?"
         
     | 
| 
      
 775 
     | 
    
         
            +
                          ],
         
     | 
| 
      
 776 
     | 
    
         
            +
                          "nodes_visited" => ["node_1_1467221909631"]
         
     | 
| 
      
 777 
     | 
    
         
            +
                        }
         
     | 
| 
      
 778 
     | 
    
         
            +
                      },
         
     | 
| 
      
 779 
     | 
    
         
            +
                      "request_timestamp" => "2016-07-16T09:22:38.960Z",
         
     | 
| 
      
 780 
     | 
    
         
            +
                      "response_timestamp" => "2016-07-16T09:22:39.011Z",
         
     | 
| 
      
 781 
     | 
    
         
            +
                      "log_id" => "e70d6c12-582d-47a8-a6a2-845120a1f232"
         
     | 
| 
      
 782 
     | 
    
         
            +
                    }
         
     | 
| 
      
 783 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 784 
     | 
    
         
            +
                  "pagination" => {
         
     | 
| 
      
 785 
     | 
    
         
            +
                    "next_url" =>
         
     | 
| 
      
 786 
     | 
    
         
            +
                    "/v1/workspaces/15fb0e8a-463d-4fec-86aa-a737d9c38a32/logs?cursor=dOfVSuh6fBpDuOxEL9m1S7JKDV7KLuBmRR+lQG1s1i/rVnBZ0ZBVCuy53ruHgPImC31gQv5prUsJ77e0Mj+6sGu/yfusHYF5&version=2016-07-11&filter=response.top_intent:turn_off&page_limit=1",
         
     | 
| 
      
 787 
     | 
    
         
            +
                    "matched" => 215
         
     | 
| 
      
 788 
     | 
    
         
            +
                  }
         
     | 
| 
      
 789 
     | 
    
         
            +
                }
         
     | 
| 
      
 790 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 791 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 792 
     | 
    
         
            +
                }
         
     | 
| 
      
 793 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/logs?version=2018-02-16")
         
     | 
| 
      
 794 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 795 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 796 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 797 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 798 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 799 
     | 
    
         
            +
                    }
         
     | 
| 
      
 800 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 801 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 802 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 803 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 804 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 805 
     | 
    
         
            +
                )
         
     | 
| 
      
 806 
     | 
    
         
            +
                service_response = service.list_logs(
         
     | 
| 
      
 807 
     | 
    
         
            +
                  workspace_id: "boguswid"
         
     | 
| 
      
 808 
     | 
    
         
            +
                )
         
     | 
| 
      
 809 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 810 
     | 
    
         
            +
              end
         
     | 
| 
      
 811 
     | 
    
         
            +
             
     | 
| 
      
 812 
     | 
    
         
            +
              def test_list_all_logs
         
     | 
| 
      
 813 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 814 
     | 
    
         
            +
                  "logs" => [
         
     | 
| 
      
 815 
     | 
    
         
            +
                    {
         
     | 
| 
      
 816 
     | 
    
         
            +
                      "request" => {
         
     | 
| 
      
 817 
     | 
    
         
            +
                        "input" => {
         
     | 
| 
      
 818 
     | 
    
         
            +
                          "text" => "Good morning"
         
     | 
| 
      
 819 
     | 
    
         
            +
                        },
         
     | 
| 
      
 820 
     | 
    
         
            +
                        "context" => {
         
     | 
| 
      
 821 
     | 
    
         
            +
                          "metadata" => {
         
     | 
| 
      
 822 
     | 
    
         
            +
                            "deployment" => "deployment_1"
         
     | 
| 
      
 823 
     | 
    
         
            +
                          }
         
     | 
| 
      
 824 
     | 
    
         
            +
                        }
         
     | 
| 
      
 825 
     | 
    
         
            +
                      },
         
     | 
| 
      
 826 
     | 
    
         
            +
                      "response" => {
         
     | 
| 
      
 827 
     | 
    
         
            +
                        "intents" => [
         
     | 
| 
      
 828 
     | 
    
         
            +
                          {
         
     | 
| 
      
 829 
     | 
    
         
            +
                            "intent" => "hello",
         
     | 
| 
      
 830 
     | 
    
         
            +
                            "confidence" => 1
         
     | 
| 
      
 831 
     | 
    
         
            +
                          }
         
     | 
| 
      
 832 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 833 
     | 
    
         
            +
                        "entities" => [],
         
     | 
| 
      
 834 
     | 
    
         
            +
                        "input" => {
         
     | 
| 
      
 835 
     | 
    
         
            +
                          "text" => "Good morning"
         
     | 
| 
      
 836 
     | 
    
         
            +
                        },
         
     | 
| 
      
 837 
     | 
    
         
            +
                        "output" => {
         
     | 
| 
      
 838 
     | 
    
         
            +
                          "text" => ["Hi! What can I do for you?"],
         
     | 
| 
      
 839 
     | 
    
         
            +
                          "nodes_visited" => ["node_2_1501875253968"],
         
     | 
| 
      
 840 
     | 
    
         
            +
                          "log_messages" => []
         
     | 
| 
      
 841 
     | 
    
         
            +
                        },
         
     | 
| 
      
 842 
     | 
    
         
            +
                        "context" => {
         
     | 
| 
      
 843 
     | 
    
         
            +
                          "metadata" => {
         
     | 
| 
      
 844 
     | 
    
         
            +
                            "deployment" => "deployment_1"
         
     | 
| 
      
 845 
     | 
    
         
            +
                          },
         
     | 
| 
      
 846 
     | 
    
         
            +
                          "conversation_id" => "81a43b48-7dca-4a7d-a0d7-6fed03fcee69",
         
     | 
| 
      
 847 
     | 
    
         
            +
                          "system" => {
         
     | 
| 
      
 848 
     | 
    
         
            +
                            "dialog_stack" => [
         
     | 
| 
      
 849 
     | 
    
         
            +
                              {
         
     | 
| 
      
 850 
     | 
    
         
            +
                                "dialog_node" => "root"
         
     | 
| 
      
 851 
     | 
    
         
            +
                              }
         
     | 
| 
      
 852 
     | 
    
         
            +
                            ],
         
     | 
| 
      
 853 
     | 
    
         
            +
                            "dialog_turn_counter" => 1,
         
     | 
| 
      
 854 
     | 
    
         
            +
                            "dialog_request_counter" => 1,
         
     | 
| 
      
 855 
     | 
    
         
            +
                            "_node_output_map" => {
         
     | 
| 
      
 856 
     | 
    
         
            +
                              "node_2_1501875253968" => [0]
         
     | 
| 
      
 857 
     | 
    
         
            +
                            },
         
     | 
| 
      
 858 
     | 
    
         
            +
                            "branch_exited" => true,
         
     | 
| 
      
 859 
     | 
    
         
            +
                            "branch_exited_reason" => "completed"
         
     | 
| 
      
 860 
     | 
    
         
            +
                          }
         
     | 
| 
      
 861 
     | 
    
         
            +
                        }
         
     | 
| 
      
 862 
     | 
    
         
            +
                      },
         
     | 
| 
      
 863 
     | 
    
         
            +
                      "language" => "en",
         
     | 
| 
      
 864 
     | 
    
         
            +
                      "workspace_id" => "9978a49e-ea89-4493-b33d-82298d3db20d",
         
     | 
| 
      
 865 
     | 
    
         
            +
                      "request_timestamp" => "2017-09-13T19:52:32.611Z",
         
     | 
| 
      
 866 
     | 
    
         
            +
                      "response_timestamp" => "2017-09-13T19:52:32.628Z",
         
     | 
| 
      
 867 
     | 
    
         
            +
                      "log_id" => "aa886a8a-bac5-4b91-8323-2fd61a69c9d3"
         
     | 
| 
      
 868 
     | 
    
         
            +
                    }
         
     | 
| 
      
 869 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 870 
     | 
    
         
            +
                  "pagination" => {}
         
     | 
| 
      
 871 
     | 
    
         
            +
                }
         
     | 
| 
      
 872 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 873 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 874 
     | 
    
         
            +
                }
         
     | 
| 
      
 875 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/logs?filter=language::en,request.context.metadata.deployment::deployment_1&version=2018-02-16")
         
     | 
| 
      
 876 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 877 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 878 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 879 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 880 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 881 
     | 
    
         
            +
                    }
         
     | 
| 
      
 882 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 883 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 884 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 885 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 886 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 887 
     | 
    
         
            +
                )
         
     | 
| 
      
 888 
     | 
    
         
            +
                service_response = service.list_all_logs(
         
     | 
| 
      
 889 
     | 
    
         
            +
                  filter: "language::en,request.context.metadata.deployment::deployment_1"
         
     | 
| 
      
 890 
     | 
    
         
            +
                )
         
     | 
| 
      
 891 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 892 
     | 
    
         
            +
              end
         
     | 
| 
      
 893 
     | 
    
         
            +
             
     | 
| 
      
 894 
     | 
    
         
            +
              def test_message
         
     | 
| 
      
 895 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 896 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 897 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 898 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 899 
     | 
    
         
            +
                )
         
     | 
| 
      
 900 
     | 
    
         
            +
                # service.set_default_headers("x-watson-learning-opt-out" => true)
         
     | 
| 
      
 901 
     | 
    
         
            +
                workspace_id = "f8fdbc65-e0bd-4e43-b9f8-2975a366d4ec"
         
     | 
| 
      
 902 
     | 
    
         
            +
                message_response = {
         
     | 
| 
      
 903 
     | 
    
         
            +
                  "context" => {
         
     | 
| 
      
 904 
     | 
    
         
            +
                    "conversation_id" => "1b7b67c0-90ed-45dc-8508-9488bc483d5b",
         
     | 
| 
      
 905 
     | 
    
         
            +
                    "system" => {
         
     | 
| 
      
 906 
     | 
    
         
            +
                      "dialog_stack" => ["root"],
         
     | 
| 
      
 907 
     | 
    
         
            +
                      "dialog_turn_counter" => 1,
         
     | 
| 
      
 908 
     | 
    
         
            +
                      "dialog_request_counter" => 1
         
     | 
| 
      
 909 
     | 
    
         
            +
                    }
         
     | 
| 
      
 910 
     | 
    
         
            +
                  },
         
     | 
| 
      
 911 
     | 
    
         
            +
                  "intents" => [],
         
     | 
| 
      
 912 
     | 
    
         
            +
                  "entities" => [],
         
     | 
| 
      
 913 
     | 
    
         
            +
                  "input" => {},
         
     | 
| 
      
 914 
     | 
    
         
            +
                  "output" => {
         
     | 
| 
      
 915 
     | 
    
         
            +
                    "text" => "okay",
         
     | 
| 
      
 916 
     | 
    
         
            +
                    "log_messages" => []
         
     | 
| 
      
 917 
     | 
    
         
            +
                  }
         
     | 
| 
      
 918 
     | 
    
         
            +
                }
         
     | 
| 
      
 919 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 920 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 921 
     | 
    
         
            +
                }
         
     | 
| 
      
 922 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/f8fdbc65-e0bd-4e43-b9f8-2975a366d4ec/message?version=2018-02-16")
         
     | 
| 
      
 923 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 924 
     | 
    
         
            +
                    body: "{\"input\":{\"text\":\"Turn on the lights\"}}",
         
     | 
| 
      
 925 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 926 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 927 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 928 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 929 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 930 
     | 
    
         
            +
                    }
         
     | 
| 
      
 931 
     | 
    
         
            +
                  ).to_return(status: 200, body: message_response.to_json, headers: headers)
         
     | 
| 
      
 932 
     | 
    
         
            +
                service_response = service.message(
         
     | 
| 
      
 933 
     | 
    
         
            +
                  workspace_id: workspace_id,
         
     | 
| 
      
 934 
     | 
    
         
            +
                  input: { "text" => "Turn on the lights" },
         
     | 
| 
      
 935 
     | 
    
         
            +
                  context: nil
         
     | 
| 
      
 936 
     | 
    
         
            +
                )
         
     | 
| 
      
 937 
     | 
    
         
            +
                assert_equal(message_response, service_response.result)
         
     | 
| 
      
 938 
     | 
    
         
            +
             
     | 
| 
      
 939 
     | 
    
         
            +
                message_ctx = {
         
     | 
| 
      
 940 
     | 
    
         
            +
                  "context" => {
         
     | 
| 
      
 941 
     | 
    
         
            +
                    "conversation_id" => "1b7b67c0-90ed-45dc-8508-9488bc483d5b",
         
     | 
| 
      
 942 
     | 
    
         
            +
                    "system" => {
         
     | 
| 
      
 943 
     | 
    
         
            +
                      "dialog_stack" => ["root"],
         
     | 
| 
      
 944 
     | 
    
         
            +
                      "dialog_turn_counter" => 2,
         
     | 
| 
      
 945 
     | 
    
         
            +
                      "dialog_request_counter" => 1
         
     | 
| 
      
 946 
     | 
    
         
            +
                    }
         
     | 
| 
      
 947 
     | 
    
         
            +
                  }
         
     | 
| 
      
 948 
     | 
    
         
            +
                }
         
     | 
| 
      
 949 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/f8fdbc65-e0bd-4e43-b9f8-2975a366d4ec/message?version=2018-02-16")
         
     | 
| 
      
 950 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 951 
     | 
    
         
            +
                    body: "{\"input\":{\"text\":\"Turn on the lights\"},\"context\":\"{\\\"conversation_id\\\":\\\"1b7b67c0-90ed-45dc-8508-9488bc483d5b\\\",\\\"system\\\":{\\\"dialog_stack\\\":[\\\"root\\\"],\\\"dialog_turn_counter\\\":2,\\\"dialog_request_counter\\\":1}}\"}",
         
     | 
| 
      
 952 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 953 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 954 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 955 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 956 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 957 
     | 
    
         
            +
                    }
         
     | 
| 
      
 958 
     | 
    
         
            +
                  ).to_return(status: 200, body: message_response.to_json, headers: headers)
         
     | 
| 
      
 959 
     | 
    
         
            +
                service_response = service.message(
         
     | 
| 
      
 960 
     | 
    
         
            +
                  workspace_id: workspace_id,
         
     | 
| 
      
 961 
     | 
    
         
            +
                  input: { "text" => "Turn on the lights" },
         
     | 
| 
      
 962 
     | 
    
         
            +
                  context: message_ctx["context"].to_json
         
     | 
| 
      
 963 
     | 
    
         
            +
                )
         
     | 
| 
      
 964 
     | 
    
         
            +
                assert_equal(message_response, service_response.result)
         
     | 
| 
      
 965 
     | 
    
         
            +
              end
         
     | 
| 
      
 966 
     | 
    
         
            +
             
     | 
| 
      
 967 
     | 
    
         
            +
              def test_create_synonym
         
     | 
| 
      
 968 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 969 
     | 
    
         
            +
                  "synonym" => "aeiou",
         
     | 
| 
      
 970 
     | 
    
         
            +
                  "created" => "2000-01-23T04:56:07.000+00:00",
         
     | 
| 
      
 971 
     | 
    
         
            +
                  "updated" => "2000-01-23T04:56:07.000+00:00"
         
     | 
| 
      
 972 
     | 
    
         
            +
                }
         
     | 
| 
      
 973 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 974 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 975 
     | 
    
         
            +
                }
         
     | 
| 
      
 976 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/aeiou/values/vowel/synonyms?version=2018-02-16")
         
     | 
| 
      
 977 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 978 
     | 
    
         
            +
                    body: "{\"synonym\":\"a\"}",
         
     | 
| 
      
 979 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 980 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 981 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 982 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 983 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 984 
     | 
    
         
            +
                    }
         
     | 
| 
      
 985 
     | 
    
         
            +
                  ).to_return(status: 201, body: response.to_json, headers: headers)
         
     | 
| 
      
 986 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 987 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 988 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 989 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 990 
     | 
    
         
            +
                )
         
     | 
| 
      
 991 
     | 
    
         
            +
                service_response = service.create_synonym(
         
     | 
| 
      
 992 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 993 
     | 
    
         
            +
                  entity: "aeiou",
         
     | 
| 
      
 994 
     | 
    
         
            +
                  value: "vowel",
         
     | 
| 
      
 995 
     | 
    
         
            +
                  synonym: "a"
         
     | 
| 
      
 996 
     | 
    
         
            +
                )
         
     | 
| 
      
 997 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 998 
     | 
    
         
            +
              end
         
     | 
| 
      
 999 
     | 
    
         
            +
             
     | 
| 
      
 1000 
     | 
    
         
            +
              def test_delete_synonym
         
     | 
| 
      
 1001 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1002 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1003 
     | 
    
         
            +
                }
         
     | 
| 
      
 1004 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/aeiou/values/vowel/synonyms/a?version=2018-02-16")
         
     | 
| 
      
 1005 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1006 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1007 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1008 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1009 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1010 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1011 
     | 
    
         
            +
                  ).to_return(status: 200, body: "", headers: headers)
         
     | 
| 
      
 1012 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1013 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1014 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1015 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1016 
     | 
    
         
            +
                )
         
     | 
| 
      
 1017 
     | 
    
         
            +
                service_response = service.delete_synonym(
         
     | 
| 
      
 1018 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1019 
     | 
    
         
            +
                  entity: "aeiou",
         
     | 
| 
      
 1020 
     | 
    
         
            +
                  value: "vowel",
         
     | 
| 
      
 1021 
     | 
    
         
            +
                  synonym: "a"
         
     | 
| 
      
 1022 
     | 
    
         
            +
                )
         
     | 
| 
      
 1023 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 1024 
     | 
    
         
            +
              end
         
     | 
| 
      
 1025 
     | 
    
         
            +
             
     | 
| 
      
 1026 
     | 
    
         
            +
              def test_get_synonym
         
     | 
| 
      
 1027 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1028 
     | 
    
         
            +
                  "synonym" => "barbecue",
         
     | 
| 
      
 1029 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1030 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 1031 
     | 
    
         
            +
                }
         
     | 
| 
      
 1032 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1033 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1034 
     | 
    
         
            +
                }
         
     | 
| 
      
 1035 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/grilling/values/bbq/synonyms/barbecue?version=2018-02-16")
         
     | 
| 
      
 1036 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1037 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1038 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1039 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1040 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1041 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1042 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1043 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1044 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1045 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1046 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1047 
     | 
    
         
            +
                )
         
     | 
| 
      
 1048 
     | 
    
         
            +
                service_response = service.get_synonym(
         
     | 
| 
      
 1049 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1050 
     | 
    
         
            +
                  entity: "grilling",
         
     | 
| 
      
 1051 
     | 
    
         
            +
                  value: "bbq",
         
     | 
| 
      
 1052 
     | 
    
         
            +
                  synonym: "barbecue"
         
     | 
| 
      
 1053 
     | 
    
         
            +
                )
         
     | 
| 
      
 1054 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1055 
     | 
    
         
            +
              end
         
     | 
| 
      
 1056 
     | 
    
         
            +
             
     | 
| 
      
 1057 
     | 
    
         
            +
              def test_list_synonyms
         
     | 
| 
      
 1058 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1059 
     | 
    
         
            +
                  "synonyms" => [
         
     | 
| 
      
 1060 
     | 
    
         
            +
                    {
         
     | 
| 
      
 1061 
     | 
    
         
            +
                      "synonym" => "BBQ sauce",
         
     | 
| 
      
 1062 
     | 
    
         
            +
                      "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1063 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 1064 
     | 
    
         
            +
                    },
         
     | 
| 
      
 1065 
     | 
    
         
            +
                    {
         
     | 
| 
      
 1066 
     | 
    
         
            +
                      "synonym" => "barbecue",
         
     | 
| 
      
 1067 
     | 
    
         
            +
                      "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1068 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 1069 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1070 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 1071 
     | 
    
         
            +
                  "pagination" => {
         
     | 
| 
      
 1072 
     | 
    
         
            +
                    "refresh_url" => "/v1/workspaces/pizza_app-e0f3/entities/sauce/values/types/synonyms?version=2017-12-18&filter=name:b&include_count=true&page_limit=2",
         
     | 
| 
      
 1073 
     | 
    
         
            +
                    "next_url" => "/v1/workspaces/pizza_app-e0f3/entities/sauce/values/types/synonyms?cursor=base64=&version=2017-12-18&filter=name:b&page_limit=2",
         
     | 
| 
      
 1074 
     | 
    
         
            +
                    "total" => 8,
         
     | 
| 
      
 1075 
     | 
    
         
            +
                    "matched" => 2
         
     | 
| 
      
 1076 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1077 
     | 
    
         
            +
                }
         
     | 
| 
      
 1078 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1079 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1080 
     | 
    
         
            +
                }
         
     | 
| 
      
 1081 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/grilling/values/bbq/synonyms?version=2018-02-16")
         
     | 
| 
      
 1082 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1083 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1084 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1085 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1086 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1087 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1088 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1089 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1090 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1091 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1092 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1093 
     | 
    
         
            +
                )
         
     | 
| 
      
 1094 
     | 
    
         
            +
                service_response = service.list_synonyms(
         
     | 
| 
      
 1095 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1096 
     | 
    
         
            +
                  entity: "grilling",
         
     | 
| 
      
 1097 
     | 
    
         
            +
                  value: "bbq"
         
     | 
| 
      
 1098 
     | 
    
         
            +
                )
         
     | 
| 
      
 1099 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1100 
     | 
    
         
            +
              end
         
     | 
| 
      
 1101 
     | 
    
         
            +
             
     | 
| 
      
 1102 
     | 
    
         
            +
              def test_update_synonym
         
     | 
| 
      
 1103 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1104 
     | 
    
         
            +
                  "synonym" => "barbecue",
         
     | 
| 
      
 1105 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1106 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 1107 
     | 
    
         
            +
                }
         
     | 
| 
      
 1108 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1109 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1110 
     | 
    
         
            +
                }
         
     | 
| 
      
 1111 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/grilling/values/bbq/synonyms/barbecue?version=2018-02-16")
         
     | 
| 
      
 1112 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1113 
     | 
    
         
            +
                    body: "{\"synonym\":\"barbecue\"}",
         
     | 
| 
      
 1114 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1115 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1116 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1117 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 1118 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1119 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1120 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1121 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1122 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1123 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1124 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1125 
     | 
    
         
            +
                )
         
     | 
| 
      
 1126 
     | 
    
         
            +
                service_response = service.update_synonym(
         
     | 
| 
      
 1127 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1128 
     | 
    
         
            +
                  entity: "grilling",
         
     | 
| 
      
 1129 
     | 
    
         
            +
                  value: "bbq",
         
     | 
| 
      
 1130 
     | 
    
         
            +
                  synonym: "barbecue",
         
     | 
| 
      
 1131 
     | 
    
         
            +
                  new_synonym: "barbecue"
         
     | 
| 
      
 1132 
     | 
    
         
            +
                )
         
     | 
| 
      
 1133 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1134 
     | 
    
         
            +
              end
         
     | 
| 
      
 1135 
     | 
    
         
            +
             
     | 
| 
      
 1136 
     | 
    
         
            +
              def test_create_value
         
     | 
| 
      
 1137 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1138 
     | 
    
         
            +
                  "metadata" => "{}",
         
     | 
| 
      
 1139 
     | 
    
         
            +
                  "created" => "2000-01-23T04:56:07.000+00:00",
         
     | 
| 
      
 1140 
     | 
    
         
            +
                  "value" => "aeiou",
         
     | 
| 
      
 1141 
     | 
    
         
            +
                  "type" => "synonyms",
         
     | 
| 
      
 1142 
     | 
    
         
            +
                  "updated" => "2000-01-23T04:56:07.000+00:00"
         
     | 
| 
      
 1143 
     | 
    
         
            +
                }
         
     | 
| 
      
 1144 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1145 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1146 
     | 
    
         
            +
                }
         
     | 
| 
      
 1147 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/grilling/values?version=2018-02-16")
         
     | 
| 
      
 1148 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1149 
     | 
    
         
            +
                    body: "{\"value\":\"aeiou\"}",
         
     | 
| 
      
 1150 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1151 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1152 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1153 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 1154 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1155 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1156 
     | 
    
         
            +
                  ).to_return(status: 201, body: response.to_json, headers: headers)
         
     | 
| 
      
 1157 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1158 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1159 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1160 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1161 
     | 
    
         
            +
                )
         
     | 
| 
      
 1162 
     | 
    
         
            +
                service_response = service.create_value(
         
     | 
| 
      
 1163 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1164 
     | 
    
         
            +
                  entity: "grilling",
         
     | 
| 
      
 1165 
     | 
    
         
            +
                  value: "aeiou"
         
     | 
| 
      
 1166 
     | 
    
         
            +
                )
         
     | 
| 
      
 1167 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1168 
     | 
    
         
            +
              end
         
     | 
| 
      
 1169 
     | 
    
         
            +
             
     | 
| 
      
 1170 
     | 
    
         
            +
              def test_delete_value
         
     | 
| 
      
 1171 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1172 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1173 
     | 
    
         
            +
                }
         
     | 
| 
      
 1174 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/grilling/values/bbq?version=2018-02-16")
         
     | 
| 
      
 1175 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1176 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1177 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1178 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1179 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1180 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1181 
     | 
    
         
            +
                  ).to_return(status: 200, body: "", headers: headers)
         
     | 
| 
      
 1182 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1183 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1184 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1185 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1186 
     | 
    
         
            +
                )
         
     | 
| 
      
 1187 
     | 
    
         
            +
                service_response = service.delete_value(
         
     | 
| 
      
 1188 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1189 
     | 
    
         
            +
                  entity: "grilling",
         
     | 
| 
      
 1190 
     | 
    
         
            +
                  value: "bbq"
         
     | 
| 
      
 1191 
     | 
    
         
            +
                )
         
     | 
| 
      
 1192 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 1193 
     | 
    
         
            +
              end
         
     | 
| 
      
 1194 
     | 
    
         
            +
             
     | 
| 
      
 1195 
     | 
    
         
            +
              def test_get_value
         
     | 
| 
      
 1196 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1197 
     | 
    
         
            +
                  "value" => "BBQ sauce",
         
     | 
| 
      
 1198 
     | 
    
         
            +
                  "metadata" => {
         
     | 
| 
      
 1199 
     | 
    
         
            +
                    "code" => 1422
         
     | 
| 
      
 1200 
     | 
    
         
            +
                  },
         
     | 
| 
      
 1201 
     | 
    
         
            +
                  "type" => "synonyms",
         
     | 
| 
      
 1202 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1203 
     | 
    
         
            +
                  "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 1204 
     | 
    
         
            +
                }
         
     | 
| 
      
 1205 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1206 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1207 
     | 
    
         
            +
                }
         
     | 
| 
      
 1208 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/grilling/values/bbq?export=true&version=2018-02-16")
         
     | 
| 
      
 1209 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1210 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1211 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1212 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1213 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1214 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1215 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1216 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1217 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1218 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1219 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1220 
     | 
    
         
            +
                )
         
     | 
| 
      
 1221 
     | 
    
         
            +
                service_response = service.get_value(
         
     | 
| 
      
 1222 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1223 
     | 
    
         
            +
                  entity: "grilling",
         
     | 
| 
      
 1224 
     | 
    
         
            +
                  value: "bbq",
         
     | 
| 
      
 1225 
     | 
    
         
            +
                  export: true
         
     | 
| 
      
 1226 
     | 
    
         
            +
                )
         
     | 
| 
      
 1227 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1228 
     | 
    
         
            +
              end
         
     | 
| 
      
 1229 
     | 
    
         
            +
             
     | 
| 
      
 1230 
     | 
    
         
            +
              def test_list_values
         
     | 
| 
      
 1231 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1232 
     | 
    
         
            +
                  "values" => [
         
     | 
| 
      
 1233 
     | 
    
         
            +
                    {
         
     | 
| 
      
 1234 
     | 
    
         
            +
                      "value" => "BBQ sauce",
         
     | 
| 
      
 1235 
     | 
    
         
            +
                      "metadata" => {
         
     | 
| 
      
 1236 
     | 
    
         
            +
                        "code" => 1422
         
     | 
| 
      
 1237 
     | 
    
         
            +
                      },
         
     | 
| 
      
 1238 
     | 
    
         
            +
                      "type" => "synonyms",
         
     | 
| 
      
 1239 
     | 
    
         
            +
                      "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1240 
     | 
    
         
            +
                      "updated" => "2015-12-07T18:53:59.153Z"
         
     | 
| 
      
 1241 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1242 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 1243 
     | 
    
         
            +
                  "pagination" => {
         
     | 
| 
      
 1244 
     | 
    
         
            +
                    "refresh_url" => "/v1/workspaces/pizza_app-e0f3/entities/sauce/values?version=2017-12-18&filter=name:pizza&include_count=true&page_limit=1",
         
     | 
| 
      
 1245 
     | 
    
         
            +
                    "next_url" => "/v1/workspaces/pizza_app-e0f3/sauce/values?cursor=base64=&version=2017-12-18&filter=name:pizza&page_limit=1",
         
     | 
| 
      
 1246 
     | 
    
         
            +
                    "total" => 1,
         
     | 
| 
      
 1247 
     | 
    
         
            +
                    "matched" => 1
         
     | 
| 
      
 1248 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1249 
     | 
    
         
            +
                }
         
     | 
| 
      
 1250 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1251 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1252 
     | 
    
         
            +
                }
         
     | 
| 
      
 1253 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/grilling/values?export=true&version=2018-02-16")
         
     | 
| 
      
 1254 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1255 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1256 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1257 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1258 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1259 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1260 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1261 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1262 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1263 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1264 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1265 
     | 
    
         
            +
                )
         
     | 
| 
      
 1266 
     | 
    
         
            +
                service_response = service.list_values(
         
     | 
| 
      
 1267 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1268 
     | 
    
         
            +
                  entity: "grilling",
         
     | 
| 
      
 1269 
     | 
    
         
            +
                  export: true
         
     | 
| 
      
 1270 
     | 
    
         
            +
                )
         
     | 
| 
      
 1271 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1272 
     | 
    
         
            +
              end
         
     | 
| 
      
 1273 
     | 
    
         
            +
             
     | 
| 
      
 1274 
     | 
    
         
            +
              def test_update_value
         
     | 
| 
      
 1275 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1276 
     | 
    
         
            +
                  "value" => "BBQ sauce",
         
     | 
| 
      
 1277 
     | 
    
         
            +
                  "metadata" => {
         
     | 
| 
      
 1278 
     | 
    
         
            +
                    "code" => 1422
         
     | 
| 
      
 1279 
     | 
    
         
            +
                  },
         
     | 
| 
      
 1280 
     | 
    
         
            +
                  "type" => "synonyms",
         
     | 
| 
      
 1281 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1282 
     | 
    
         
            +
                  "updated" => "2015-12-06T23:53:59.153Z"
         
     | 
| 
      
 1283 
     | 
    
         
            +
                }
         
     | 
| 
      
 1284 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1285 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1286 
     | 
    
         
            +
                }
         
     | 
| 
      
 1287 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/entities/grilling/values/bbq?version=2018-02-16")
         
     | 
| 
      
 1288 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1289 
     | 
    
         
            +
                    body: "{\"value\":\"BBQ sauce\",\"metadata\":{\"code\":1422}}",
         
     | 
| 
      
 1290 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1291 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1292 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1293 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 1294 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1295 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1296 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1297 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1298 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1299 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1300 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1301 
     | 
    
         
            +
                )
         
     | 
| 
      
 1302 
     | 
    
         
            +
                service_response = service.update_value(
         
     | 
| 
      
 1303 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1304 
     | 
    
         
            +
                  entity: "grilling",
         
     | 
| 
      
 1305 
     | 
    
         
            +
                  value: "bbq",
         
     | 
| 
      
 1306 
     | 
    
         
            +
                  new_value: "BBQ sauce",
         
     | 
| 
      
 1307 
     | 
    
         
            +
                  new_metadata: { "code" => 1422 },
         
     | 
| 
      
 1308 
     | 
    
         
            +
                  new_synonyms: nil
         
     | 
| 
      
 1309 
     | 
    
         
            +
                )
         
     | 
| 
      
 1310 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1311 
     | 
    
         
            +
              end
         
     | 
| 
      
 1312 
     | 
    
         
            +
             
     | 
| 
      
 1313 
     | 
    
         
            +
              def test_create_workspace
         
     | 
| 
      
 1314 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1315 
     | 
    
         
            +
                  "name" => "Pizza app",
         
     | 
| 
      
 1316 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1317 
     | 
    
         
            +
                  "language" => "en",
         
     | 
| 
      
 1318 
     | 
    
         
            +
                  "metadata" => {},
         
     | 
| 
      
 1319 
     | 
    
         
            +
                  "updated" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1320 
     | 
    
         
            +
                  "description" => "Pizza app",
         
     | 
| 
      
 1321 
     | 
    
         
            +
                  "workspace_id" => "pizza_app-e0f3"
         
     | 
| 
      
 1322 
     | 
    
         
            +
                }
         
     | 
| 
      
 1323 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1324 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1325 
     | 
    
         
            +
                }
         
     | 
| 
      
 1326 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces?version=2018-02-16")
         
     | 
| 
      
 1327 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1328 
     | 
    
         
            +
                    body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{}}",
         
     | 
| 
      
 1329 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1330 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1331 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1332 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 1333 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1334 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1335 
     | 
    
         
            +
                  ).to_return(status: 201, body: response.to_json, headers: headers)
         
     | 
| 
      
 1336 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1337 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1338 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1339 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1340 
     | 
    
         
            +
                )
         
     | 
| 
      
 1341 
     | 
    
         
            +
                service_response = service.create_workspace(
         
     | 
| 
      
 1342 
     | 
    
         
            +
                  name: "Pizza app",
         
     | 
| 
      
 1343 
     | 
    
         
            +
                  description: "Pizza app",
         
     | 
| 
      
 1344 
     | 
    
         
            +
                  language: "en",
         
     | 
| 
      
 1345 
     | 
    
         
            +
                  metadata: {}
         
     | 
| 
      
 1346 
     | 
    
         
            +
                )
         
     | 
| 
      
 1347 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1348 
     | 
    
         
            +
              end
         
     | 
| 
      
 1349 
     | 
    
         
            +
             
     | 
| 
      
 1350 
     | 
    
         
            +
              def test_delete_workspace
         
     | 
| 
      
 1351 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1352 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1353 
     | 
    
         
            +
                }
         
     | 
| 
      
 1354 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid?version=2018-02-16")
         
     | 
| 
      
 1355 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1356 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1357 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1358 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1359 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1360 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1361 
     | 
    
         
            +
                  ).to_return(status: 200, body: "", headers: headers)
         
     | 
| 
      
 1362 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1363 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1364 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1365 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1366 
     | 
    
         
            +
                )
         
     | 
| 
      
 1367 
     | 
    
         
            +
                service_response = service.delete_workspace(
         
     | 
| 
      
 1368 
     | 
    
         
            +
                  workspace_id: "boguswid"
         
     | 
| 
      
 1369 
     | 
    
         
            +
                )
         
     | 
| 
      
 1370 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 1371 
     | 
    
         
            +
              end
         
     | 
| 
      
 1372 
     | 
    
         
            +
             
     | 
| 
      
 1373 
     | 
    
         
            +
              def test_get_workspace
         
     | 
| 
      
 1374 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1375 
     | 
    
         
            +
                  "name" => "Pizza app",
         
     | 
| 
      
 1376 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1377 
     | 
    
         
            +
                  "language" => "en",
         
     | 
| 
      
 1378 
     | 
    
         
            +
                  "metadata" => {},
         
     | 
| 
      
 1379 
     | 
    
         
            +
                  "updated" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1380 
     | 
    
         
            +
                  "description" => "Pizza app",
         
     | 
| 
      
 1381 
     | 
    
         
            +
                  "status" => "Available",
         
     | 
| 
      
 1382 
     | 
    
         
            +
                  "learning_opt_out" => false,
         
     | 
| 
      
 1383 
     | 
    
         
            +
                  "workspace_id" => "pizza_app-e0f3"
         
     | 
| 
      
 1384 
     | 
    
         
            +
                }
         
     | 
| 
      
 1385 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1386 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1387 
     | 
    
         
            +
                }
         
     | 
| 
      
 1388 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid?export=false&version=2018-02-16")
         
     | 
| 
      
 1389 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1390 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1391 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1392 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1393 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1394 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1395 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1396 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1397 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1398 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1399 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1400 
     | 
    
         
            +
                )
         
     | 
| 
      
 1401 
     | 
    
         
            +
                service_response = service.get_workspace(
         
     | 
| 
      
 1402 
     | 
    
         
            +
                  workspace_id: "boguswid",
         
     | 
| 
      
 1403 
     | 
    
         
            +
                  export: false
         
     | 
| 
      
 1404 
     | 
    
         
            +
                )
         
     | 
| 
      
 1405 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1406 
     | 
    
         
            +
              end
         
     | 
| 
      
 1407 
     | 
    
         
            +
             
     | 
| 
      
 1408 
     | 
    
         
            +
              def test_list_workspaces
         
     | 
| 
      
 1409 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1410 
     | 
    
         
            +
                  "workspaces" => [
         
     | 
| 
      
 1411 
     | 
    
         
            +
                    {
         
     | 
| 
      
 1412 
     | 
    
         
            +
                      "name" => "Pizza app",
         
     | 
| 
      
 1413 
     | 
    
         
            +
                      "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1414 
     | 
    
         
            +
                      "language" => "en",
         
     | 
| 
      
 1415 
     | 
    
         
            +
                      "metadata" => {},
         
     | 
| 
      
 1416 
     | 
    
         
            +
                      "updated" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1417 
     | 
    
         
            +
                      "description" => "Pizza app",
         
     | 
| 
      
 1418 
     | 
    
         
            +
                      "workspace_id" => "pizza_app-e0f3"
         
     | 
| 
      
 1419 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1420 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 1421 
     | 
    
         
            +
                  "pagination" => {
         
     | 
| 
      
 1422 
     | 
    
         
            +
                    "refresh_url" => "/v1/workspaces?version=2016-01-24&page_limit=1",
         
     | 
| 
      
 1423 
     | 
    
         
            +
                    "next_url" => "/v1/workspaces?cursor=base64=&version=2016-01-24&page_limit=1"
         
     | 
| 
      
 1424 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1425 
     | 
    
         
            +
                }
         
     | 
| 
      
 1426 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1427 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1428 
     | 
    
         
            +
                }
         
     | 
| 
      
 1429 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces?version=2018-02-16")
         
     | 
| 
      
 1430 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1431 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1432 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1433 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1434 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1435 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1436 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1437 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1438 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1439 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1440 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1441 
     | 
    
         
            +
                )
         
     | 
| 
      
 1442 
     | 
    
         
            +
                service_response = service.list_workspaces
         
     | 
| 
      
 1443 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1444 
     | 
    
         
            +
              end
         
     | 
| 
      
 1445 
     | 
    
         
            +
             
     | 
| 
      
 1446 
     | 
    
         
            +
              def test_update_workspace
         
     | 
| 
      
 1447 
     | 
    
         
            +
                response = {
         
     | 
| 
      
 1448 
     | 
    
         
            +
                  "name" => "Pizza app",
         
     | 
| 
      
 1449 
     | 
    
         
            +
                  "created" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1450 
     | 
    
         
            +
                  "language" => "en",
         
     | 
| 
      
 1451 
     | 
    
         
            +
                  "metadata" => {},
         
     | 
| 
      
 1452 
     | 
    
         
            +
                  "updated" => "2015-12-06T23:53:59.153Z",
         
     | 
| 
      
 1453 
     | 
    
         
            +
                  "description" => "Pizza app",
         
     | 
| 
      
 1454 
     | 
    
         
            +
                  "workspace_id" => "pizza_app-e0f3"
         
     | 
| 
      
 1455 
     | 
    
         
            +
                }
         
     | 
| 
      
 1456 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1457 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1458 
     | 
    
         
            +
                }
         
     | 
| 
      
 1459 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/pizza_app-e0f3?version=2018-02-16")
         
     | 
| 
      
 1460 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1461 
     | 
    
         
            +
                    body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{}}",
         
     | 
| 
      
 1462 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1463 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1464 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1465 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 1466 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1467 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1468 
     | 
    
         
            +
                  ).to_return(status: 200, body: response.to_json, headers: headers)
         
     | 
| 
      
 1469 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1470 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1471 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1472 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1473 
     | 
    
         
            +
                )
         
     | 
| 
      
 1474 
     | 
    
         
            +
                service_response = service.update_workspace(
         
     | 
| 
      
 1475 
     | 
    
         
            +
                  workspace_id: "pizza_app-e0f3",
         
     | 
| 
      
 1476 
     | 
    
         
            +
                  name: "Pizza app",
         
     | 
| 
      
 1477 
     | 
    
         
            +
                  description: "Pizza app",
         
     | 
| 
      
 1478 
     | 
    
         
            +
                  language: "en",
         
     | 
| 
      
 1479 
     | 
    
         
            +
                  metadata: {}
         
     | 
| 
      
 1480 
     | 
    
         
            +
                )
         
     | 
| 
      
 1481 
     | 
    
         
            +
                assert_equal(response, service_response.result)
         
     | 
| 
      
 1482 
     | 
    
         
            +
              end
         
     | 
| 
      
 1483 
     | 
    
         
            +
             
     | 
| 
      
 1484 
     | 
    
         
            +
              def test_dialog_nodes
         
     | 
| 
      
 1485 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1486 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1487 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1488 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1489 
     | 
    
         
            +
                )
         
     | 
| 
      
 1490 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1491 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1492 
     | 
    
         
            +
                }
         
     | 
| 
      
 1493 
     | 
    
         
            +
             
     | 
| 
      
 1494 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/id/dialog_nodes?version=2018-02-16")
         
     | 
| 
      
 1495 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1496 
     | 
    
         
            +
                    body: "{\"dialog_node\":\"location-done\"}",
         
     | 
| 
      
 1497 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1498 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1499 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1500 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 1501 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1502 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1503 
     | 
    
         
            +
                  ).to_return(status: 200, body: { "application/json" => { "dialog_node" => "location-done" } }.to_json, headers: headers)
         
     | 
| 
      
 1504 
     | 
    
         
            +
                service_response = service.create_dialog_node(
         
     | 
| 
      
 1505 
     | 
    
         
            +
                  workspace_id: "id",
         
     | 
| 
      
 1506 
     | 
    
         
            +
                  dialog_node: "location-done"
         
     | 
| 
      
 1507 
     | 
    
         
            +
                )
         
     | 
| 
      
 1508 
     | 
    
         
            +
                assert_equal("location-done", service_response.result["application/json"]["dialog_node"])
         
     | 
| 
      
 1509 
     | 
    
         
            +
             
     | 
| 
      
 1510 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/id/dialog_nodes/location-done?version=2018-02-16")
         
     | 
| 
      
 1511 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1512 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1513 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1514 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1515 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1516 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1517 
     | 
    
         
            +
                  ).to_return(status: 200, body: { "description" => "deleted successfully" }.to_json, headers: headers)
         
     | 
| 
      
 1518 
     | 
    
         
            +
                service_response = service.delete_dialog_node(
         
     | 
| 
      
 1519 
     | 
    
         
            +
                  workspace_id: "id",
         
     | 
| 
      
 1520 
     | 
    
         
            +
                  dialog_node: "location-done"
         
     | 
| 
      
 1521 
     | 
    
         
            +
                )
         
     | 
| 
      
 1522 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 1523 
     | 
    
         
            +
             
     | 
| 
      
 1524 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/id/dialog_nodes/location-done?version=2018-02-16")
         
     | 
| 
      
 1525 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1526 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1527 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1528 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1529 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1530 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1531 
     | 
    
         
            +
                  ).to_return(status: 200, body: { "application/json" => { "dialog_node" => "location-atm" } }.to_json, headers: headers)
         
     | 
| 
      
 1532 
     | 
    
         
            +
                service_response = service.get_dialog_node(
         
     | 
| 
      
 1533 
     | 
    
         
            +
                  workspace_id: "id",
         
     | 
| 
      
 1534 
     | 
    
         
            +
                  dialog_node: "location-done"
         
     | 
| 
      
 1535 
     | 
    
         
            +
                )
         
     | 
| 
      
 1536 
     | 
    
         
            +
                assert_equal({ "application/json" => { "dialog_node" => "location-atm" } }, service_response.result)
         
     | 
| 
      
 1537 
     | 
    
         
            +
             
     | 
| 
      
 1538 
     | 
    
         
            +
                stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/id/dialog_nodes?version=2018-02-16")
         
     | 
| 
      
 1539 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1540 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1541 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1542 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1543 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1544 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1545 
     | 
    
         
            +
                  ).to_return(status: 200, body: { "application/json" => { "dialog_node" => "location-atm" } }.to_json, headers: headers)
         
     | 
| 
      
 1546 
     | 
    
         
            +
                service_response = service.list_dialog_nodes(
         
     | 
| 
      
 1547 
     | 
    
         
            +
                  workspace_id: "id"
         
     | 
| 
      
 1548 
     | 
    
         
            +
                )
         
     | 
| 
      
 1549 
     | 
    
         
            +
                assert_equal({ "application/json" => { "dialog_node" => "location-atm" } }, service_response.result)
         
     | 
| 
      
 1550 
     | 
    
         
            +
              end
         
     | 
| 
      
 1551 
     | 
    
         
            +
             
     | 
| 
      
 1552 
     | 
    
         
            +
              def test_delete_user_data
         
     | 
| 
      
 1553 
     | 
    
         
            +
                headers = {
         
     | 
| 
      
 1554 
     | 
    
         
            +
                  "Content-Type" => "application/json"
         
     | 
| 
      
 1555 
     | 
    
         
            +
                }
         
     | 
| 
      
 1556 
     | 
    
         
            +
                stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v1/user_data?customer_id=id&version=2018-02-16")
         
     | 
| 
      
 1557 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1558 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1559 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1560 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1561 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1562 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1563 
     | 
    
         
            +
                  ).to_return(status: 200, body: "", headers: headers)
         
     | 
| 
      
 1564 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1565 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1566 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1567 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1568 
     | 
    
         
            +
                )
         
     | 
| 
      
 1569 
     | 
    
         
            +
                service_response = service.delete_user_data(
         
     | 
| 
      
 1570 
     | 
    
         
            +
                  customer_id: "id"
         
     | 
| 
      
 1571 
     | 
    
         
            +
                )
         
     | 
| 
      
 1572 
     | 
    
         
            +
                assert(service_response.nil?)
         
     | 
| 
      
 1573 
     | 
    
         
            +
              end
         
     | 
| 
      
 1574 
     | 
    
         
            +
             
     | 
| 
      
 1575 
     | 
    
         
            +
              def test_update_dialog_node
         
     | 
| 
      
 1576 
     | 
    
         
            +
                service = IBMWatson::AssistantV1.new(
         
     | 
| 
      
 1577 
     | 
    
         
            +
                  username: "username",
         
     | 
| 
      
 1578 
     | 
    
         
            +
                  password: "password",
         
     | 
| 
      
 1579 
     | 
    
         
            +
                  version: "2018-02-16"
         
     | 
| 
      
 1580 
     | 
    
         
            +
                )
         
     | 
| 
      
 1581 
     | 
    
         
            +
                stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/workspace_id/dialog_nodes/dialog_node?version=2018-02-16")
         
     | 
| 
      
 1582 
     | 
    
         
            +
                  .with(
         
     | 
| 
      
 1583 
     | 
    
         
            +
                    body: "{\"description\":\"A new description\"}",
         
     | 
| 
      
 1584 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 1585 
     | 
    
         
            +
                      "Accept" => "application/json",
         
     | 
| 
      
 1586 
     | 
    
         
            +
                      "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
         
     | 
| 
      
 1587 
     | 
    
         
            +
                      "Content-Type" => "application/json",
         
     | 
| 
      
 1588 
     | 
    
         
            +
                      "Host" => "gateway.watsonplatform.net"
         
     | 
| 
      
 1589 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1590 
     | 
    
         
            +
                  ).to_return(status: 200, body: "Pseudo update dialog node response", headers: {})
         
     | 
| 
      
 1591 
     | 
    
         
            +
                service_response = service.update_dialog_node(
         
     | 
| 
      
 1592 
     | 
    
         
            +
                  workspace_id: "workspace_id",
         
     | 
| 
      
 1593 
     | 
    
         
            +
                  dialog_node: "dialog_node",
         
     | 
| 
      
 1594 
     | 
    
         
            +
                  new_description: "A new description"
         
     | 
| 
      
 1595 
     | 
    
         
            +
                )
         
     | 
| 
      
 1596 
     | 
    
         
            +
                assert_equal("Pseudo update dialog node response", service_response.result)
         
     | 
| 
      
 1597 
     | 
    
         
            +
              end
         
     | 
| 
      
 1598 
     | 
    
         
            +
            end
         
     |