Search in sources :

Example 1 with EnvironmentConfigBean

use of org.wso2.carbon.apimgt.rest.api.configurations.utils.bean.EnvironmentConfigBean in project carbon-apimgt by wso2.

the class ConfigurationsAPI method environments.

/**
 * Get environment configurations from deployment.yaml and returns the list of environments
 *
 * @return Response List of environments: {"environments":[
 * {"host":"localhost:9292","loginTokenPath":"/login/token","label":"Development"},
 * {"host":"localhost:9293","loginTokenPath":"/login/token","label":"Production"}
 * ]}
 */
@GET
@Path("/environments")
@Produces(MediaType.APPLICATION_JSON)
public Response environments() {
    APIMUIConfigurations apimUIConfigurations = ConfigurationService.getInstance().getApimUIConfigurations();
    EnvironmentConfigBean environmentConfigBean = new EnvironmentConfigBean();
    environmentConfigBean.setEnvironments(apimUIConfigurations.getEnvironments());
    return Response.ok(environmentConfigBean, MediaType.APPLICATION_JSON).build();
}
Also used : EnvironmentConfigBean(org.wso2.carbon.apimgt.rest.api.configurations.utils.bean.EnvironmentConfigBean) APIMUIConfigurations(org.wso2.carbon.apimgt.rest.api.configurations.models.APIMUIConfigurations) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with EnvironmentConfigBean

use of org.wso2.carbon.apimgt.rest.api.configurations.utils.bean.EnvironmentConfigBean in project carbon-apimgt by wso2.

the class ConfigurationsAPITestCase method testEnvironments.

@Test
public void testEnvironments() {
    // Happy Path - 200
    // //Default configurations
    ConfigurationsAPI configurationsAPI = new ConfigurationsAPI();
    Response response = configurationsAPI.environments();
    Assert.assertEquals(response.getStatus(), 200);
    EnvironmentConfigBean environmentConfigBean = (EnvironmentConfigBean) response.getEntity();
    Assert.assertFalse(environmentConfigBean.getEnvironments().isEmpty());
    Assert.assertNotNull(environmentConfigBean.getEnvironments().get(0).getHost());
    Assert.assertFalse(environmentConfigBean.getEnvironments().get(0).getLabel().isEmpty());
    Assert.assertFalse(environmentConfigBean.getEnvironments().get(0).getLoginTokenPath().isEmpty());
    // //Custom configurations
    APIMUIConfigurations apimUIConfigurations = ConfigurationService.getInstance().getApimUIConfigurations();
    apimUIConfigurations.setEnvironments(getSampleEnvironments());
    response = configurationsAPI.environments();
    environmentConfigBean = (EnvironmentConfigBean) response.getEntity();
    Assert.assertEquals(environmentConfigBean.getEnvironments().size(), getSampleEnvironments().size());
    for (int i = 0; i < environmentConfigBean.getEnvironments().size(); i++) {
        Assert.assertEquals(environmentConfigBean.getEnvironments().get(i).getLabel(), getSampleEnvironments().get(i).getLabel());
        Assert.assertEquals(environmentConfigBean.getEnvironments().get(i).getHost(), getSampleEnvironments().get(i).getHost());
        Assert.assertEquals(environmentConfigBean.getEnvironments().get(i).getLoginTokenPath(), getSampleEnvironments().get(i).getLoginTokenPath());
    }
}
Also used : Response(javax.ws.rs.core.Response) EnvironmentConfigBean(org.wso2.carbon.apimgt.rest.api.configurations.utils.bean.EnvironmentConfigBean) APIMUIConfigurations(org.wso2.carbon.apimgt.rest.api.configurations.models.APIMUIConfigurations) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

APIMUIConfigurations (org.wso2.carbon.apimgt.rest.api.configurations.models.APIMUIConfigurations)2 EnvironmentConfigBean (org.wso2.carbon.apimgt.rest.api.configurations.utils.bean.EnvironmentConfigBean)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 BeforeTest (org.testng.annotations.BeforeTest)1 Test (org.testng.annotations.Test)1