use of com.google.cloud.language.v1.AnnotateTextRequest.Features 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.v1.AnnotateTextRequest.Features in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method annotateTextTest.
@Test
@SuppressWarnings("all")
public void annotateTextTest() {
String language = "language-1613589672";
AnnotateTextResponse expectedResponse = AnnotateTextResponse.newBuilder().setLanguage(language).build();
mockLanguageService.addResponse(expectedResponse);
Document document = Document.newBuilder().build();
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
AnnotateTextResponse actualResponse = client.annotateText(document, features, encodingType);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
Assert.assertEquals(1, actualRequests.size());
AnnotateTextRequest actualRequest = (AnnotateTextRequest) actualRequests.get(0);
Assert.assertEquals(document, actualRequest.getDocument());
Assert.assertEquals(features, actualRequest.getFeatures());
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
}
use of com.google.cloud.language.v1.AnnotateTextRequest.Features in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method annotateTextTest.
@Test
@SuppressWarnings("all")
public void annotateTextTest() {
String language = "language-1613589672";
AnnotateTextResponse expectedResponse = AnnotateTextResponse.newBuilder().setLanguage(language).build();
mockLanguageService.addResponse(expectedResponse);
Document document = Document.newBuilder().build();
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
AnnotateTextResponse actualResponse = client.annotateText(document, features, encodingType);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
Assert.assertEquals(1, actualRequests.size());
AnnotateTextRequest actualRequest = (AnnotateTextRequest) actualRequests.get(0);
Assert.assertEquals(document, actualRequest.getDocument());
Assert.assertEquals(features, actualRequest.getFeatures());
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
}
use of com.google.cloud.language.v1.AnnotateTextRequest.Features 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());
}
}
Aggregations