Ejemplo n.º 1
0
 @Test
 public void testReadCell() throws Exception {
   when(mockCell.getCellType()).thenReturn(Cell.CELL_TYPE_NUMERIC);
   final HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
   final HSSFCellStyle cellStyle = hssfWorkbook.createCellStyle();
   final Date currentDate = new Date();
   cellStyle.setDataFormat(
       hssfWorkbook.getCreationHelper().createDataFormat().getFormat("m/d/yyyy h:mm"));
   when(mockCell.getCellStyle()).thenReturn(cellStyle);
   when(mockCell.getDateCellValue()).thenReturn(currentDate);
   final Calendar calendar = calendarConverter.readCell(mockCell);
   assertNotNull(calendar);
   assertEquals(currentDate.getTime(), calendar.getTimeInMillis());
 }
Ejemplo n.º 2
0
 @Test
 public void testWriteCellWithNull() throws Exception {
   calendarConverter.writeCell(mockCell, null);
   verify(mockCell, never()).setCellValue(any(Calendar.class));
 }
Ejemplo n.º 3
0
 @Test
 public void testWriteCell() throws Exception {
   final Calendar calendar = Calendar.getInstance();
   calendarConverter.writeCell(mockCell, calendar);
   verify(mockCell).setCellValue(calendar);
 }
Ejemplo n.º 4
0
 @Test
 public void testReadCellWithAsNonDateFormatted() throws Exception {
   when(mockCell.getCellType()).thenReturn(Cell.CELL_TYPE_BOOLEAN);
   when(mockCell.getNumericCellValue()).thenReturn(-5.0E-324D);
   assertNull(calendarConverter.readCell(mockCell, ".*"));
 }
Ejemplo n.º 5
0
 @Test
 public void testReadCellWithAsNonNumeric() throws Exception {
   when(mockCell.getCellType()).thenReturn(Cell.CELL_TYPE_BOOLEAN);
   assertNull(calendarConverter.readCell(mockCell, ".*"));
 }
Ejemplo n.º 6
0
 @Test
 public void testReadCellWithNullCellAndRegex() throws Exception {
   assertNull(calendarConverter.readCell(null, ".*"));
 }