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