AutonomiccsSystemVmTemplateService implements InitializingBean { protected String constructSystemVmTemplateUrl(HypervisorType hypervisorType) { ImageFormat supportedImageFormat = HypervisorType.getSupportedImageFormat(hypervisorType); if (supportedImageFormat == null) { throw new CloudRuntimeException(String.format("Could not find a supported image format for hypervisor [%s]", hypervisorType)); } return String.format("%s/%s.%s", autonomiccsSystemVmsTemplateUrlBase, getAutonomiccsSystemVmTemplateName(hypervisorType), supportedImageFormat.getFileExtension()); }  boolean isTemplateRegisteredForHypervisor(HypervisorType hypervisorType); String getAutonomiccsSystemVmTemplateDisplayText(HypervisorType hypervisor); String getAutonomiccsSystemVmTemplateName(HypervisorType hypervisor); String getSystemVmTemplateUrl(HypervisorType hypervisor); VMTemplateVO findAutonomiccsSystemVmTemplate(HypervisorType hypervisor); @Override /** * This method is executed by Spring framework. * It configures the template's display text and name */ void afterPropertiesSet(); boolean isTemplateRegisteredAndReadyForHypervisor(HypervisorType hypervisorType);  }
@Test public void constructSystemVmTemplateUrlTest() { Mockito.doReturn(null).when(spy).getAutonomiccsSystemVmTemplateName(Mockito.any(HypervisorType.class)); Mockito.doReturn("autonomiccsSystemVmTemplateName-xenserver").when(spy).getAutonomiccsSystemVmTemplateName(Mockito.any(HypervisorType.class)); String result = spy.constructSystemVmTemplateUrl(HypervisorType.XenServer); Mockito.verify(spy).getAutonomiccsSystemVmTemplateName(Mockito.any(HypervisorType.class)); Assert.assertEquals("autonomiccsSystemVmsTemplateUrlBase/autonomiccsSystemVmTemplateName-xenserver.vhd", result); }
@Test(expected = CloudRuntimeException.class) public void constructSystemVmTemplateUrlTestExpectCloudRuntimeException() { spy.constructSystemVmTemplateUrl(HypervisorType.Any); }