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();
}
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());
}
}
Aggregations