use of com.google.cloud.language.v1beta2.Document in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeEntitySentimentExceptionTest.
@Test
@SuppressWarnings("all")
public void analyzeEntitySentimentExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
client.analyzeEntitySentiment(document, encodingType);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.cloud.language.v1beta2.Document in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeEntitiesExceptionTest.
@Test
@SuppressWarnings("all")
public void analyzeEntitiesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
client.analyzeEntities(document, encodingType);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.cloud.language.v1beta2.Document in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method annotateTextExceptionTest.
@Test
@SuppressWarnings("all")
public void annotateTextExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
client.annotateText(document, features, encodingType);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.cloud.language.v1beta2.Document 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());
}
use of com.google.cloud.language.v1beta2.Document in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeSyntaxTest.
@Test
@SuppressWarnings("all")
public void analyzeSyntaxTest() {
String language = "language-1613589672";
AnalyzeSyntaxResponse expectedResponse = AnalyzeSyntaxResponse.newBuilder().setLanguage(language).build();
mockLanguageService.addResponse(expectedResponse);
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
AnalyzeSyntaxResponse actualResponse = client.analyzeSyntax(document, encodingType);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
Assert.assertEquals(1, actualRequests.size());
AnalyzeSyntaxRequest actualRequest = (AnalyzeSyntaxRequest) actualRequests.get(0);
Assert.assertEquals(document, actualRequest.getDocument());
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
}
Aggregations