use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project webanno by webanno.
the class CasToBratJsonTest method testGenerateBratJsonGetCollection.
/**
* generate BRAT JSON for the collection informations
*
* @throws IOException
* if an I/O error occurs.
*/
@Test
public void testGenerateBratJsonGetCollection() throws IOException {
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
String jsonFilePath = "target/test-output/output_cas_to_json_collection.json";
GetCollectionInformationResponse collectionInformation = new GetCollectionInformationResponse();
List<AnnotationLayer> layerList = new ArrayList<>();
AnnotationLayer layer = new AnnotationLayer();
layer.setId(1l);
layer.setDescription("span annoattion");
layer.setName("pos");
layer.setType(WebAnnoConst.SPAN_TYPE);
TagSet tagset = new TagSet();
tagset.setId(1l);
tagset.setDescription("pos");
tagset.setLanguage("de");
tagset.setName("STTS");
Tag tag = new Tag();
tag.setId(1l);
tag.setDescription("noun");
tag.setName("NN");
tag.setTagSet(tagset);
layerList.add(layer);
collectionInformation.addCollection("/Collection1/");
collectionInformation.addCollection("/Collection2/");
collectionInformation.addCollection("/Collection3/");
collectionInformation.addDocument("/Collection1/doc1");
collectionInformation.addDocument("/Collection2/doc1");
collectionInformation.addDocument("/Collection3/doc1");
collectionInformation.addDocument("/Collection1/doc2");
collectionInformation.addDocument("/Collection2/doc2");
collectionInformation.addDocument("/Collection3/doc2");
collectionInformation.setSearchConfig(new ArrayList<>());
List<String> tagSetNames = new ArrayList<>();
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.POS);
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.DEPENDENCY);
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.NAMEDENTITY);
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.COREFERENCE);
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.COREFRELTYPE);
JSONUtil.generatePrettyJson(jsonConverter, collectionInformation, new File(jsonFilePath));
assertThat(linesOf(new File("src/test/resources/output_cas_to_json_collection_expected.json"), "UTF-8")).isEqualTo(linesOf(new File(jsonFilePath), "UTF-8"));
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project steve by RWTH-i5-IDSG.
the class GithubReleaseCheckService method init.
@PostConstruct
private void init() {
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setReadTimeout(API_TIMEOUT_IN_MILLIS);
factory.setConnectTimeout(API_TIMEOUT_IN_MILLIS);
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.SnakeCaseStrategy());
restTemplate = new RestTemplate(Collections.singletonList(new MappingJackson2HttpMessageConverter(mapper)));
restTemplate.setRequestFactory(factory);
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project tutorials by eugenp.
the class WebConfig method configureMessageConverters.
// beans
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
converters.add(new MappingJackson2HttpMessageConverter());
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project earth-snow by justlive1.
the class WebConfig method jsonConverter.
@Primary
@Bean
public MappingJackson2HttpMessageConverter jsonConverter() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper());
converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8, MediaType.TEXT_PLAIN));
return converter;
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project taskana by Taskana.
the class WorkbasketControllerIntTest method getRestTemplate.
/**
* Return a REST template which is capable of dealing with responses in HAL format
*
* @return RestTemplate
*/
private RestTemplate getRestTemplate() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new Jackson2HalModule());
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
return template;
}
Aggregations