Search in sources :

Example 6 with ConfigurationResponse

use of com.cloud.api.response.ConfigurationResponse in project CloudStack-archive by CloudStack-extras.

the class ListCfgsByCmd method execute.

@Override
public void execute() {
    List<? extends Configuration> result = _mgr.searchForConfigurations(this);
    ListResponse<ConfigurationResponse> response = new ListResponse<ConfigurationResponse>();
    List<ConfigurationResponse> configResponses = new ArrayList<ConfigurationResponse>();
    for (Configuration cfg : result) {
        ConfigurationResponse cfgResponse = _responseGenerator.createConfigurationResponse(cfg);
        cfgResponse.setObjectName("configuration");
        configResponses.add(cfgResponse);
    }
    response.setResponses(configResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ConfigurationResponse(com.cloud.api.response.ConfigurationResponse) ListResponse(com.cloud.api.response.ListResponse) Configuration(com.cloud.configuration.Configuration) ArrayList(java.util.ArrayList)

Example 7 with ConfigurationResponse

use of com.cloud.api.response.ConfigurationResponse in project cosmic by MissionCriticalCloud.

the class UpdateCfgCmdTest method testCreateSuccess.

@Test
public void testCreateSuccess() {
    final Configuration cfg = Mockito.mock(Configuration.class);
    updateCfgCmd._configService = configService;
    updateCfgCmd._responseGenerator = responseGenerator;
    try {
        Mockito.when(configService.updateConfiguration(updateCfgCmd)).thenReturn(cfg);
    } catch (final Exception e) {
        Assert.fail("Received exception when success expected " + e.getMessage());
    }
    final ConfigurationResponse response = new ConfigurationResponse();
    response.setName("Test case");
    Mockito.when(responseGenerator.createConfigurationResponse(cfg)).thenReturn(response);
    updateCfgCmd.execute();
    Mockito.verify(responseGenerator).createConfigurationResponse(cfg);
    final ConfigurationResponse actualResponse = (ConfigurationResponse) updateCfgCmd.getResponseObject();
    Assert.assertEquals(response, actualResponse);
    Assert.assertEquals("updateconfigurationresponse", response.getResponseName());
}
Also used : ConfigurationResponse(com.cloud.api.response.ConfigurationResponse) Configuration(com.cloud.config.Configuration) ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) Test(org.junit.Test)

Aggregations

ConfigurationResponse (com.cloud.api.response.ConfigurationResponse)7 Configuration (com.cloud.config.Configuration)4 ServerApiException (com.cloud.api.ServerApiException)3 ListResponse (com.cloud.api.response.ListResponse)3 ArrayList (java.util.ArrayList)3 Configuration (com.cloud.configuration.Configuration)2 List (java.util.List)2 Test (org.junit.Test)2 Pair (com.cloud.utils.Pair)1 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)1