@Test public void testGetVirtualSize() throws Exception { final long virtualSize = 2000; final long actualSize = 1000; final File mockFile = Mockito.mock(File.class); Mockito.when(mockFile.length()).thenReturn(actualSize); Mockito.doReturn(virtualSize).when(this.processor).getTemplateVirtualSize((File) Mockito.any()); Assert.assertEquals(virtualSize, this.processor.getVirtualSize(mockFile)); Mockito.verify(mockFile, Mockito.times(0)).length(); }
@Override public long getVirtualSize(final File file) throws IOException { try { final long size = getTemplateVirtualSize(file); return size; } catch (final Exception e) { s_logger.info("[ignored]" + "failed to get template virtual size for VHD: " + e.getLocalizedMessage()); } return file.length(); }
VhdProcessor extends AdapterBase implements Processor { @Override public long getVirtualSize(final File file) throws IOException { try { final long size = getTemplateVirtualSize(file); return size; } catch (final Exception e) { s_logger.info("[ignored]" + "failed to get template virtual size for VHD: " + e.getLocalizedMessage()); } return file.length(); } }
VhdProcessor extends AdapterBase implements Processor { @Override public long getVirtualSize(final File file) throws IOException { try { final long size = getTemplateVirtualSize(file); return size; } catch (final Exception e) { s_logger.info("[ignored]" + "failed to get template virtual size for VHD: " + e.getLocalizedMessage()); } return file.length(); }  }
VhdProcessor extends AdapterBase implements Processor { @Override public long getVirtualSize(final File file) throws IOException { try { final long size = getTemplateVirtualSize(file); return size; } catch (final Exception e) { s_logger.info("[ignored]" + "failed to get template virtual size for VHD: " + e.getLocalizedMessage()); } return file.length(); }  @Override TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName); @Override long getVirtualSize(final File file); @Override boolean configure(final String name, final Map<String, Object> params); }
VhdProcessor extends AdapterBase implements Processor { @Override public long getVirtualSize(final File file) throws IOException { try { final long size = getTemplateVirtualSize(file); return size; } catch (final Exception e) { s_logger.info("[ignored]" + "failed to get template virtual size for VHD: " + e.getLocalizedMessage()); } return file.length(); }  @Override TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName); @Override long getVirtualSize(final File file); @Override boolean configure(final String name, final Map<String, Object> params);  }