use of com.cloudera.api.swagger.model.ApiConfig in project knox by apache.
the class AbstractCMDiscoveryTest method createApiConfigMock.
protected static ApiConfig createApiConfigMock(final String name, final String value) {
ApiConfig apiConfig = EasyMock.createNiceMock(ApiConfig.class);
EasyMock.expect(apiConfig.getName()).andReturn(name).anyTimes();
EasyMock.expect(apiConfig.getValue()).andReturn(value).anyTimes();
EasyMock.replay(apiConfig);
return apiConfig;
}
use of com.cloudera.api.swagger.model.ApiConfig in project knox by apache.
the class ClouderaManagerServiceDiscoveryTest method createMockApiConfigList.
private static ApiConfigList createMockApiConfigList(Map<String, String> properties) {
ApiConfigList configList = EasyMock.createNiceMock(ApiConfigList.class);
List<ApiConfig> roleConfigs = new ArrayList<>();
int i = 0;
for (Map.Entry<String, String> property : properties.entrySet()) {
ApiConfig config = EasyMock.createNiceMock(ApiConfig.class);
if (i++ % 2 == 0) {
EasyMock.expect(config.getName()).andReturn(property.getKey()).anyTimes();
} else {
EasyMock.expect(config.getRelatedName()).andReturn(property.getKey()).anyTimes();
}
EasyMock.expect(config.getValue()).andReturn(property.getValue()).anyTimes();
EasyMock.replay(config);
roleConfigs.add(config);
}
EasyMock.expect(configList.getItems()).andReturn(roleConfigs).anyTimes();
EasyMock.replay(configList);
return configList;
}
use of com.cloudera.api.swagger.model.ApiConfig in project knox by apache.
the class ClouderaManagerServiceDiscoveryTest method createMockApiServiceConfig.
private static ApiServiceConfig createMockApiServiceConfig(Map<String, String> properties) {
ApiServiceConfig serviceConfig = EasyMock.createNiceMock(ApiServiceConfig.class);
List<ApiConfig> serviceConfigs = new ArrayList<>();
int i = 0;
for (Map.Entry<String, String> property : properties.entrySet()) {
ApiConfig config = EasyMock.createNiceMock(ApiConfig.class);
if (i++ % 2 == 0) {
EasyMock.expect(config.getName()).andReturn(property.getKey()).anyTimes();
} else {
EasyMock.expect(config.getRelatedName()).andReturn(property.getKey()).anyTimes();
}
EasyMock.expect(config.getValue()).andReturn(property.getValue()).anyTimes();
EasyMock.replay(config);
serviceConfigs.add(config);
}
EasyMock.expect(serviceConfig.getItems()).andReturn(serviceConfigs).anyTimes();
EasyMock.replay(serviceConfig);
return serviceConfig;
}
use of com.cloudera.api.swagger.model.ApiConfig 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.ApiConfig 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