1616// under the License.
1717package org .apache .cloudstack .util .solidfire ;
1818
19- import java .util .ArrayList ;
20- import java .util .List ;
21-
22- import javax .inject .Inject ;
23-
24- import org .apache .cloudstack .api .response .solidfire .ApiVolumeSnapshotDetailsResponse ;
25- import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
26- import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
27-
2819import com .cloud .dc .ClusterVO ;
2920import com .cloud .dc .dao .ClusterDao ;
3021import com .cloud .storage .SnapshotVO ;
3526import com .cloud .storage .dao .VolumeDao ;
3627import com .cloud .user .Account ;
3728import com .cloud .user .dao .AccountDao ;
29+ import com .cloud .utils .exception .CloudRuntimeException ;
30+ import org .apache .cloudstack .api .response .solidfire .ApiVolumeSnapshotDetailsResponse ;
31+ import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
32+ import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
33+
34+ import javax .inject .Inject ;
35+ import java .util .ArrayList ;
36+ import java .util .List ;
3837
3938public class SolidFireIntegrationTestUtil {
4039 @ Inject private AccountDao accountDao ;
@@ -48,48 +47,70 @@ private SolidFireIntegrationTestUtil() {}
4847
4948 public long getAccountIdForAccountUuid (String accountUuid ) {
5049 Account account = accountDao .findByUuid (accountUuid );
51-
50+ if (account == null ){
51+ throw new CloudRuntimeException ("Unable to find Account for ID: " + accountUuid );
52+ }
5253 return account .getAccountId ();
5354 }
5455
5556 public long getAccountIdForVolumeUuid (String volumeUuid ) {
5657 VolumeVO volume = volumeDao .findByUuid (volumeUuid );
58+ if (volume == null ){
59+ throw new CloudRuntimeException ("Unable to find Volume for ID: " + volumeUuid );
60+ }
5761
5862 return volume .getAccountId ();
5963 }
6064
6165 public long getAccountIdForSnapshotUuid (String snapshotUuid ) {
6266 SnapshotVO snapshot = snapshotDao .findByUuid (snapshotUuid );
63-
67+ if (snapshot == null ){
68+ throw new CloudRuntimeException ("Unable to find Volume for ID: " + snapshotUuid );
69+ }
6470 return snapshot .getAccountId ();
6571 }
6672
6773 public long getClusterIdForClusterUuid (String clusterUuid ) {
6874 ClusterVO cluster = clusterDao .findByUuid (clusterUuid );
75+ if (cluster == null ){
76+ throw new CloudRuntimeException ("Unable to find Volume for ID: " + clusterUuid );
77+ }
6978
7079 return cluster .getId ();
7180 }
7281
7382 public long getStoragePoolIdForStoragePoolUuid (String storagePoolUuid ) {
7483 StoragePoolVO storagePool = storagePoolDao .findByUuid (storagePoolUuid );
84+ if (storagePool == null ){
85+ throw new CloudRuntimeException ("Unable to find Volume for ID: " + storagePoolUuid );
86+ }
7587
7688 return storagePool .getId ();
7789 }
7890
7991 public String getPathForVolumeUuid (String volumeUuid ) {
8092 VolumeVO volume = volumeDao .findByUuid (volumeUuid );
93+ if (volume == null ){
94+ throw new CloudRuntimeException ("Unable to find Volume for ID: " + volumeUuid );
95+ }
8196
8297 return volume .getPath ();
8398 }
8499
85100 public String getVolume_iScsiName (String volumeUuid ) {
86101 VolumeVO volume = volumeDao .findByUuid (volumeUuid );
102+ if (volume == null ){
103+ throw new CloudRuntimeException ("Unable to find Volume for ID: " + volumeUuid );
104+ }
87105
88106 return volume .get_iScsiName ();
89107 }
90108
91109 public List <ApiVolumeSnapshotDetailsResponse > getSnapshotDetails (String snapshotUuid ) {
92110 SnapshotVO snapshot = snapshotDao .findByUuid (snapshotUuid );
111+ if (snapshot == null ){
112+ throw new CloudRuntimeException ("Unable to find Volume for ID: " + snapshotUuid );
113+ }
93114
94115 List <SnapshotDetailsVO > snapshotDetails = snapshotDetailsDao .listDetails (snapshot .getId ());
95116
0 commit comments