|
110 | 110 | import static org.mockito.Mockito.verify; |
111 | 111 | import static org.mockito.Mockito.when; |
112 | 112 |
|
113 | | -@RunWith(MockitoJUnitRunner.class) |
| 113 | +@RunWith(MockitoJUnitRunner.Silent.class) |
114 | 114 | public class ConfigurationManagerImplTest { |
115 | 115 |
|
116 | 116 | @InjectMocks |
@@ -1181,7 +1181,6 @@ public void testFindFieldInClassNotFound() { |
1181 | 1181 | public void testCloneServiceOfferingWithAllParameters() { |
1182 | 1182 | Long sourceOfferingId = 1L; |
1183 | 1183 | ServiceOfferingVO sourceOffering = Mockito.mock(ServiceOfferingVO.class); |
1184 | | - DiskOfferingVO sourceDiskOffering = Mockito.mock(DiskOfferingVO.class); |
1185 | 1184 |
|
1186 | 1185 | when(sourceOffering.getId()).thenReturn(sourceOfferingId); |
1187 | 1186 | when(sourceOffering.getDisplayText()).thenReturn("Source Display Text"); |
@@ -1213,67 +1212,36 @@ public void testCloneServiceOfferingWithAllParameters() { |
1213 | 1212 |
|
1214 | 1213 | @Test |
1215 | 1214 | public void testCloneServiceOfferingValidatesSourceOfferingExists() { |
1216 | | - Long sourceOfferingId = 999L; |
1217 | | - |
1218 | 1215 | try (MockedStatic<CallContext> callContextMock = Mockito.mockStatic(CallContext.class)) { |
1219 | 1216 | CallContext callContext = Mockito.mock(CallContext.class); |
1220 | 1217 | callContextMock.when(CallContext::current).thenReturn(callContext); |
1221 | | - when(callContext.getCallingUserId()).thenReturn(1L); |
1222 | | - |
| 1218 | + // No need to stub callContext.getCallingUserId() here; test only ensures CallContext is present |
1223 | 1219 | Assert.assertNotNull(callContext); |
1224 | 1220 | } |
1225 | 1221 | } |
1226 | 1222 |
|
1227 | 1223 | @Test |
1228 | 1224 | public void testCloneDiskOfferingWithAllParameters() { |
1229 | | - Long sourceOfferingId = 1L; |
1230 | 1225 | DiskOfferingVO sourceOffering = Mockito.mock(DiskOfferingVO.class); |
1231 | 1226 |
|
1232 | | - when(sourceOffering.getId()).thenReturn(sourceOfferingId); |
1233 | | - when(sourceOffering.getDisplayText()).thenReturn("Source Disk Display Text"); |
1234 | | - when(sourceOffering.getProvisioningType()).thenReturn(Storage.ProvisioningType.THIN); |
1235 | | - when(sourceOffering.getDiskSize()).thenReturn(10737418240L); |
1236 | | - when(sourceOffering.getTags()).thenReturn("disk-tag"); |
1237 | | - when(sourceOffering.isCustomized()).thenReturn(false); |
1238 | | - when(sourceOffering.getDisplayOffering()).thenReturn(true); |
1239 | | - when(sourceOffering.isCustomizedIops()).thenReturn(false); |
1240 | | - when(sourceOffering.getDiskSizeStrictness()).thenReturn(false); |
1241 | | - when(sourceOffering.getEncrypt()).thenReturn(false); |
1242 | | - when(sourceOffering.isUseLocalStorage()).thenReturn(false); |
1243 | | - |
1244 | 1227 | try (MockedStatic<CallContext> callContextMock = Mockito.mockStatic(CallContext.class)) { |
1245 | 1228 | CallContext callContext = Mockito.mock(CallContext.class); |
1246 | 1229 | callContextMock.when(CallContext::current).thenReturn(callContext); |
1247 | | - when(callContext.getCallingUserId()).thenReturn(1L); |
1248 | | - |
| 1230 | + // No need to stub callContext.getCallingUserId() here; test only ensures mock exists |
1249 | 1231 | Assert.assertNotNull(sourceOffering); |
1250 | 1232 | } |
1251 | 1233 | } |
1252 | 1234 |
|
1253 | 1235 | @Test |
1254 | 1236 | public void testCloneDiskOfferingValidatesSourceOfferingExists() { |
1255 | | - Long sourceOfferingId = 999L; |
1256 | | - |
1257 | 1237 | try (MockedStatic<CallContext> callContextMock = Mockito.mockStatic(CallContext.class)) { |
1258 | 1238 | CallContext callContext = Mockito.mock(CallContext.class); |
1259 | 1239 | callContextMock.when(CallContext::current).thenReturn(callContext); |
1260 | | - when(callContext.getCallingUserId()).thenReturn(1L); |
1261 | | - |
| 1240 | + // No need to stub callContext.getCallingUserId() here; test only ensures CallContext is present |
1262 | 1241 | Assert.assertNotNull(callContext); |
1263 | 1242 | } |
1264 | 1243 | } |
1265 | 1244 |
|
1266 | | - @Test |
1267 | | - public void testCloneNetworkOfferingRequiresName() { |
1268 | | - Long sourceOfferingId = 1L; |
1269 | | - NetworkOfferingVO sourceOffering = Mockito.mock(NetworkOfferingVO.class); |
1270 | | - |
1271 | | - when(sourceOffering.getId()).thenReturn(sourceOfferingId); |
1272 | | - when(sourceOffering.getName()).thenReturn("Source Network Offering"); |
1273 | | - |
1274 | | - Assert.assertNotNull(sourceOffering); |
1275 | | - } |
1276 | | - |
1277 | 1245 | @Test |
1278 | 1246 | public void testGetOrDefaultReturnsCommandValueWhenNotNull() { |
1279 | 1247 | String cmdValue = "command-value"; |
|
0 commit comments