Search in sources :

Example 61 with XmlMapper

use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project dhis2-core by dhis2.

the class JobConfigurationSerializationTest method xmlWithEmptyArray.

@Test
void xmlWithEmptyArray() throws IOException {
    final XmlMapper xmlMapper = new XmlMapper();
    xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    xmlMapper.configure(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY, false);
    JobConfiguration jc = xmlMapper.readValue("<jobConfiguration lastUpdated=\"2019-03-26T22:57:44.649\" id=\"uB9oC4R2nTn\" created=\"2019-03-26T22:57:44.649\" name=\"Test Analytic\">\n" + "      <jobStatus>SCHEDULED</jobStatus>\n" + "      <displayName>Test Analytic</displayName>\n" + "      <enabled>true</enabled>\n" + "      <leaderOnlyJob>true</leaderOnlyJob>\n" + "      <externalAccess>false</externalAccess>\n" + "      <jobType>ANALYTICS_TABLE</jobType>\n" + "      <nextExecutionTime>2019-03-27T12:00:00.000</nextExecutionTime>\n" + "      <favorite>false</favorite>\n" + "      <configurable>true</configurable>\n" + "      <access>\n" + "        <read>true</read>\n" + "        <update>true</update>\n" + "        <externalize>false</externalize>\n" + "        <delete>true</delete>\n" + "        <write>true</write>\n" + "        <manage>true</manage>\n" + "      </access>\n" + "      <lastUpdatedBy id=\"xE7jOejl9FI\"/>\n" + "      <jobParameters>\n" + "        <lastYears>2</lastYears>\n" + "        <skipResourceTables>true</skipResourceTables>\n" + "        <skipTableTypes>\n" + "        </skipTableTypes>" + "        <skipPrograms>\n" + "        </skipPrograms>" + "      </jobParameters>\n" + "      <cronExpression>0 0 12 ? * MON-FRI</cronExpression>\n" + "    </jobConfiguration>", JobConfiguration.class);
    assertEquals("uB9oC4R2nTn", jc.getUid());
    assertEquals(JobStatus.SCHEDULED, jc.getJobStatus());
    assertEquals("Test Analytic", jc.getName());
    assertEquals("Test Analytic", jc.getDisplayName());
    assertTrue(jc.isEnabled());
    assertTrue(jc.isLeaderOnlyJob());
    assertEquals(JobType.ANALYTICS_TABLE, jc.getJobType());
    assertNull(jc.getNextExecutionTime());
    assertEquals("0 0 12 ? * MON-FRI", jc.getCronExpression());
    assertNotNull(jc.getJobParameters());
    assertEquals((Integer) 2, ((AnalyticsJobParameters) jc.getJobParameters()).getLastYears());
    assertTrue(((AnalyticsJobParameters) jc.getJobParameters()).isSkipResourceTables());
    assertNotNull(((AnalyticsJobParameters) jc.getJobParameters()).getSkipTableTypes());
    assertEquals(0, ((AnalyticsJobParameters) jc.getJobParameters()).getSkipTableTypes().size());
    assertEquals(0, ((AnalyticsJobParameters) jc.getJobParameters()).getSkipPrograms().size());
}
Also used : AnalyticsJobParameters(org.hisp.dhis.scheduling.parameters.AnalyticsJobParameters) XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper) Test(org.junit.jupiter.api.Test)

Example 62 with XmlMapper

use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project tikxml by Tickaroo.

the class JacksonMediumXmlBenchmark method parse.

public void parse(String xml) throws Exception {
    XmlMapper mapper = new XmlMapper();
    Feed feed = mapper.readValue(xml, Feed.class);
    System.out.println(getClass().getSimpleName() + " " + feed);
}
Also used : XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper)

Aggregations

XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)62 IOException (java.io.IOException)19 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)15 Test (org.junit.Test)15 InputStream (java.io.InputStream)9 File (java.io.File)8 HttpResponse (org.apache.http.HttpResponse)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)7 JacksonXmlModule (com.fasterxml.jackson.dataformat.xml.JacksonXmlModule)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Test (org.junit.jupiter.api.Test)5 BadRequestException (ninja.exceptions.BadRequestException)4 EntityReferences (org.apache.cloudstack.backup.veeam.api.EntityReferences)4 Ref (org.apache.cloudstack.backup.veeam.api.Ref)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)2 FileInputStream (java.io.FileInputStream)2