Skip to content

Commit 11c937d

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
sync: review comments changes for test files
1 parent 199c463 commit 11c937d

4 files changed

Lines changed: 4 additions & 35 deletions

File tree

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
5555
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
5656
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
57-
import org.apache.cloudstack.storage.feign.model.Igroup;
5857
import org.apache.cloudstack.storage.feign.client.SnapshotFeignClient;
5958
import org.apache.cloudstack.storage.feign.model.FlexVolSnapshot;
6059
import org.apache.cloudstack.storage.feign.model.Lun;

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.Hyper
378378
_dataStoreHelper.attachZone(dataStore);
379379
return true;
380380
}
381-
382381
private boolean validateProtocolSupportAndFetchHostsIdentifier(List<HostVO> hosts, ProtocolType protocolType, List<String> hostIdentifiers) {
383382
switch (protocolType) {
384383
case ISCSI:

plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriverTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ void testCreateAsync_NullCallback_ThrowsException() {
158158
void testCreateAsync_VolumeWithISCSI_Success() {
159159
// Setup
160160
when(dataStore.getId()).thenReturn(1L);
161-
when(dataStore.getUuid()).thenReturn("pool-uuid-123");
162161
when(dataStore.getName()).thenReturn("ontap-pool");
163162
when(volumeInfo.getType()).thenReturn(VOLUME);
164163
when(volumeInfo.getId()).thenReturn(100L);
@@ -212,7 +211,6 @@ void testCreateAsync_VolumeWithNFS_Success() {
212211
storagePoolDetails.put(OntapStorageConstants.PROTOCOL, ProtocolType.NFS3.name());
213212

214213
when(dataStore.getId()).thenReturn(1L);
215-
when(dataStore.getUuid()).thenReturn("pool-uuid-123");
216214
when(dataStore.getName()).thenReturn("ontap-pool");
217215
when(volumeInfo.getType()).thenReturn(VOLUME);
218216
when(volumeInfo.getId()).thenReturn(100L);
@@ -336,7 +334,6 @@ void testGrantAccess_NullParameters_ThrowsException() {
336334
void testGrantAccess_ClusterScope_Success() {
337335
// Setup
338336
when(dataStore.getId()).thenReturn(1L);
339-
when(dataStore.getUuid()).thenReturn("pool-uuid-123");
340337
when(volumeInfo.getType()).thenReturn(VOLUME);
341338
when(volumeInfo.getId()).thenReturn(100L);
342339

@@ -389,7 +386,6 @@ void testGrantAccess_IgroupNotFound_CreatesNewIgroup() {
389386
when(hostVO.getName()).thenReturn("host1");
390387

391388
when(dataStore.getId()).thenReturn(1L);
392-
when(dataStore.getUuid()).thenReturn("pool-uuid-123");
393389
when(volumeInfo.getType()).thenReturn(VOLUME);
394390
when(volumeInfo.getId()).thenReturn(100L);
395391

plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/vmsnapshot/OntapVMSnapshotStrategyTest.java

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import static org.mockito.Mockito.verify;
3131
import static org.mockito.Mockito.when;
3232

33-
import java.lang.reflect.Field;
3433
import java.util.ArrayList;
3534
import java.util.Arrays;
3635
import java.util.Collections;
@@ -49,6 +48,7 @@
4948
import org.junit.jupiter.api.BeforeEach;
5049
import org.junit.jupiter.api.Test;
5150
import org.junit.jupiter.api.extension.ExtendWith;
51+
import org.mockito.InjectMocks;
5252
import org.mockito.Mock;
5353
import org.mockito.Spy;
5454
import org.mockito.junit.jupiter.MockitoExtension;
@@ -107,6 +107,7 @@ class OntapVMSnapshotStrategyTest {
107107
private static final String VM_UUID = "vm-uuid-123";
108108

109109
@Spy
110+
@InjectMocks
110111
private OntapVMSnapshotStrategy strategy;
111112

112113
@Mock
@@ -133,34 +134,8 @@ class OntapVMSnapshotStrategyTest {
133134
private VolumeDetailsDao volumeDetailsDao;
134135

135136
@BeforeEach
136-
void setUp() throws Exception {
137-
// Inject mocks into the inherited fields via reflection
138-
// DefaultVMSnapshotStrategy fields
139-
setField(strategy, DefaultVMSnapshotStrategy.class, "vmSnapshotHelper", vmSnapshotHelper);
140-
setField(strategy, DefaultVMSnapshotStrategy.class, "guestOSDao", guestOSDao);
141-
setField(strategy, DefaultVMSnapshotStrategy.class, "userVmDao", userVmDao);
142-
setField(strategy, DefaultVMSnapshotStrategy.class, "vmSnapshotDao", vmSnapshotDao);
143-
setField(strategy, DefaultVMSnapshotStrategy.class, "agentMgr", agentMgr);
144-
setField(strategy, DefaultVMSnapshotStrategy.class, "volumeDao", volumeDao);
145-
146-
// StorageVMSnapshotStrategy fields
147-
setField(strategy, StorageVMSnapshotStrategy.class, "storagePool", storagePool);
148-
setField(strategy, StorageVMSnapshotStrategy.class, "vmSnapshotDetailsDao", vmSnapshotDetailsDao);
149-
setField(strategy, StorageVMSnapshotStrategy.class, "volumeDataFactory", volumeDataFactory);
150-
151-
// OntapVMSnapshotStrategy fields
152-
setField(strategy, OntapVMSnapshotStrategy.class, "storagePoolDetailsDao", storagePoolDetailsDao);
153-
setField(strategy, OntapVMSnapshotStrategy.class, "volumeDetailsDao", volumeDetailsDao);
154-
}
155-
156-
// ──────────────────────────────────────────────────────────────────────────
157-
// Helper: inject field via reflection into a specific declaring class
158-
// ──────────────────────────────────────────────────────────────────────────
159-
160-
private void setField(Object target, Class<?> declaringClass, String fieldName, Object value) throws Exception {
161-
Field field = declaringClass.getDeclaredField(fieldName);
162-
field.setAccessible(true);
163-
field.set(target, value);
137+
void setUp() {
138+
// @InjectMocks handles injection into inherited fields
164139
}
165140

166141
// ──────────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)