3636import java .util .UUID ;
3737
3838import com .cloud .user .User ;
39+ import org .apache .cloudstack .engine .subsystem .api .storage .ZoneScope ;
40+ import org .apache .cloudstack .storage .datastore .db .ImageStoreDao ;
41+ import org .apache .cloudstack .storage .datastore .db .ImageStoreVO ;
3942import org .apache .log4j .Logger ;
4043import org .junit .After ;
4144import org .junit .Assert ;
@@ -143,6 +146,8 @@ public class ConfigurationManagerTest {
143146 HostPodDao _podDao ;
144147 @ Mock
145148 PhysicalNetworkDao _physicalNetworkDao ;
149+ @ Mock
150+ ImageStoreDao _imageStoreDao ;
146151
147152 VlanVO vlan = new VlanVO (Vlan .VlanType .VirtualNetwork , "vlantag" , "vlangateway" , "vlannetmask" , 1L , "iprange" , 1L , 1L , null , null , null );
148153
@@ -174,6 +179,7 @@ public void setup() throws Exception {
174179 configurationMgr ._clusterDao = _clusterDao ;
175180 configurationMgr ._podDao = _podDao ;
176181 configurationMgr ._physicalNetworkDao = _physicalNetworkDao ;
182+ configurationMgr ._imageStoreDao = _imageStoreDao ;
177183
178184
179185 Account account = new AccountVO ("testaccount" , 1 , "networkdomain" , (short )0 , UUID .randomUUID ().toString ());
@@ -679,6 +685,7 @@ public void checkIfZoneIsDeletableSuccessTest() {
679685 Mockito .when (_vmInstanceDao .listByZoneId (anyLong ())).thenReturn (new ArrayList <VMInstanceVO >());
680686 Mockito .when (_volumeDao .findByDc (anyLong ())).thenReturn (new ArrayList <VolumeVO >());
681687 Mockito .when (_physicalNetworkDao .listByZone (anyLong ())).thenReturn (new ArrayList <PhysicalNetworkVO >());
688+ Mockito .when (_imageStoreDao .findByScope (any (ZoneScope .class ))).thenReturn (new ArrayList <ImageStoreVO >());
682689
683690 configurationMgr .checkIfZoneIsDeletable (new Random ().nextLong ());
684691 }
@@ -696,6 +703,7 @@ public void checkIfZoneIsDeletableFailureOnHostTest() {
696703 Mockito .when (_vmInstanceDao .listByZoneId (anyLong ())).thenReturn (new ArrayList <VMInstanceVO >());
697704 Mockito .when (_volumeDao .findByDc (anyLong ())).thenReturn (new ArrayList <VolumeVO >());
698705 Mockito .when (_physicalNetworkDao .listByZone (anyLong ())).thenReturn (new ArrayList <PhysicalNetworkVO >());
706+ Mockito .when (_imageStoreDao .findByScope (any (ZoneScope .class ))).thenReturn (new ArrayList <ImageStoreVO >());
699707
700708 configurationMgr .checkIfZoneIsDeletable (new Random ().nextLong ());
701709 }
@@ -713,6 +721,7 @@ public void checkIfZoneIsDeletableFailureOnPodTest() {
713721 Mockito .when (_vmInstanceDao .listByZoneId (anyLong ())).thenReturn (new ArrayList <VMInstanceVO >());
714722 Mockito .when (_volumeDao .findByDc (anyLong ())).thenReturn (new ArrayList <VolumeVO >());
715723 Mockito .when (_physicalNetworkDao .listByZone (anyLong ())).thenReturn (new ArrayList <PhysicalNetworkVO >());
724+ Mockito .when (_imageStoreDao .findByScope (any (ZoneScope .class ))).thenReturn (new ArrayList <ImageStoreVO >());
716725
717726 configurationMgr .checkIfZoneIsDeletable (new Random ().nextLong ());
718727 }
@@ -726,6 +735,7 @@ public void checkIfZoneIsDeletableFailureOnPrivateIpAddressTest() {
726735 Mockito .when (_vmInstanceDao .listByZoneId (anyLong ())).thenReturn (new ArrayList <VMInstanceVO >());
727736 Mockito .when (_volumeDao .findByDc (anyLong ())).thenReturn (new ArrayList <VolumeVO >());
728737 Mockito .when (_physicalNetworkDao .listByZone (anyLong ())).thenReturn (new ArrayList <PhysicalNetworkVO >());
738+ Mockito .when (_imageStoreDao .findByScope (any (ZoneScope .class ))).thenReturn (new ArrayList <ImageStoreVO >());
729739
730740 configurationMgr .checkIfZoneIsDeletable (new Random ().nextLong ());
731741 }
@@ -739,6 +749,7 @@ public void checkIfZoneIsDeletableFailureOnPublicIpAddressTest() {
739749 Mockito .when (_vmInstanceDao .listByZoneId (anyLong ())).thenReturn (new ArrayList <VMInstanceVO >());
740750 Mockito .when (_volumeDao .findByDc (anyLong ())).thenReturn (new ArrayList <VolumeVO >());
741751 Mockito .when (_physicalNetworkDao .listByZone (anyLong ())).thenReturn (new ArrayList <PhysicalNetworkVO >());
752+ Mockito .when (_imageStoreDao .findByScope (any (ZoneScope .class ))).thenReturn (new ArrayList <ImageStoreVO >());
742753
743754 configurationMgr .checkIfZoneIsDeletable (new Random ().nextLong ());
744755 }
@@ -756,6 +767,7 @@ public void checkIfZoneIsDeletableFailureOnVmInstanceTest() {
756767 Mockito .when (_vmInstanceDao .listByZoneId (anyLong ())).thenReturn (arrayList );
757768 Mockito .when (_volumeDao .findByDc (anyLong ())).thenReturn (new ArrayList <VolumeVO >());
758769 Mockito .when (_physicalNetworkDao .listByZone (anyLong ())).thenReturn (new ArrayList <PhysicalNetworkVO >());
770+ Mockito .when (_imageStoreDao .findByScope (any (ZoneScope .class ))).thenReturn (new ArrayList <ImageStoreVO >());
759771
760772 configurationMgr .checkIfZoneIsDeletable (new Random ().nextLong ());
761773 }
@@ -773,6 +785,7 @@ public void checkIfZoneIsDeletableFailureOnVolumeTest() {
773785 Mockito .when (_vmInstanceDao .listByZoneId (anyLong ())).thenReturn (new ArrayList <VMInstanceVO >());
774786 Mockito .when (_volumeDao .findByDc (anyLong ())).thenReturn (arrayList );
775787 Mockito .when (_physicalNetworkDao .listByZone (anyLong ())).thenReturn (new ArrayList <PhysicalNetworkVO >());
788+ Mockito .when (_imageStoreDao .findByScope (any (ZoneScope .class ))).thenReturn (new ArrayList <ImageStoreVO >());
776789
777790 configurationMgr .checkIfZoneIsDeletable (new Random ().nextLong ());
778791 }
@@ -790,6 +803,7 @@ public void checkIfZoneIsDeletableFailureOnPhysicalNetworkTest() {
790803 Mockito .when (_vmInstanceDao .listByZoneId (anyLong ())).thenReturn (new ArrayList <VMInstanceVO >());
791804 Mockito .when (_volumeDao .findByDc (anyLong ())).thenReturn (new ArrayList <VolumeVO >());
792805 Mockito .when (_physicalNetworkDao .listByZone (anyLong ())).thenReturn (arrayList );
806+ Mockito .when (_imageStoreDao .findByScope (any (ZoneScope .class ))).thenReturn (new ArrayList <ImageStoreVO >());
793807
794808 configurationMgr .checkIfZoneIsDeletable (new Random ().nextLong ());
795809 }
0 commit comments