Ejemplo n.º 1
0
 /*
  * (non-Javadoc)
  *
  * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp()
  */
 @Override
 @Before
 public void setUp() throws Exception {
   super.setUp();
   service = new ToneAnalyzer(ToneAnalyzer.VERSION_DATE_2016_02_11);
   service.setApiKey("");
   service.setEndPoint(MOCK_SERVER_URL);
 }
Ejemplo n.º 2
0
  /**
   * Test get tone.
   *
   * @throws FileNotFoundException the file not found exception
   */
  @Test
  public void testGetTone() throws FileNotFoundException {
    final String text =
        "I know the times are difficult! Our sales have been "
            + "disappointing for the past three quarters for our data analytics "
            + "product suite. We have a competitive data analytics product "
            + "suite in the industry. But we need to do our job selling it! ";

    ToneAnalysis response = loadFixture(FIXTURE, ToneAnalysis.class);

    final JsonObject contentJson = new JsonObject();
    contentJson.addProperty(TEXT, text);

    mockServer
        .when(
            request()
                .withMethod(POST)
                .withPath(TONE_PATH)
                .withQueryStringParameter(VERSION_DATE, ToneAnalyzer.VERSION_DATE_2016_02_11)
                .withBody(contentJson.toString()))
        .respond(
            response()
                .withHeader(HttpHeaders.CONTENT_TYPE, HttpMediaType.APPLICATION_JSON)
                .withBody(response.toString()));

    // Call the service and compare the result
    Assert.assertEquals(response, service.getTone(text).execute());
  }
Ejemplo n.º 3
0
 /** Test tone with null. */
 @Test(expected = IllegalArgumentException.class)
 public void testGetToneWithNull() {
   service.getTone(null);
 }