Skip to content

Commit 58c0d36

Browse files
committed
fix test
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent c4e354c commit 58c0d36

File tree

4 files changed

+14
-29
lines changed

4 files changed

+14
-29
lines changed

api/src/main/java/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,23 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22-
import org.apache.cloudstack.api.ApiArgValidator;
23-
import org.apache.cloudstack.api.ApiErrorCode;
24-
import org.apache.cloudstack.api.ServerApiException;
25-
import org.apache.cloudstack.api.response.DomainResponse;
26-
import org.apache.cloudstack.api.response.ManagementServerResponse;
27-
import org.apache.commons.lang3.StringUtils;
28-
2922
import org.apache.cloudstack.api.APICommand;
3023
import org.apache.cloudstack.api.ApiConstants;
24+
import org.apache.cloudstack.api.ApiErrorCode;
3125
import org.apache.cloudstack.api.BaseListCmd;
3226
import org.apache.cloudstack.api.Parameter;
27+
import org.apache.cloudstack.api.ServerApiException;
3328
import org.apache.cloudstack.api.response.AccountResponse;
3429
import org.apache.cloudstack.api.response.ClusterResponse;
3530
import org.apache.cloudstack.api.response.ConfigurationResponse;
31+
import org.apache.cloudstack.api.response.DomainResponse;
3632
import org.apache.cloudstack.api.response.ImageStoreResponse;
3733
import org.apache.cloudstack.api.response.ListResponse;
34+
import org.apache.cloudstack.api.response.ManagementServerResponse;
3835
import org.apache.cloudstack.api.response.StoragePoolResponse;
3936
import org.apache.cloudstack.api.response.ZoneResponse;
4037
import org.apache.cloudstack.config.Configuration;
38+
import org.apache.commons.lang3.StringUtils;
4139

4240
import com.cloud.exception.InvalidParameterValueException;
4341
import com.cloud.utils.Pair;
@@ -100,7 +98,6 @@ public class ListCfgsByCmd extends BaseListCmd {
10098
type = CommandType.UUID,
10199
entityType = ManagementServerResponse.class,
102100
description = "the ID of the Management Server to update the parameter value for corresponding management server",
103-
validations = ApiArgValidator.PositiveNumber,
104101
since = "4.21.0")
105102
private Long managementServerId;
106103

api/src/main/java/org/apache/cloudstack/api/command/admin/config/ResetCfgCmd.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323
import org.apache.cloudstack.api.BaseCmd;
2424
import org.apache.cloudstack.api.Parameter;
2525
import org.apache.cloudstack.api.ServerApiException;
26-
import org.apache.cloudstack.api.response.ImageStoreResponse;
27-
import org.apache.cloudstack.api.response.ManagementServerResponse;
28-
import org.apache.cloudstack.framework.config.ConfigKey;
29-
3026
import org.apache.cloudstack.api.response.AccountResponse;
3127
import org.apache.cloudstack.api.response.ClusterResponse;
3228
import org.apache.cloudstack.api.response.ConfigurationResponse;
3329
import org.apache.cloudstack.api.response.DomainResponse;
30+
import org.apache.cloudstack.api.response.ImageStoreResponse;
31+
import org.apache.cloudstack.api.response.ManagementServerResponse;
3432
import org.apache.cloudstack.api.response.StoragePoolResponse;
3533
import org.apache.cloudstack.api.response.ZoneResponse;
3634
import org.apache.cloudstack.config.Configuration;
35+
import org.apache.cloudstack.framework.config.ConfigKey;
3736

3837
import com.cloud.user.Account;
3938
import com.cloud.utils.Pair;
@@ -89,7 +88,6 @@ public class ResetCfgCmd extends BaseCmd {
8988
type = CommandType.UUID,
9089
entityType = ManagementServerResponse.class,
9190
description = "the ID of the Management Server to update the parameter value for corresponding management server",
92-
validations = ApiArgValidator.PositiveNumber,
9391
since = "4.21.0")
9492
private Long managementServerId;
9593

server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -866,14 +866,9 @@ public void shouldValidateConfigRangeTestValueIsNotNullAndConfigHasRangeReturnTr
866866
@Test
867867
public void testResetConfigurations() {
868868
Long poolId = 1L;
869-
ResetCfgCmd cmd = Mockito.mock(ResetCfgCmd.class);
870-
Mockito.when(cmd.getCfgName()).thenReturn("pool.storage.capacity.disablethreshold");
871-
Mockito.when(cmd.getStoragepoolId()).thenReturn(poolId);
872-
Mockito.when(cmd.getZoneId()).thenReturn(null);
873-
Mockito.when(cmd.getClusterId()).thenReturn(null);
874-
Mockito.when(cmd.getAccountId()).thenReturn(null);
875-
Mockito.when(cmd.getDomainId()).thenReturn(null);
876-
Mockito.when(cmd.getImageStoreId()).thenReturn(null);
869+
ResetCfgCmd cmd = new ResetCfgCmd();
870+
ReflectionTestUtils.setField(cmd, "storagePoolId", poolId);
871+
ReflectionTestUtils.setField(cmd, "cfgName", "pool.storage.capacity.disablethreshold");
877872

878873
ConfigurationVO cfg = new ConfigurationVO("Advanced", "DEFAULT", "test", "pool.storage.capacity.disablethreshold", null, "description");
879874
cfg.setScope(10);

server/src/test/java/com/cloud/server/ManagementServerImplTest.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -716,14 +716,9 @@ public void testSearchForConfigurationsMultipleIds() {
716716
@Test
717717
public void testSearchForConfigurations() {
718718
Long poolId = 1L;
719-
ListCfgsByCmd cmd = Mockito.mock(ListCfgsByCmd.class);
720-
Mockito.when(cmd.getConfigName()).thenReturn("pool.storage.capacity.disablethreshold");
721-
Mockito.when(cmd.getStoragepoolId()).thenReturn(poolId);
722-
Mockito.when(cmd.getZoneId()).thenReturn(null);
723-
Mockito.when(cmd.getClusterId()).thenReturn(null);
724-
Mockito.when(cmd.getAccountId()).thenReturn(null);
725-
Mockito.when(cmd.getDomainId()).thenReturn(null);
726-
Mockito.when(cmd.getImageStoreId()).thenReturn(null);
719+
ListCfgsByCmd cmd = new ListCfgsByCmd();
720+
ReflectionTestUtils.setField(cmd, "storagePoolId", poolId);
721+
ReflectionTestUtils.setField(cmd, "configName", "pool.storage.capacity.disablethreshold");
727722

728723
SearchCriteria<ConfigurationVO> sc = Mockito.mock(SearchCriteria.class);
729724
Mockito.when(configDao.createSearchCriteria()).thenReturn(sc);

0 commit comments

Comments
 (0)