Search in sources :

Example 1 with AnalyzeSentimentResponse

use of com.google.cloud.language.v1beta2.AnalyzeSentimentResponse in project google-cloud-java by GoogleCloudPlatform.

the class LanguageServiceClientTest method analyzeSentimentTest.

@Test
@SuppressWarnings("all")
public void analyzeSentimentTest() {
    String language = "language-1613589672";
    AnalyzeSentimentResponse expectedResponse = AnalyzeSentimentResponse.newBuilder().setLanguage(language).build();
    mockLanguageService.addResponse(expectedResponse);
    Document document = Document.newBuilder().build();
    AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    AnalyzeSentimentRequest actualRequest = (AnalyzeSentimentRequest) actualRequests.get(0);
    Assert.assertEquals(document, actualRequest.getDocument());
}
Also used : AnalyzeSentimentResponse(com.google.cloud.language.v1beta2.AnalyzeSentimentResponse) Document(com.google.cloud.language.v1beta2.Document) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) AnalyzeSentimentRequest(com.google.cloud.language.v1beta2.AnalyzeSentimentRequest) Test(org.junit.Test)

Example 2 with AnalyzeSentimentResponse

use of com.google.cloud.language.v1beta2.AnalyzeSentimentResponse in project google-cloud-java by GoogleCloudPlatform.

the class LanguageServiceClientTest method analyzeSentimentTest.

@Test
@SuppressWarnings("all")
public void analyzeSentimentTest() {
    String language = "language-1613589672";
    AnalyzeSentimentResponse expectedResponse = AnalyzeSentimentResponse.newBuilder().setLanguage(language).build();
    mockLanguageService.addResponse(expectedResponse);
    Document document = Document.newBuilder().build();
    AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    AnalyzeSentimentRequest actualRequest = (AnalyzeSentimentRequest) actualRequests.get(0);
    Assert.assertEquals(document, actualRequest.getDocument());
}
Also used : AnalyzeSentimentResponse(com.google.cloud.language.v1.AnalyzeSentimentResponse) Document(com.google.cloud.language.v1.Document) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) AnalyzeSentimentRequest(com.google.cloud.language.v1.AnalyzeSentimentRequest) Test(org.junit.Test)

Aggregations

GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)2 Test (org.junit.Test)2 AnalyzeSentimentRequest (com.google.cloud.language.v1.AnalyzeSentimentRequest)1 AnalyzeSentimentResponse (com.google.cloud.language.v1.AnalyzeSentimentResponse)1 Document (com.google.cloud.language.v1.Document)1 AnalyzeSentimentRequest (com.google.cloud.language.v1beta2.AnalyzeSentimentRequest)1 AnalyzeSentimentResponse (com.google.cloud.language.v1beta2.AnalyzeSentimentResponse)1 Document (com.google.cloud.language.v1beta2.Document)1