use of org.molgenis.data.file.processor.CellProcessor in project molgenis by molgenis.
the class ExcelRepositoryTest method addCellProcessor_data.
@Test
public void addCellProcessor_data() {
CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();
excelSheetReader.addCellProcessor(processor);
for (Entity entity : excelSheetReader) entity.get("col2");
verify(processor).process("val2");
verify(processor).process("val4");
verify(processor).process("val6");
}
use of org.molgenis.data.file.processor.CellProcessor in project molgenis by molgenis.
the class ExcelSheetWriterTest method addCellProcessor.
@Test
public void addCellProcessor() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();
Entity entity = new DynamicEntity(mock(EntityType.class)) {
@Override
protected void validateValueType(String attrName, Object value) {
// noop
}
};
entity.set("col1", "val1");
entity.set("col2", "val2");
excelSheetWriter.addCellProcessor(processor);
excelSheetWriter.add(entity);
verify(processor).process("val1");
verify(processor).process("val2");
}
use of org.molgenis.data.file.processor.CellProcessor in project molgenis by molgenis.
the class CsvWriterTest method addCellProcessor_data.
@Test
public void addCellProcessor_data() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();
Entity entity = new DynamicEntity(entityType);
entity.set("col1", "val1");
entity.set("col2", "val2");
try (CsvWriter csvWriter = new CsvWriter(new StringWriter())) {
csvWriter.addCellProcessor(processor);
csvWriter.writeAttributeNames(Arrays.asList("col1", "col2"));
csvWriter.add(entity);
}
verify(processor).process("val1");
verify(processor).process("val2");
}
use of org.molgenis.data.file.processor.CellProcessor in project molgenis by molgenis.
the class CsvWriterTest method addCellProcessor.
@Test
public void addCellProcessor() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processHeader()).thenReturn(true).getMock();
try (CsvWriter csvWriter = new CsvWriter(new StringWriter())) {
csvWriter.addCellProcessor(processor);
csvWriter.writeAttributeNames(Arrays.asList("col1", "col2"));
}
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_header.
@Test
public void addCellProcessor_header() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processHeader()).thenReturn(true).getMock();
when(processor.process("col1")).thenReturn("col1");
when(processor.process("col2")).thenReturn("col2");
try (CsvRepository csvRepository = new CsvRepository(test, entityTypeFactory, attrMetaFactory, null)) {
csvRepository.addCellProcessor(processor);
for (@SuppressWarnings("unused") Entity entity : csvRepository) {
}
verify(processor).process("col1");
verify(processor).process("col2");
}
}
Aggregations