/** * * * <pre> * The enabled features. * </pre> * * <code>.google.cloud.language.v1.AnnotateTextRequest.Features features = 2;</code> */ public Builder mergeFeatures(com.google.cloud.language.v1.AnnotateTextRequest.Features value) { if (featuresBuilder_ == null) { if (features_ != null) { features_ = com.google.cloud.language.v1.AnnotateTextRequest.Features.newBuilder(features_) .mergeFrom(value) .buildPartial(); } else { features_ = value; } onChanged(); } else { featuresBuilder_.mergeFrom(value); } return this; } /**
@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()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
/** * * * <pre> * The enabled features. * </pre> * * <code>.google.cloud.language.v1.AnnotateTextRequest.Features features = 2;</code> */ public Builder mergeFeatures(com.google.cloud.language.v1.AnnotateTextRequest.Features value) { if (featuresBuilder_ == null) { if (features_ != null) { features_ = com.google.cloud.language.v1.AnnotateTextRequest.Features.newBuilder(features_) .mergeFrom(value) .buildPartial(); } else { features_ = value; } onChanged(); } else { featuresBuilder_.mergeFrom(value); } return this; } /**
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@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 (InvalidArgumentException e) { // Expected exception } } }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }