use of com.cloudera.api.swagger.model.ApiService in project knox by apache.
the class ClouderaManagerServiceDiscoveryRepositoryTest method testAddRole.
@Test
public void testAddRole() throws Exception {
final String serviceName = "HDFS-1";
final String roleName = "NAMENODE-1";
repository.registerCluster(serviceDiscoveryConfig);
final ApiService service = EasyMock.createNiceMock(ApiService.class);
EasyMock.expect(service.getName()).andReturn(serviceName).anyTimes();
final ApiRole role = EasyMock.createNiceMock(ApiRole.class);
EasyMock.expect(role.getName()).andReturn(roleName).anyTimes();
final ApiRoleList roles = EasyMock.createNiceMock(ApiRoleList.class);
EasyMock.expect(roles.getItems()).andReturn(Collections.singletonList(role)).anyTimes();
EasyMock.replay(service, role, roles);
assertFalse(containsRole(service, roleName));
repository.addService(serviceDiscoveryConfig, service);
repository.addRoles(serviceDiscoveryConfig, service, roles);
assertTrue(containsRole(service, roleName));
}
use of com.cloudera.api.swagger.model.ApiService in project knox by apache.
the class ClouderaManagerServiceDiscovery method getClusterServices.
private List<ApiService> getClusterServices(ServiceDiscoveryConfig serviceDiscoveryConfig, ServicesResourceApi servicesResourceApi) {
log.lookupClusterServicesFromRepository();
List<ApiService> services = repository.getServices(serviceDiscoveryConfig);
if (services == null || services.isEmpty()) {
try {
log.lookupClusterServicesFromCM();
final ApiServiceList serviceList = servicesResourceApi.readServices(serviceDiscoveryConfig.getCluster(), VIEW_SUMMARY);
services = serviceList == null ? new ArrayList<>() : serviceList.getItems();
// make sure that services are populated in the repository
services.forEach(service -> repository.addService(serviceDiscoveryConfig, service));
} catch (ApiException e) {
log.failedToAccessServiceConfigs(serviceDiscoveryConfig.getCluster(), e);
}
}
return services;
}
use of com.cloudera.api.swagger.model.ApiService in project knox by apache.
the class ClouderaManagerServiceDiscoveryRepositoryTest method testAddRoleConfig.
@Test
public void testAddRoleConfig() throws Exception {
final String serviceName = "HDFS-1";
final String roleName = "NAMENODE-1";
final String roleConfigName = "myRoleConfig";
final String roleConfigValue = "myRoleConfigValue";
repository.registerCluster(serviceDiscoveryConfig);
final ApiService service = EasyMock.createNiceMock(ApiService.class);
EasyMock.expect(service.getName()).andReturn(serviceName).anyTimes();
final ApiRole role = EasyMock.createNiceMock(ApiRole.class);
EasyMock.expect(role.getName()).andReturn(roleName).anyTimes();
final ApiRoleList roles = EasyMock.createNiceMock(ApiRoleList.class);
EasyMock.expect(roles.getItems()).andReturn(Collections.singletonList(role)).anyTimes();
final ApiConfig roleConfig = EasyMock.createNiceMock(ApiConfig.class);
EasyMock.expect(roleConfig.getName()).andReturn(roleConfigName).anyTimes();
EasyMock.expect(roleConfig.getValue()).andReturn(roleConfigValue).anyTimes();
final ApiConfigList roleConfigs = EasyMock.createNiceMock(ApiConfigList.class);
EasyMock.expect(roleConfigs.getItems()).andReturn(Collections.singletonList(roleConfig)).anyTimes();
EasyMock.replay(service, role, roles, roleConfig, roleConfigs);
assertFalse(containsRoleConfig(service, role, roleConfigName, roleConfigValue));
repository.addService(serviceDiscoveryConfig, service);
repository.addRoles(serviceDiscoveryConfig, service, roles);
repository.addRoleConfigs(serviceDiscoveryConfig, service, role, roleConfigs);
assertTrue(containsRoleConfig(service, role, roleConfigName, roleConfigValue));
}
use of com.cloudera.api.swagger.model.ApiService in project knox by apache.
the class ClouderaManagerServiceDiscoveryRepositoryTest method testAddService.
@Test
public void testAddService() throws Exception {
final String serviceName = "HDFS-1";
repository.registerCluster(serviceDiscoveryConfig);
assertFalse(containsService(serviceName));
final ApiService service = EasyMock.createNiceMock(ApiService.class);
EasyMock.expect(service.getName()).andReturn(serviceName).anyTimes();
EasyMock.replay(service);
repository.addService(serviceDiscoveryConfig, service);
assertTrue(containsService(serviceName));
}
use of com.cloudera.api.swagger.model.ApiService in project knox by apache.
the class ClouderaManagerServiceDiscoveryRepositoryTest method testAddServiceConfig.
@Test
public void testAddServiceConfig() throws Exception {
final String serviceName = "HDFS-1";
final String serviceConfigName = "myServiceConfigName";
final String serviceConfigValue = "myServiceConfigValue";
repository.registerCluster(serviceDiscoveryConfig);
final ApiService service = EasyMock.createNiceMock(ApiService.class);
EasyMock.expect(service.getName()).andReturn(serviceName).anyTimes();
final ApiConfig serviceConfig = EasyMock.createNiceMock(ApiConfig.class);
EasyMock.expect(serviceConfig.getName()).andReturn(serviceConfigName).anyTimes();
EasyMock.expect(serviceConfig.getValue()).andReturn(serviceConfigValue).anyTimes();
final ApiServiceConfig serviceConfigs = EasyMock.createNiceMock(ApiServiceConfig.class);
EasyMock.expect(serviceConfigs.getItems()).andReturn(Collections.singletonList(serviceConfig)).anyTimes();
EasyMock.replay(service, serviceConfig, serviceConfigs);
assertFalse(containsServiceConfig(service, serviceConfigName, serviceConfigValue));
repository.addService(serviceDiscoveryConfig, service);
repository.addServiceConfig(serviceDiscoveryConfig, service, serviceConfigs);
assertTrue(containsServiceConfig(service, serviceConfigName, serviceConfigValue));
}
Aggregations