コード例 #1
0
  @Test
  public void AIDataServiceDevRuTest() {
    final String devUrl = getDevUrl();
    if (!TextUtils.isEmpty(devUrl)) {
      final AIConfiguration config =
          new AIConfiguration(
              "43a7541fb0a94fae8f1bef406a2d9ca8",
              getSubscriptionKey(),
              AIConfiguration.SupportedLanguages.Russian,
              AIConfiguration.RecognitionEngine.System);

      config.setServiceUrl(devUrl);

      final AIDataService aiDataService = new AIDataService(Robolectric.application, config);

      final AIRequest aiRequest = new AIRequest();
      aiRequest.setQuery("привет");

      try {
        final AIResponse aiResponse = makeRequest(aiDataService, aiRequest);

        assertFalse(TextUtils.isEmpty(aiResponse.getResult().getResolvedQuery()));
        assertEquals("helloAction", aiResponse.getResult().getAction());
        assertEquals("Добрый день", aiResponse.getResult().getFulfillment().getSpeech());

      } catch (final AIServiceException e) {
        e.printStackTrace();
        assertTrue(e.getMessage(), false);
      }
    } else {
      assertTrue(true);
    }
  }
コード例 #2
0
  @Test
  public void AIDataServiceDevTest() {
    final String devUrl = getDevUrl();
    if (!TextUtils.isEmpty(devUrl)) {
      final AIConfiguration config =
          new AIConfiguration(
              getAccessToken(),
              getSubscriptionKey(),
              AIConfiguration.SupportedLanguages.English,
              AIConfiguration.RecognitionEngine.System);

      config.setServiceUrl(devUrl);

      final AIDataService aiDataService = new AIDataService(Robolectric.application, config);

      final AIRequest aiRequest = new AIRequest();
      aiRequest.setQuery("hello");

      try {
        final AIResponse aiResponse = makeRequest(aiDataService, aiRequest);

        assertFalse(TextUtils.isEmpty(aiResponse.getResult().getResolvedQuery()));
        assertEquals("greeting", aiResponse.getResult().getAction());
        assertEquals("Hi! How are you?", aiResponse.getResult().getFulfillment().getSpeech());

      } catch (final AIServiceException e) {
        e.printStackTrace();
        assertTrue(e.getMessage(), false);
      }
    } else {
      assertTrue(true);
    }
  }