Search in sources :

Example 1 with ApiConfig

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;
}
Also used : ApiConfig(com.cloudera.api.swagger.model.ApiConfig)

Example 2 with 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;
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ArrayList(java.util.ArrayList) ApiConfig(com.cloudera.api.swagger.model.ApiConfig) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with ApiConfig

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;
}
Also used : ArrayList(java.util.ArrayList) ApiConfig(com.cloudera.api.swagger.model.ApiConfig) Map(java.util.Map) HashMap(java.util.HashMap) ApiServiceConfig(com.cloudera.api.swagger.model.ApiServiceConfig)

Example 4 with ApiConfig

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));
}
Also used : ApiRole(com.cloudera.api.swagger.model.ApiRole) ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ApiService(com.cloudera.api.swagger.model.ApiService) ApiRoleList(com.cloudera.api.swagger.model.ApiRoleList) ApiConfig(com.cloudera.api.swagger.model.ApiConfig) Test(org.junit.Test)

Example 5 with ApiConfig

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));
}
Also used : ApiService(com.cloudera.api.swagger.model.ApiService) ApiConfig(com.cloudera.api.swagger.model.ApiConfig) ApiServiceConfig(com.cloudera.api.swagger.model.ApiServiceConfig) Test(org.junit.Test)

Aggregations

ApiConfig (com.cloudera.api.swagger.model.ApiConfig)5 ApiConfigList (com.cloudera.api.swagger.model.ApiConfigList)2 ApiService (com.cloudera.api.swagger.model.ApiService)2 ApiServiceConfig (com.cloudera.api.swagger.model.ApiServiceConfig)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Test (org.junit.Test)2 ApiRole (com.cloudera.api.swagger.model.ApiRole)1 ApiRoleList (com.cloudera.api.swagger.model.ApiRoleList)1