Search in sources :

Example 1 with AnalyzeEntitySentimentRequest

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

the class LanguageServiceClientTest method analyzeEntitySentimentTest.

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

Aggregations

AnalyzeEntitySentimentRequest (com.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest)1 AnalyzeEntitySentimentResponse (com.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse)1 Document (com.google.cloud.language.v1beta2.Document)1 EncodingType (com.google.cloud.language.v1beta2.EncodingType)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Test (org.junit.Test)1