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