Search in sources :

Example 1 with ApiRoleConfigGroupList

use of com.cloudera.api.swagger.model.ApiRoleConfigGroupList in project cloudbreak by hortonworks.

the class ClouderaManagerConfigServiceTest method testGetRoleConfigValueByServiceTypeShouldReturnOptionalEmptyWhenRoleTypeNotFound.

@Test
public void testGetRoleConfigValueByServiceTypeShouldReturnOptionalEmptyWhenRoleTypeNotFound() throws ApiException {
    RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = Mockito.mock(RoleConfigGroupsResourceApi.class);
    ServicesResourceApi servicesResourceApi = Mockito.mock(ServicesResourceApi.class);
    when(clouderaManagerApiFactory.getRoleConfigGroupsResourceApi(API_CLIENT)).thenReturn(roleConfigGroupsResourceApi);
    when(clouderaManagerApiFactory.getServicesResourceApi(API_CLIENT)).thenReturn(servicesResourceApi);
    List<ApiService> services = List.of(createApiService(NIFI_SERVICE, NIFI_SERVICE_TYPE), createApiService("SPARK", "SPARK-ROLE"));
    when(servicesResourceApi.readServices(eq(TEST_CLUSTER_NAME), any())).thenReturn(createApiServiceList(services));
    ApiRoleConfigGroupList configGroupList = createApiRoleConfigGroups(List.of(createConfigGroup("SPARK-GROUP", "SPARK-ROLE")));
    when(roleConfigGroupsResourceApi.readRoleConfigGroups(TEST_CLUSTER_NAME, NIFI_SERVICE)).thenReturn(configGroupList);
    Optional<String> actual = underTest.getRoleConfigValueByServiceType(API_CLIENT, TEST_CLUSTER_NAME, NIFI_ROLE, NIFI_SERVICE_TYPE, CONFIG_NAME);
    assertEquals(Optional.empty(), actual);
    verify(clouderaManagerApiFactory).getRoleConfigGroupsResourceApi(API_CLIENT);
    verify(clouderaManagerApiFactory).getServicesResourceApi(API_CLIENT);
    verify(servicesResourceApi).readServices(eq(TEST_CLUSTER_NAME), any());
    verify(roleConfigGroupsResourceApi, times(1)).readRoleConfigGroups(TEST_CLUSTER_NAME, NIFI_SERVICE);
}
Also used : RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ServicesResourceApi(com.cloudera.api.swagger.ServicesResourceApi) ApiRoleConfigGroupList(com.cloudera.api.swagger.model.ApiRoleConfigGroupList) ApiService(com.cloudera.api.swagger.model.ApiService) Test(org.junit.Test)

Example 2 with ApiRoleConfigGroupList

use of com.cloudera.api.swagger.model.ApiRoleConfigGroupList in project cloudbreak by hortonworks.

the class ClouderaManagerConfigServiceTest method testGetRoleConfigValueByServiceTypeShouldReturnOptionalEmptyWhenTheConfigNotFound.

@Test
public void testGetRoleConfigValueByServiceTypeShouldReturnOptionalEmptyWhenTheConfigNotFound() throws ApiException {
    RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = Mockito.mock(RoleConfigGroupsResourceApi.class);
    ServicesResourceApi servicesResourceApi = Mockito.mock(ServicesResourceApi.class);
    when(clouderaManagerApiFactory.getRoleConfigGroupsResourceApi(API_CLIENT)).thenReturn(roleConfigGroupsResourceApi);
    when(clouderaManagerApiFactory.getServicesResourceApi(API_CLIENT)).thenReturn(servicesResourceApi);
    List<ApiService> services = List.of(createApiService(NIFI_SERVICE, NIFI_SERVICE_TYPE), createApiService("SPARK", "SPARK-ROLE"));
    when(servicesResourceApi.readServices(eq(TEST_CLUSTER_NAME), any())).thenReturn(createApiServiceList(services));
    ApiRoleConfigGroupList configGroupList = createApiRoleConfigGroups(List.of(createConfigGroup(NIFI_CONFIG_GROUP, NIFI_ROLE), createConfigGroup("SPARK-GROUP", "SPARK-ROLE")));
    when(roleConfigGroupsResourceApi.readRoleConfigGroups(TEST_CLUSTER_NAME, NIFI_SERVICE)).thenReturn(configGroupList);
    ApiConfigList roleConfig = createApiConfigList(Collections.emptyList());
    when(roleConfigGroupsResourceApi.readConfig(TEST_CLUSTER_NAME, NIFI_CONFIG_GROUP, NIFI_SERVICE, CONFIG_VIEW)).thenReturn(roleConfig);
    Optional<String> actual = underTest.getRoleConfigValueByServiceType(API_CLIENT, TEST_CLUSTER_NAME, NIFI_ROLE, NIFI_SERVICE_TYPE, CONFIG_NAME);
    assertEquals(Optional.empty(), actual);
    verify(clouderaManagerApiFactory).getRoleConfigGroupsResourceApi(API_CLIENT);
    verify(clouderaManagerApiFactory).getServicesResourceApi(API_CLIENT);
    verify(servicesResourceApi).readServices(eq(TEST_CLUSTER_NAME), any());
    verify(roleConfigGroupsResourceApi).readRoleConfigGroups(TEST_CLUSTER_NAME, NIFI_SERVICE);
    verify(roleConfigGroupsResourceApi).readConfig(TEST_CLUSTER_NAME, NIFI_CONFIG_GROUP, NIFI_SERVICE, CONFIG_VIEW);
}
Also used : RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ServicesResourceApi(com.cloudera.api.swagger.ServicesResourceApi) ApiRoleConfigGroupList(com.cloudera.api.swagger.model.ApiRoleConfigGroupList) ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ApiService(com.cloudera.api.swagger.model.ApiService) Test(org.junit.Test)

Example 3 with ApiRoleConfigGroupList

use of com.cloudera.api.swagger.model.ApiRoleConfigGroupList in project cloudbreak by hortonworks.

the class ClouderaManagerConfigServiceTest method testGetRoleConfigValueByServiceTypeShouldReturnTheConfigValueWhenTheValueIsNullAndDefaultValuePresent.

@Test
public void testGetRoleConfigValueByServiceTypeShouldReturnTheConfigValueWhenTheValueIsNullAndDefaultValuePresent() throws ApiException {
    RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = Mockito.mock(RoleConfigGroupsResourceApi.class);
    ServicesResourceApi servicesResourceApi = Mockito.mock(ServicesResourceApi.class);
    when(clouderaManagerApiFactory.getRoleConfigGroupsResourceApi(API_CLIENT)).thenReturn(roleConfigGroupsResourceApi);
    when(clouderaManagerApiFactory.getServicesResourceApi(API_CLIENT)).thenReturn(servicesResourceApi);
    List<ApiService> services = List.of(createApiService(NIFI_SERVICE, NIFI_SERVICE_TYPE), createApiService("SPARK", "SPARK-ROLE"));
    when(servicesResourceApi.readServices(eq(TEST_CLUSTER_NAME), any())).thenReturn(createApiServiceList(services));
    ApiRoleConfigGroupList configGroupList = createApiRoleConfigGroups(List.of(createConfigGroup(NIFI_CONFIG_GROUP, NIFI_ROLE), createConfigGroup("SPARK-GROUP", "SPARK-ROLE")));
    when(roleConfigGroupsResourceApi.readRoleConfigGroups(TEST_CLUSTER_NAME, NIFI_SERVICE)).thenReturn(configGroupList);
    ApiConfigList roleConfig = createApiConfigList(List.of(createConfig(null, DEFAULT_VALUE)));
    when(roleConfigGroupsResourceApi.readConfig(TEST_CLUSTER_NAME, NIFI_CONFIG_GROUP, NIFI_SERVICE, CONFIG_VIEW)).thenReturn(roleConfig);
    Optional<String> actual = underTest.getRoleConfigValueByServiceType(API_CLIENT, TEST_CLUSTER_NAME, NIFI_ROLE, NIFI_SERVICE_TYPE, CONFIG_NAME);
    assertEquals(Optional.of(DEFAULT_VALUE), actual);
    verify(clouderaManagerApiFactory).getRoleConfigGroupsResourceApi(API_CLIENT);
    verify(clouderaManagerApiFactory).getServicesResourceApi(API_CLIENT);
    verify(servicesResourceApi).readServices(eq(TEST_CLUSTER_NAME), any());
    verify(roleConfigGroupsResourceApi).readRoleConfigGroups(TEST_CLUSTER_NAME, NIFI_SERVICE);
    verify(roleConfigGroupsResourceApi).readConfig(TEST_CLUSTER_NAME, NIFI_CONFIG_GROUP, NIFI_SERVICE, CONFIG_VIEW);
}
Also used : RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ServicesResourceApi(com.cloudera.api.swagger.ServicesResourceApi) ApiRoleConfigGroupList(com.cloudera.api.swagger.model.ApiRoleConfigGroupList) ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ApiService(com.cloudera.api.swagger.model.ApiService) Test(org.junit.Test)

Example 4 with ApiRoleConfigGroupList

use of com.cloudera.api.swagger.model.ApiRoleConfigGroupList in project cloudbreak by hortonworks.

the class ClouderaManagerConfigServiceTest method testGetRoleConfigValueByServiceTypeShouldReturnTheConfigValue.

@Test
public void testGetRoleConfigValueByServiceTypeShouldReturnTheConfigValue() throws ApiException {
    RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = Mockito.mock(RoleConfigGroupsResourceApi.class);
    ServicesResourceApi servicesResourceApi = Mockito.mock(ServicesResourceApi.class);
    when(clouderaManagerApiFactory.getRoleConfigGroupsResourceApi(API_CLIENT)).thenReturn(roleConfigGroupsResourceApi);
    when(clouderaManagerApiFactory.getServicesResourceApi(API_CLIENT)).thenReturn(servicesResourceApi);
    List<ApiService> services = List.of(createApiService(NIFI_SERVICE, NIFI_SERVICE_TYPE), createApiService("SPARK", "SPARK-ROLE"));
    when(servicesResourceApi.readServices(eq(TEST_CLUSTER_NAME), any())).thenReturn(createApiServiceList(services));
    ApiRoleConfigGroupList configGroupList = createApiRoleConfigGroups(List.of(createConfigGroup(NIFI_CONFIG_GROUP, NIFI_ROLE), createConfigGroup("SPARK-GROUP", "SPARK-ROLE")));
    when(roleConfigGroupsResourceApi.readRoleConfigGroups(TEST_CLUSTER_NAME, NIFI_SERVICE)).thenReturn(configGroupList);
    ApiConfigList roleConfig = createApiConfigList(List.of(createConfig(CONFIG_VALUE, null)));
    when(roleConfigGroupsResourceApi.readConfig(TEST_CLUSTER_NAME, NIFI_CONFIG_GROUP, NIFI_SERVICE, CONFIG_VIEW)).thenReturn(roleConfig);
    Optional<String> actual = underTest.getRoleConfigValueByServiceType(API_CLIENT, TEST_CLUSTER_NAME, NIFI_ROLE, NIFI_SERVICE_TYPE, CONFIG_NAME);
    assertEquals(Optional.of(CONFIG_VALUE), actual);
    verify(clouderaManagerApiFactory).getRoleConfigGroupsResourceApi(API_CLIENT);
    verify(clouderaManagerApiFactory).getServicesResourceApi(API_CLIENT);
    verify(servicesResourceApi).readServices(eq(TEST_CLUSTER_NAME), any());
    verify(roleConfigGroupsResourceApi).readRoleConfigGroups(TEST_CLUSTER_NAME, NIFI_SERVICE);
    verify(roleConfigGroupsResourceApi).readConfig(TEST_CLUSTER_NAME, NIFI_CONFIG_GROUP, NIFI_SERVICE, CONFIG_VIEW);
}
Also used : RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ServicesResourceApi(com.cloudera.api.swagger.ServicesResourceApi) ApiRoleConfigGroupList(com.cloudera.api.swagger.model.ApiRoleConfigGroupList) ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ApiService(com.cloudera.api.swagger.model.ApiService) Test(org.junit.Test)

Example 5 with ApiRoleConfigGroupList

use of com.cloudera.api.swagger.model.ApiRoleConfigGroupList in project cloudbreak by hortonworks.

the class ClouderaManagerConfigServiceTest method createApiRoleConfigGroups.

private ApiRoleConfigGroupList createApiRoleConfigGroups(List<ApiRoleConfigGroup> apiRoleConfigGroups) {
    ApiRoleConfigGroupList apiRoleConfigGroupList = new ApiRoleConfigGroupList();
    apiRoleConfigGroupList.items(apiRoleConfigGroups);
    return apiRoleConfigGroupList;
}
Also used : ApiRoleConfigGroupList(com.cloudera.api.swagger.model.ApiRoleConfigGroupList)

Aggregations

ApiRoleConfigGroupList (com.cloudera.api.swagger.model.ApiRoleConfigGroupList)5 RoleConfigGroupsResourceApi (com.cloudera.api.swagger.RoleConfigGroupsResourceApi)4 ServicesResourceApi (com.cloudera.api.swagger.ServicesResourceApi)4 ApiService (com.cloudera.api.swagger.model.ApiService)4 Test (org.junit.Test)4 ApiConfigList (com.cloudera.api.swagger.model.ApiConfigList)3