Search in sources :

Example 66 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project k-9 by k9mail.

the class SettingsExporterTest method exportPreferences_exportsGlobalSettingsWhenRequested.

@Test
public void exportPreferences_exportsGlobalSettingsWhenRequested() throws Exception {
    Document document = exportPreferences(true, Collections.<String>emptySet());
    assertNotNull(document.getRootElement().getChild("global"));
}
Also used : Document(org.jdom2.Document) Test(org.junit.Test)

Example 67 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project k-9 by k9mail.

the class SettingsExporterTest method exportPreferences_producesXML.

@Test
public void exportPreferences_producesXML() throws Exception {
    Document document = exportPreferences(false, Collections.<String>emptySet());
    assertEquals("k9settings", document.getRootElement().getName());
}
Also used : Document(org.jdom2.Document) Test(org.junit.Test)

Example 68 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project k-9 by k9mail.

the class SettingsExporterTest method exportPreferences.

private Document exportPreferences(boolean globalSettings, Set<String> accounts) throws Exception {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    SettingsExporter.exportPreferences(RuntimeEnvironment.application, outputStream, globalSettings, accounts);
    Document document = parseXML(outputStream.toByteArray());
    outputStream.close();
    return document;
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(org.jdom2.Document)

Example 69 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project google-cloud-java by GoogleCloudPlatform.

the class AnalyzeSentiment method main.

public static void main(String... args) throws Exception {
    // Instantiates a client
    LanguageServiceClient language = LanguageServiceClient.create();
    // The text to analyze
    String[] texts = { "I love this!", "I hate this!" };
    for (String text : texts) {
        Document doc = Document.newBuilder().setContent(text).setType(Type.PLAIN_TEXT).build();
        // Detects the sentiment of the text
        Sentiment sentiment = language.analyzeSentiment(doc).getDocumentSentiment();
        System.out.printf("Text: \"%s\"%n", text);
        System.out.printf("Sentiment: score = %s, magnitude = %s%n", sentiment.getScore(), sentiment.getMagnitude());
    }
}
Also used : LanguageServiceClient(com.google.cloud.language.spi.v1.LanguageServiceClient) Document(com.google.cloud.language.v1.Document) Sentiment(com.google.cloud.language.v1.Sentiment)

Example 70 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project google-cloud-java by GoogleCloudPlatform.

the class LanguageServiceClientTest method analyzeEntitySentimentTest.

@Test
@SuppressWarnings("all")
public void analyzeEntitySentimentTest() {
    String language = "language-1613589672";
    AnalyzeEntitySentimentResponse expectedResponse = AnalyzeEntitySentimentResponse.newBuilder().setLanguage(language).build();
    mockLanguageService.addResponse(expectedResponse);
    Document document = Document.newBuilder().build();
    EncodingType encodingType = EncodingType.NONE;
    AnalyzeEntitySentimentResponse actualResponse = client.analyzeEntitySentiment(document, encodingType);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    AnalyzeEntitySentimentRequest actualRequest = (AnalyzeEntitySentimentRequest) actualRequests.get(0);
    Assert.assertEquals(document, actualRequest.getDocument());
    Assert.assertEquals(encodingType, actualRequest.getEncodingType());
}
Also used : AnalyzeEntitySentimentRequest(com.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest) EncodingType(com.google.cloud.language.v1beta2.EncodingType) Document(com.google.cloud.language.v1beta2.Document) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) AnalyzeEntitySentimentResponse(com.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse) Test(org.junit.Test)

Aggregations

Document (org.jdom2.Document)86 Element (org.jdom2.Element)57 File (java.io.File)29 Test (org.junit.Test)24 DocType (org.jdom2.DocType)23 SAXBuilder (org.jdom2.input.SAXBuilder)20 IOException (java.io.IOException)16 XMLOutputter (org.jdom2.output.XMLOutputter)14 ProcessingInstruction (org.jdom2.ProcessingInstruction)13 XmlFile (jmri.jmrit.XmlFile)11 Document (com.google.cloud.language.v1beta2.Document)10 ApiException (com.google.api.gax.grpc.ApiException)9 Document (com.google.cloud.language.v1.Document)9 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)9 StatusRuntimeException (io.grpc.StatusRuntimeException)9 EncodingType (com.google.cloud.language.v1beta2.EncodingType)8 FileOutputStream (java.io.FileOutputStream)7 EncodingType (com.google.cloud.language.v1.EncodingType)6 FileNotFoundException (java.io.FileNotFoundException)6 JDOMException (org.jdom2.JDOMException)6