test_class.declarator: processor
test_class.original_string: QCOW2Processor processor;
test_class.type: QCOW2Processor
test_class.var_name: processor
test_class.declarator: mockStorageLayer
test_class.modifier: @Mock
test_class.original_string: @Mock
      StorageLayer mockStorageLayer;
test_class.type: StorageLayer
test_class.var_name: mockStorageLayer
test_class.file: cosmic-common/src/test/java/com/cloud/common/storageprocessor/QCOW2ProcessorTest.java
test_class.identifier: QCOW2ProcessorTest
test_case.body: @Test
      public void testProcess() throws Exception {
          final String templatePath = "/tmp";
          final String templateName = "template";
          final long virtualSize = 2000;
          final long actualSize = 1000;
  
          Mockito.when(this.mockStorageLayer.exists(Mockito.anyString())).thenReturn(true);
          final File mockFile = Mockito.mock(File.class);
  
          Mockito.when(this.mockStorageLayer.getFile(Mockito.anyString())).thenReturn(mockFile);
          Mockito.when(this.mockStorageLayer.getSize(Mockito.anyString())).thenReturn(actualSize);
          Mockito.doReturn(virtualSize).when(this.processor).getTemplateVirtualSize((File) Mockito.any());
  
          final TemplateFormatInfo info = this.processor.process(templatePath, null, templateName);
          Assert.assertEquals(ImageFormat.QCOW2, info.format);
          Assert.assertEquals(actualSize, info.size);
          Assert.assertEquals(virtualSize, info.virtualSize);
          Assert.assertEquals(templateName + ".qcow2", info.filename);
      }
test_case.class_method_signature: QCOW2ProcessorTest.testProcess()
test_case.full_signature: @Test public void testProcess()
test_case.identifier: testProcess
test_case.invocations: thenReturn when exists anyString mock thenReturn when getFile anyString thenReturn when getSize anyString getTemplateVirtualSize when doReturn any process assertEquals assertEquals assertEquals assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testProcess()
focal_class.declarator: s_logger = LoggerFactory.getLogger(QCOW2Processor.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger s_logger = LoggerFactory.getLogger(QCOW2Processor.class);
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.declarator: VIRTUALSIZE_HEADER_LOCATION = 24
focal_class.modifier: private static final
focal_class.original_string: private static final int VIRTUALSIZE_HEADER_LOCATION = 24;
focal_class.type: int
focal_class.var_name: VIRTUALSIZE_HEADER_LOCATION
focal_class.declarator: _storage
focal_class.modifier: private
focal_class.original_string: private StorageLayer _storage;
focal_class.type: StorageLayer
focal_class.var_name: _storage
focal_class.file: cosmic-common/src/main/java/com/cloud/common/storageprocessor/QCOW2Processor.java
focal_class.identifier: QCOW2Processor
focal_class.interfaces: implements Processor
focal_class.class_method_signature: QCOW2Processor.process(final String templatePath, final ImageFormat format, final String templateName)
focal_class.full_signature: @Override public TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName)
focal_class.identifier: process
focal_class.modifiers: @Override public
focal_class.parameters: (final String templatePath, final ImageFormat format, final String templateName)
focal_class.return: TemplateFormatInfo
focal_class.signature: TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName)
focal_class.class_method_signature: QCOW2Processor.getVirtualSize(final File file)
focal_class.full_signature: @Override public long getVirtualSize(final File file)
focal_class.identifier: getVirtualSize
focal_class.modifiers: @Override public
focal_class.parameters: (final File file)
focal_class.return: long
focal_class.signature: long getVirtualSize(final File file)
focal_class.class_method_signature: QCOW2Processor.getTemplateVirtualSize(final File file)
focal_class.full_signature: protected long getTemplateVirtualSize(final File file)
focal_class.identifier: getTemplateVirtualSize
focal_class.modifiers: protected
focal_class.parameters: (final File file)
focal_class.return: long
focal_class.signature: long getTemplateVirtualSize(final File file)
focal_class.class_method_signature: QCOW2Processor.configure(final String name, final Map<String, Object> params)
focal_class.full_signature: @Override public boolean configure(final String name, final Map<String, Object> params)
focal_class.identifier: configure
focal_class.modifiers: @Override public
focal_class.parameters: (final String name, final Map<String, Object> params)
focal_class.return: boolean
focal_class.signature: boolean configure(final String name, final Map<String, Object> params)
focal_class.superclass: extends AdapterBase
focal_method.body: @Override
      public TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName) throws InternalErrorException {
          if (format != null) {
              s_logger.debug("We currently don't handle conversion from " + format + " to QCOW2.");
              return null;
          }
  
          final String qcow2Path = templatePath + File.separator + templateName + "." + ImageFormat.QCOW2.toString().toLowerCase();
  
          if (!this._storage.exists(qcow2Path)) {
              s_logger.debug("Unable to find the qcow2 file: " + qcow2Path);
              return null;
          }
  
          final TemplateFormatInfo info = new TemplateFormatInfo();
          info.format = ImageFormat.QCOW2;
          info.filename = templateName + "." + ImageFormat.QCOW2.toString().toLowerCase();
  
          final File qcow2File = this._storage.getFile(qcow2Path);
  
          info.size = this._storage.getSize(qcow2Path);
  
          try {
              info.virtualSize = getTemplateVirtualSize(qcow2File);
          } catch (final IOException e) {
              s_logger.error("Unable to get virtual size from " + qcow2File.getName());
              throw new InternalErrorException("unable to get virtual size from qcow2 file");
          }
  
          return info;
      }
focal_method.class_method_signature: QCOW2Processor.process(final String templatePath, final ImageFormat format, final String templateName)
focal_method.full_signature: @Override public TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName)
focal_method.identifier: process
focal_method.invocations: debug toLowerCase toString exists debug toLowerCase toString getFile getSize getTemplateVirtualSize error getName
focal_method.modifiers: @Override public
focal_method.parameters: (final String templatePath, final ImageFormat format, final String templateName)
focal_method.return: TemplateFormatInfo
focal_method.signature: TemplateFormatInfo process(final String templatePath, final ImageFormat format, final String templateName)