use of org.molgenis.oneclickimporter.job.OneClickImportJobExecution 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();
}
use of org.molgenis.oneclickimporter.job.OneClickImportJobExecution in project molgenis by molgenis.
the class OneClickImporterController method importFile.
@ResponseBody
@PostMapping(value = "/upload", produces = MediaType.TEXT_HTML_VALUE)
public String importFile(@RequestParam(value = "file") MultipartFile multipartFile) throws IOException {
String filename = multipartFile.getOriginalFilename();
fileStore.store(multipartFile.getInputStream(), filename);
OneClickImportJobExecution jobExecution = oneClickImportJobExecutionFactory.create();
jobExecution.setUser(getCurrentUsername());
jobExecution.setFile(filename);
jobExecutor.submit(jobExecution);
return concatEntityHref(jobExecution);
}
Aggregations