@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()); }
@Test public void testWriteCellWithNull() throws Exception { calendarConverter.writeCell(mockCell, null); verify(mockCell, never()).setCellValue(any(Calendar.class)); }
@Test public void testWriteCell() throws Exception { final Calendar calendar = Calendar.getInstance(); calendarConverter.writeCell(mockCell, calendar); verify(mockCell).setCellValue(calendar); }
@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, ".*")); }
@Test public void testReadCellWithAsNonNumeric() throws Exception { when(mockCell.getCellType()).thenReturn(Cell.CELL_TYPE_BOOLEAN); assertNull(calendarConverter.readCell(mockCell, ".*")); }
@Test public void testReadCellWithNullCellAndRegex() throws Exception { assertNull(calendarConverter.readCell(null, ".*")); }