use of org.datanucleus.samples.annotations.one_many.bidir_3.Document in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeEntitiesTest.
@Test
@SuppressWarnings("all")
public void analyzeEntitiesTest() {
String language = "language-1613589672";
AnalyzeEntitiesResponse expectedResponse = AnalyzeEntitiesResponse.newBuilder().setLanguage(language).build();
mockLanguageService.addResponse(expectedResponse);
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
AnalyzeEntitiesResponse actualResponse = client.analyzeEntities(document, encodingType);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
Assert.assertEquals(1, actualRequests.size());
AnalyzeEntitiesRequest actualRequest = (AnalyzeEntitiesRequest) actualRequests.get(0);
Assert.assertEquals(document, actualRequest.getDocument());
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
}
use of org.datanucleus.samples.annotations.one_many.bidir_3.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());
}
use of org.datanucleus.samples.annotations.one_many.bidir_3.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 org.datanucleus.samples.annotations.one_many.bidir_3.Document in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeSyntaxExceptionTest.
@Test
@SuppressWarnings("all")
public void analyzeSyntaxExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
client.analyzeSyntax(document, encodingType);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of org.datanucleus.samples.annotations.one_many.bidir_3.Document in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeEntitiesTest.
@Test
@SuppressWarnings("all")
public void analyzeEntitiesTest() {
String language = "language-1613589672";
AnalyzeEntitiesResponse expectedResponse = AnalyzeEntitiesResponse.newBuilder().setLanguage(language).build();
mockLanguageService.addResponse(expectedResponse);
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
AnalyzeEntitiesResponse actualResponse = client.analyzeEntities(document, encodingType);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
Assert.assertEquals(1, actualRequests.size());
AnalyzeEntitiesRequest actualRequest = (AnalyzeEntitiesRequest) actualRequests.get(0);
Assert.assertEquals(document, actualRequest.getDocument());
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
}
Aggregations