use of org.molgenis.data.file.processor.CellProcessor in project molgenis by molgenis.
the class ExcelWriterTest method addCellProcessor_header.
@Test
public void addCellProcessor_header() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processHeader()).thenReturn(true).getMock();
OutputStream os = mock(OutputStream.class);
ExcelWriter excelWriter = new ExcelWriter(os, attrMetaFactory);
excelWriter.addCellProcessor(processor);
try {
excelWriter.createWritable("sheet", Arrays.asList("col1", "col2"));
} finally {
excelWriter.close();
}
verify(processor).process("col1");
verify(processor).process("col2");
}
use of org.molgenis.data.file.processor.CellProcessor in project molgenis by molgenis.
the class ExcelWriterTest method addCellProcessor_data.
@Test
public void addCellProcessor_data() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();
OutputStream os = mock(OutputStream.class);
ExcelWriter excelWriter = new ExcelWriter(os, attrMetaFactory);
excelWriter.addCellProcessor(processor);
try {
Entity entity = new DynamicEntity(mock(EntityType.class)) {
@Override
protected void validateValueType(String attrName, Object value) {
// noop
}
};
entity.set("col1", "val1");
entity.set("col2", "val2");
Writable writable = excelWriter.createWritable("test", Arrays.asList("col1", "col2"));
writable.add(entity);
} finally {
excelWriter.close();
}
verify(processor).process("val1");
verify(processor).process("val2");
}
use of org.molgenis.data.file.processor.CellProcessor in project molgenis by molgenis.
the class ExcelRepositoryTest method addCellProcessor_header.
@Test
public void addCellProcessor_header() {
CellProcessor processor = mock(CellProcessor.class);
when(processor.processHeader()).thenReturn(true);
when(processor.process("col1")).thenReturn("col1");
when(processor.process("col2")).thenReturn("col2");
excelSheetReader.addCellProcessor(processor);
for (@SuppressWarnings("unused") Entity entity : excelSheetReader) {
}
verify(processor).process("col1");
verify(processor).process("col2");
}
use of org.molgenis.data.file.processor.CellProcessor in project molgenis by molgenis.
the class CsvRepositoryTest method addCellProcessor_data.
@Test
public void addCellProcessor_data() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();
try (CsvRepository csvRepository = new CsvRepository(test, entityTypeFactory, attrMetaFactory, null)) {
csvRepository.addCellProcessor(processor);
for (@SuppressWarnings("unused") Entity entity : csvRepository) {
}
verify(processor).process("val1");
verify(processor).process("val2");
}
}
Aggregations