2424import static org .mockito .ArgumentMatchers .anyInt ;
2525import static org .mockito .ArgumentMatchers .anyLong ;
2626import static org .mockito .ArgumentMatchers .anyString ;
27+ import static org .mockito .ArgumentMatchers .nullable ;
2728import static org .mockito .Mockito .doNothing ;
2829import static org .mockito .Mockito .doThrow ;
2930import static org .mockito .Mockito .mock ;
5657import org .mockito .Mock ;
5758import org .mockito .Mockito ;
5859import org .mockito .MockitoAnnotations ;
60+ import org .mockito .Spy ;
5961
6062import com .cloud .api .query .dao .NetworkOfferingJoinDao ;
6163import com .cloud .api .query .vo .NetworkOfferingJoinVO ;
8789import com .cloud .network .dao .PhysicalNetworkDao ;
8890import com .cloud .network .dao .PhysicalNetworkVO ;
8991import com .cloud .projects .ProjectManager ;
92+ import com .cloud .storage .DiskOfferingVO ;
9093import com .cloud .storage .VolumeVO ;
9194import com .cloud .storage .dao .VolumeDao ;
9295import com .cloud .user .Account ;
@@ -108,6 +111,7 @@ public class ConfigurationManagerTest {
108111
109112 private static final Logger s_logger = Logger .getLogger (ConfigurationManagerTest .class );
110113
114+ @ Spy
111115 @ InjectMocks
112116 ConfigurationManagerImpl configurationMgr = new ConfigurationManagerImpl ();
113117
@@ -163,11 +167,12 @@ public class ConfigurationManagerTest {
163167 ImageStoreDao _imageStoreDao ;
164168 @ Mock
165169 ConfigurationDao _configDao ;
170+ @ Mock
171+ DiskOfferingVO diskOfferingVOMock ;
166172
167173 VlanVO vlan = new VlanVO (Vlan .VlanType .VirtualNetwork , "vlantag" , "vlangateway" , "vlannetmask" , 1L , "iprange" , 1L , 1L , null , null , null );
168174
169175 private static final String MAXIMUM_DURATION_ALLOWED = "3600" ;
170-
171176 @ Mock
172177 Network network ;
173178 @ Mock
@@ -938,4 +943,33 @@ public void validateMaximumIopsAndBytesLengthTestAllNull() {
938943 public void validateMaximumIopsAndBytesLengthTestDefaultLengthConfigs () {
939944 configurationMgr .validateMaximumIopsAndBytesLength (36000l , 36000l , 36000l , 36000l );
940945 }
946+
947+ @ Test
948+ public void shouldUpdateDiskOfferingTests (){
949+ Assert .assertTrue (configurationMgr .shouldUpdateDiskOffering (Mockito .anyString (), Mockito .anyString (), Mockito .anyInt (), Mockito .anyBoolean (), Mockito .anyString ()));
950+ Assert .assertTrue (configurationMgr .shouldUpdateDiskOffering (Mockito .anyString (), nullable (String .class ), nullable (Integer .class ), nullable (Boolean .class ), nullable (String .class )));
951+ Assert .assertTrue (configurationMgr .shouldUpdateDiskOffering (nullable (String .class ), Mockito .anyString (), nullable (Integer .class ), nullable (Boolean .class ), nullable (String .class )));
952+ Assert .assertTrue (configurationMgr .shouldUpdateDiskOffering (nullable (String .class ), nullable (String .class ), Mockito .anyInt (), nullable (Boolean .class ), nullable (String .class )));
953+ Assert .assertTrue (configurationMgr .shouldUpdateDiskOffering (nullable (String .class ), nullable (String .class ), nullable (int .class ), Mockito .anyBoolean (), nullable (String .class )));
954+ Assert .assertTrue (configurationMgr .shouldUpdateDiskOffering (nullable (String .class ), nullable (String .class ), nullable (int .class ), nullable (Boolean .class ), Mockito .anyString ()));
955+ }
956+
957+ @ Test
958+ public void shouldUpdateDiskOfferingTestFalse (){
959+ Assert .assertFalse (configurationMgr .shouldUpdateDiskOffering (null , null , null , null , null ));
960+ }
961+
962+ @ Test
963+ public void updateDiskOfferingTagsIfIsNotNullTestWhenTagsIsNull (){
964+ Mockito .doNothing ().when (configurationMgr ).updateDiskOfferingTagsIfIsNotNull (null , diskOfferingVOMock );
965+ this .configurationMgr .updateDiskOfferingTagsIfIsNotNull (null , diskOfferingVOMock );
966+ Mockito .verify (configurationMgr , Mockito .times (1 )).updateDiskOfferingTagsIfIsNotNull (null , diskOfferingVOMock );
967+ }
968+ @ Test
969+ public void updateDiskOfferingTagsIfIsNotNullTestWhenTagsIsNotNull (){
970+ String tags = "tags" ;
971+ Mockito .doNothing ().when (configurationMgr ).updateDiskOfferingTagsIfIsNotNull (tags , diskOfferingVOMock );
972+ this .configurationMgr .updateDiskOfferingTagsIfIsNotNull (tags , diskOfferingVOMock );
973+ Mockito .verify (configurationMgr , Mockito .times (1 )).updateDiskOfferingTagsIfIsNotNull (tags , diskOfferingVOMock );
974+ }
941975}
0 commit comments