Search in sources :

Example 51 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project molgenis by molgenis.

the class MolgenisWebAppConfig method configureMessageConverters.

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    converters.add(gsonHttpMessageConverter);
    converters.add(new BufferedImageHttpMessageConverter());
    converters.add(new CsvHttpMessageConverter());
    converters.add(new ResourceHttpMessageConverter());
    converters.add(new StringHttpMessageConverter());
    converters.add(rdfConverter);
}
Also used : BufferedImageHttpMessageConverter(org.springframework.http.converter.BufferedImageHttpMessageConverter) ResourceHttpMessageConverter(org.springframework.http.converter.ResourceHttpMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) CsvHttpMessageConverter(org.molgenis.core.ui.messageconverter.CsvHttpMessageConverter)

Example 52 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project molgenis by molgenis.

the class OneClickImporterControllerTest method before.

@BeforeMethod
public void before() {
    OneClickImporterController oneClickImporterController = new OneClickImporterController(menuReaderService, appSettings, userAccountService, fileStore, oneClickImportJobExecutionFactory, jobExecutor);
    Menu menu = mock(Menu.class);
    when(menu.findMenuItemPath(OneClickImporterController.ONE_CLICK_IMPORTER)).thenReturn("/test-path");
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(localeResolver.resolveLocale(any())).thenReturn(new Locale("nl"));
    when(appSettings.getLanguageCode()).thenReturn("en");
    User user = mock(User.class);
    when(user.isSuperuser()).thenReturn(false);
    when(userAccountService.getCurrentUser()).thenReturn(user);
    OneClickImportJobExecution jobExecution = mock(OneClickImportJobExecution.class);
    when(oneClickImportJobExecutionFactory.create()).thenReturn(jobExecution);
    EntityType oneClickImportJobExecutionEntityType = mock(EntityType.class);
    when(jobExecution.getEntityType()).thenReturn(oneClickImportJobExecutionEntityType);
    when(jobExecution.getIdValue()).thenReturn("id_1");
    when(oneClickImportJobExecutionEntityType.getId()).thenReturn("jobExecutionId");
    StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
    stringConverter.setWriteAcceptCharset(false);
    mockMvc = MockMvcBuilders.standaloneSetup(oneClickImporterController).setLocaleResolver(localeResolver).setMessageConverters(gsonHttpMessageConverter, stringConverter).build();
}
Also used : Locale(java.util.Locale) EntityType(org.molgenis.data.meta.model.EntityType) User(org.molgenis.data.security.auth.User) Menu(org.molgenis.core.ui.menu.Menu) OneClickImportJobExecution(org.molgenis.oneclickimporter.job.OneClickImportJobExecution) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 53 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project molgenis by molgenis.

the class MappingServiceControllerTest method beforeTest.

@BeforeMethod
public void beforeTest() {
    me = mock(User.class);
    when(me.getUsername()).thenReturn("fdlk");
    TestingAuthenticationToken authentication = new TestingAuthenticationToken("fdlk", null);
    authentication.setAuthenticated(true);
    SecurityContextHolder.getContext().setAuthentication(authentication);
    hop = entityTypeFactory.create("HOP");
    ageAttr = attrMetaFactory.create().setName("age").setDataType(INT);
    hop.addAttribute(ageAttr);
    dobAttr = attrMetaFactory.create().setName("dob").setDataType(DATE);
    hop.addAttribute(dobAttr);
    hop.setAbstract(true);
    lifeLines = entityTypeFactory.create("LifeLines");
    mappingProject = new MappingProject("hop hop hop", me);
    mappingProject.setIdentifier("asdf");
    MappingTarget mappingTarget = mappingProject.addTarget(hop);
    EntityMapping entityMapping = mappingTarget.addSource(lifeLines);
    AttributeMapping attributeMapping = entityMapping.addAttributeMapping("age");
    attributeMapping.setAlgorithm("$('dob').age()");
    when(dataService.getMeta()).thenReturn(metaDataService);
    mockMvc = MockMvcBuilders.standaloneSetup(controller).setMessageConverters(gsonHttpMessageConverter, new StringHttpMessageConverter()).build();
}
Also used : EntityMapping(org.molgenis.semanticmapper.mapping.model.EntityMapping) MappingProject(org.molgenis.semanticmapper.mapping.model.MappingProject) User(org.molgenis.data.security.auth.User) AttributeMapping(org.molgenis.semanticmapper.mapping.model.AttributeMapping) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) MappingTarget(org.molgenis.semanticmapper.mapping.model.MappingTarget) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 54 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project codekvast by crispab.

the class AgentControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    this.mockMvc = MockMvcBuilders.standaloneSetup(agentController).setMessageConverters(new GsonHttpMessageConverter(), new StringHttpMessageConverter()).build();
}
Also used : GsonHttpMessageConverter(org.springframework.http.converter.json.GsonHttpMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) Before(org.junit.Before)

Example 55 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project nakadi by zalando.

the class WebConfig method configureMessageConverters.

@Override
protected void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
    final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
    stringConverter.setWriteAcceptCharset(false);
    converters.add(new ByteArrayHttpMessageConverter());
    converters.add(stringConverter);
    converters.add(new ResourceHttpMessageConverter());
    converters.add(new SourceHttpMessageConverter<>());
    converters.add(mappingJackson2HttpMessageConverter());
    super.configureMessageConverters(converters);
}
Also used : ResourceHttpMessageConverter(org.springframework.http.converter.ResourceHttpMessageConverter) ByteArrayHttpMessageConverter(org.springframework.http.converter.ByteArrayHttpMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter)

Aggregations

StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)93 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)48 ArrayList (java.util.ArrayList)38 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)27 ByteArrayHttpMessageConverter (org.springframework.http.converter.ByteArrayHttpMessageConverter)24 RestTemplate (org.springframework.web.client.RestTemplate)23 Test (org.junit.jupiter.api.Test)21 ResourceHttpMessageConverter (org.springframework.http.converter.ResourceHttpMessageConverter)18 Test (org.junit.Test)16 AllEncompassingFormHttpMessageConverter (org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter)16 MappingJackson2XmlHttpMessageConverter (org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter)11 MediaType (org.springframework.http.MediaType)9 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)9 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)7 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)7 URI (java.net.URI)7 HashMap (java.util.HashMap)7 MethodParameter (org.springframework.core.MethodParameter)7 MapPropertySource (org.springframework.core.env.MapPropertySource)7 StandardEnvironment (org.springframework.core.env.StandardEnvironment)7