use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class FileMetaRepositoryDecoratorTest method testDeleteById.
@Test
public void testDeleteById() throws Exception {
FileMeta fileMeta = getMockFileMeta("id");
when(delegateRepository.findOneById("id")).thenReturn(fileMeta);
fileMetaRepositoryDecorator.deleteById("id");
verify(delegateRepository).deleteById("id");
verify(fileStore).delete("id");
}
use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class FileIngesterTest method ingest.
@Test
public void ingest() {
when(fileStoreDownloadMock.downloadFile(url, identifier, entityTypeId + ".csv")).thenReturn(f);
when(fileRepositoryCollectionFactoryMock.createFileRepositoryCollection(f)).thenReturn(fileRepositoryCollectionMock);
when(importServiceFactoryMock.getImportService(f, fileRepositoryCollectionMock)).thenReturn(importServiceMock);
when(importServiceMock.doImport(fileRepositoryCollectionMock, ADD_UPDATE_EXISTING, PACKAGE_DEFAULT)).thenReturn(report);
when(progress.getJobExecution()).thenReturn(mock(FileIngestJobExecution.class));
FileMeta fileMeta = fileIngester.ingest(entityTypeId, url, "CSV", identifier, progress);
verify(dataService).add("sys_FileMeta", fileMeta);
}
use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class StyleServiceImpl method addStyle.
@Override
public Style addStyle(String styleId, String bootstrap3FileName, InputStream bootstrap3StyleData, String bootstrap4FileName, InputStream bootstrap4StyleData) throws MolgenisStyleException {
if (dataService.getRepository(STYLE_SHEET).findOneById(styleId) != null) {
throw new MolgenisStyleException(String.format("A style with the same identifier (%s) already exists", styleId));
}
StyleSheet styleSheet = styleSheetFactory.create(styleId);
styleSheet.setName(styleId);
FileMeta bootstrap3ThemeFileMeta = createStyleSheetFileMeta(bootstrap3FileName, bootstrap3StyleData);
styleSheet.setBootstrap3Theme(bootstrap3ThemeFileMeta);
// Setting the bootstrap 4 style is optional
if (bootstrap4FileName != null && bootstrap4StyleData != null) {
FileMeta bootstrap4ThemeFileMeta = createStyleSheetFileMeta(bootstrap4FileName, bootstrap4StyleData);
styleSheet.setBootstrap4Theme(bootstrap4ThemeFileMeta);
}
dataService.add(STYLE_SHEET, styleSheet);
return Style.createLocal(styleSheet.getName());
}
use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class RestServiceTest method toEntityFileValueValid.
@Test
public void toEntityFileValueValid() throws ParseException {
String generatedId = "id";
String downloadUriAsString = "http://somedownloaduri";
ServletUriComponentsBuilder mockBuilder = mock(ServletUriComponentsBuilder.class);
UriComponents downloadUri = mock(UriComponents.class);
FileMeta fileMeta = mock(FileMeta.class);
Attribute fileAttr = when(mock(Attribute.class).getName()).thenReturn("fileAttr").getMock();
when(fileAttr.getDataType()).thenReturn(FILE);
when(idGenerator.generateId()).thenReturn(generatedId);
when(fileMetaFactory.create(generatedId)).thenReturn(fileMeta);
when(mockBuilder.replacePath(anyString())).thenReturn(mockBuilder);
when(mockBuilder.replaceQuery(null)).thenReturn(mockBuilder);
when(downloadUri.toUriString()).thenReturn(downloadUriAsString);
when(mockBuilder.build()).thenReturn(downloadUri);
when(servletUriComponentsBuilderFactory.fromCurrentRequest()).thenReturn(mockBuilder);
byte[] content = { 'a', 'b' };
MockMultipartFile mockMultipartFile = new MockMultipartFile("name", "fileName", "contentType", content);
assertEquals(restService.toEntityValue(fileAttr, mockMultipartFile, null), fileMeta);
}
use of org.molgenis.data.file.model.FileMeta in project molgenis by molgenis.
the class StyleServiceTest method getBootstrap4ThemeData.
@Test
public void getBootstrap4ThemeData() throws MolgenisStyleException {
String styleName = "my-style";
StyleSheet styleSheet = mock(StyleSheet.class);
when(styleSheet.getId()).thenReturn(styleName);
FileMeta fileMeta = mock(FileMeta.class);
String fileId = "fileId";
when(fileMeta.getId()).thenReturn(fileId);
when(styleSheet.getBootstrap4Theme()).thenReturn(fileMeta);
Query<StyleSheet> expectedQuery = new QueryImpl<StyleSheet>().eq(StyleSheetMetadata.NAME, styleName);
when(dataService.findOne(STYLE_SHEET, expectedQuery, StyleSheet.class)).thenReturn(styleSheet);
File styleFile = mock(File.class);
String mockFilePath = "mock/file/path";
when(styleFile.getPath()).thenReturn(mockFilePath);
when(fileStore.getFile(fileId)).thenReturn(styleFile);
BootstrapVersion version = BootstrapVersion.BOOTSTRAP_VERSION_4;
FileSystemResource themeData = styleService.getThemeData(styleName, version);
assertEquals(themeData.getPath(), mockFilePath);
}
Aggregations