Search in sources :

Example 36 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class DepositionFileUploadDtoTest method testReadFileUploadResponse.

@Test
public void testReadFileUploadResponse() {
    String json = "{\n" + "  \"_embedded\" : {\n" + "    \"fileUploads\" : [ {\n" + "      \"fileUploadId\" : \"5d52af6207d5180001ecd186\",\n" + "      \"status\" : \"VALID\",\n" + "      \"type\" : \"METADATA\",\n" + "      \"fileName\" : \"file\",\n" + "      \"fileSize\" : 13654,\n" + "      \"_links\" : {\n" + "        \"self\" : {\n" + "          \"href\" : \"http://193.62.54.159/backend/v1/submissions/5d514e99dcf21d0001eee221/uploads" + "/5d52af6207d5180001ecd186\"\n" + "        }\n" + "      }\n" + "    } ]\n" + "  },\n" + "  \"_links\" : {\n" + "    \"self\" : {\n" + "      \"href\" : \"http://193.62.54.159/backend/v1/submissions/5d514e99dcf21d0001eee221/uploads\"\n" + "    }\n" + "  }\n" + "}";
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        objectMapper.registerModule(new JodaModule());
        DepositionFileUploadListWrapper files = objectMapper.readValue(json, DepositionFileUploadListWrapper.class);
        assertNotNull(files);
    // assertNotNull(publication.getPublications().get(0).getPublicationDate().year());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) DepositionFileUploadListWrapper(uk.ac.ebi.spot.goci.model.deposition.util.DepositionFileUploadListWrapper) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 37 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class DepositionPublicationTest method testDepositionPublicationRead.

@Test
public void testDepositionPublicationRead() {
    try {
        Resource resource = new ClassPathResource("publication.json");
        assertTrue(resource.exists());
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.registerModule(new JodaModule());
        DepositionPublication publication = objectMapper.readValue(resource.getFile(), DepositionPublication.class);
        assertNotNull(publication);
        assertNotNull(publication.getStatus());
        assertNotNull(publication.getPublicationDate().year());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : DepositionPublication(uk.ac.ebi.spot.goci.model.deposition.DepositionPublication) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) ClassPathResource(org.springframework.core.io.ClassPathResource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 38 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class DepositionPublicationTest method testDepositionPublicationWrite.

@Test
public void testDepositionPublicationWrite() {
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        objectMapper.registerModule(new JodaModule());
        DepositionPublication publication = new DepositionPublication();
        publication.setPublicationDate(new LocalDate());
        String json = objectMapper.writeValueAsString(publication);
        assertNotNull(json);
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : DepositionPublication(uk.ac.ebi.spot.goci.model.deposition.DepositionPublication) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) IOException(java.io.IOException) LocalDate(org.joda.time.LocalDate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 39 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class DepositionStudyDtoTest method testReadStudiesResponse.

@Test
public void testReadStudiesResponse() {
    String json = "{\n" + "  \"_embedded\" : {\n" + "    \"studies\" : [ {\n" + "      \"study_tag\" : \"30237584_1\",\n" + "      \"genotyping_technology\" : \"Genome-wide genotyping array\",\n" + "      \"array_manufacturer\" : \"Illumina\",\n" + "      \"array_information\" : \"\",\n" + "      \"imputation\" : false,\n" + "      \"variant_count\" : 696317,\n" + "      \"statistical_model\" : \"\",\n" + "      \"study_description\" : \"Primary validation\",\n" + "      \"trait\" : \"Resistant hypertension\",\n" + "      \"summary_statistics_file\" : \"EFO_1002006\",\n" + "      \"checksum\" : \"\",\n" + "      \"summary_statistics_assembly\" : \"\",\n" + "      \"_links\" : {\n" + "        \"parent\" : {\n" + "          \"href\" : \"http://193.62.54.159/backend/v1/submissions/5d514e99dcf21d0001eee221\"\n" + "        }\n" + "      }\n" + "    }, {\n" + "      \"study_tag\" : \"30237584_2\",\n" + "      \"genotyping_technology\" : \"Genome-wide genotyping array\",\n" + "      \"array_manufacturer\" : \"Illumina\",\n" + "      \"array_information\" : \"\",\n" + "      \"imputation\" : false,\n" + "      \"variant_count\" : 696317,\n" + "      \"statistical_model\" : \"\",\n" + "      \"study_description\" : \"Secondary validation\",\n" + "      \"trait\" : \"Resistant hypertension\",\n" + "      \"summary_statistics_file\" : \"EFO_1002006\",\n" + "      \"checksum\" : \"\",\n" + "      \"summary_statistics_assembly\" : \"\",\n" + "      \"_links\" : {\n" + "        \"parent\" : {\n" + "          \"href\" : \"http://193.62.54.159/backend/v1/submissions/5d514e99dcf21d0001eee221\"\n" + "        }\n" + "      }\n" + "    } ]\n" + "  },\n" + "  \"_links\" : {\n" + "    \"self\" : {\n" + "      \"href\" : \"http://193.62.54.159/backend/v1/submissions/5d514e99dcf21d0001eee221/studies\"\n" + "    }\n" + "  },\n" + "  \"page\" : {\n" + "    \"size\" : 20,\n" + "    \"totalElements\" : 2,\n" + "    \"totalPages\" : 1,\n" + "    \"number\" : 0\n" + "  }\n" + "}";
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        objectMapper.registerModule(new JodaModule());
        DepositionStudyListWrapper studies = objectMapper.readValue(json, DepositionStudyListWrapper.class);
        assertNotNull(studies);
    // assertNotNull(publication.getPublications().get(0).getPublicationDate().year());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : DepositionStudyListWrapper(uk.ac.ebi.spot.goci.model.deposition.util.DepositionStudyListWrapper) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 40 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class DepositionSubmissionTest method testReadSubmission.

@Test
public void testReadSubmission() {
    try {
        Resource resource = new ClassPathResource("submission.json");
        assertTrue(resource.exists());
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.registerModule(new JodaModule());
        DepositionSubmission submission = objectMapper.readValue(resource.getFile(), DepositionSubmission.class);
        assertNotNull(submission);
        assertTrue(submission.getCreated().getTimestamp().toString().equals("2019-08-12T11:41:43.861Z"));
        assertNotNull(submission.getStatus());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) ClassPathResource(org.springframework.core.io.ClassPathResource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)45 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)37 Test (org.junit.Test)15 IOException (java.io.IOException)14 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)7 ClassPathResource (org.springframework.core.io.ClassPathResource)6 Resource (org.springframework.core.io.Resource)6 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)5 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)5 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)5 SimpleDateFormat (java.text.SimpleDateFormat)4 Bean (org.springframework.context.annotation.Bean)4 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)3 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 Primary (org.springframework.context.annotation.Primary)3 MetricsModule (com.codahale.metrics.json.MetricsModule)2 PropertyNamingStrategy (com.fasterxml.jackson.databind.PropertyNamingStrategy)2 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)2 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)2