Search in sources :

Example 11 with Document

use of org.geotoolkit.sml.xml.v100.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());
    }
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) EncodingType(com.google.cloud.language.v1beta2.EncodingType) Document(com.google.cloud.language.v1beta2.Document) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 12 with Document

use of org.geotoolkit.sml.xml.v100.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());
    }
}
Also used : AnnotateTextRequest(com.google.cloud.language.v1beta2.AnnotateTextRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) EncodingType(com.google.cloud.language.v1beta2.EncodingType) Document(com.google.cloud.language.v1beta2.Document) Features(com.google.cloud.language.v1beta2.AnnotateTextRequest.Features) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 13 with Document

use of org.geotoolkit.sml.xml.v100.Document 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());
}
Also used : AnnotateTextRequest(com.google.cloud.language.v1beta2.AnnotateTextRequest) EncodingType(com.google.cloud.language.v1beta2.EncodingType) AnnotateTextResponse(com.google.cloud.language.v1beta2.AnnotateTextResponse) Document(com.google.cloud.language.v1beta2.Document) Features(com.google.cloud.language.v1beta2.AnnotateTextRequest.Features) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 14 with Document

use of org.geotoolkit.sml.xml.v100.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());
}
Also used : AnalyzeEntitiesRequest(com.google.cloud.language.v1beta2.AnalyzeEntitiesRequest) AnalyzeEntitiesResponse(com.google.cloud.language.v1beta2.AnalyzeEntitiesResponse) EncodingType(com.google.cloud.language.v1beta2.EncodingType) Document(com.google.cloud.language.v1beta2.Document) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 15 with Document

use of org.geotoolkit.sml.xml.v100.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());
}
Also used : AnalyzeSyntaxRequest(com.google.cloud.language.v1beta2.AnalyzeSyntaxRequest) EncodingType(com.google.cloud.language.v1beta2.EncodingType) Document(com.google.cloud.language.v1beta2.Document) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) AnalyzeSyntaxResponse(com.google.cloud.language.v1beta2.AnalyzeSyntaxResponse) Test(org.junit.Test)

Aggregations

Document (org.jdom2.Document)882 Element (org.jdom2.Element)491 Test (org.junit.Test)320 IOException (java.io.IOException)211 SAXBuilder (org.jdom2.input.SAXBuilder)207 XMLOutputter (org.jdom2.output.XMLOutputter)144 File (java.io.File)131 JDOMException (org.jdom2.JDOMException)120 InputStream (java.io.InputStream)61 DocumentHelper.getDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getDocument)53 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)53 ArrayList (java.util.ArrayList)52 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)48 PID (edu.unc.lib.boxc.model.api.ids.PID)47 Path (java.nio.file.Path)46 HashMap (java.util.HashMap)46 List (java.util.List)36 Attribute (org.jdom2.Attribute)35 Document (com.google.cloud.language.v1.Document)34 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)34