Search in sources :

Example 1 with CustomConfigurationsV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response in project cloudbreak by hortonworks.

the class CustomConfigurationsToCustomConfigurationsV4ResponseConverterTest method testConvertResponseContainsCorrectCustomConfigsProperties.

@Test
void testConvertResponseContainsCorrectCustomConfigsProperties() {
    Set<CustomConfigurationPropertyParameters> properties = customConfigurations.getConfigurations().stream().map(c -> customConfigurationPropertyConverter.convertToResponseJson(c)).collect(Collectors.toSet());
    CustomConfigurationsV4Response response = underTest.convert(customConfigurations);
    Set<CustomConfigurationPropertyParameters> result = response.getConfigurations();
    assertEquals(properties, result);
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) InjectMocks(org.mockito.InjectMocks) BeforeEach(org.junit.jupiter.api.BeforeEach) Mock(org.mockito.Mock) Collection(java.util.Collection) CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Sets(com.google.common.collect.Sets) Test(org.junit.jupiter.api.Test) MockitoAnnotations(org.mockito.MockitoAnnotations) CustomConfigurationsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) CustomConfigurationProperty(com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty) CustomConfigurationPropertyParameters(com.sequenceiq.cloudbreak.api.model.CustomConfigurationPropertyParameters) CustomConfigurationPropertyParameters(com.sequenceiq.cloudbreak.api.model.CustomConfigurationPropertyParameters) CustomConfigurationsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response) Test(org.junit.jupiter.api.Test)

Example 2 with CustomConfigurationsV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response in project cloudbreak by hortonworks.

the class CustomConfigurationsToCustomConfigurationsV4ResponseConverterTest method testConvert.

@Test
void testConvert() {
    customConfigurations.setAccount("testAccount");
    when(customConfigurationPropertyConverter.convertToResponseJson(any(CustomConfigurationProperty.class))).thenCallRealMethod();
    CustomConfigurationsV4Response response = underTest.convert(customConfigurations);
    assertEquals(customConfigurations.getName(), response.getName());
    assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet("property1", "property2"), collectNames(response.getConfigurations())));
    assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet("value1", "value2"), collectValues(response.getConfigurations())));
    assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet("role1", null), collectRoles(response.getConfigurations())));
    assertTrue(CollectionUtils.isEqualCollection(Sets.newHashSet("service2", "service1"), collectServices(response.getConfigurations())));
    assertEquals(customConfigurations.getRuntimeVersion(), response.getRuntimeVersion());
    assertEquals(customConfigurations.getCrn(), response.getCrn());
    assertEquals(customConfigurations.getAccount(), response.getAccount());
    assertEquals(customConfigurations.getCreated(), response.getCreated());
}
Also used : CustomConfigurationProperty(com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty) CustomConfigurationsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response) Test(org.junit.jupiter.api.Test)

Example 3 with CustomConfigurationsV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response in project cloudbreak by hortonworks.

the class CustomConfigurationsToCustomConfigurationsV4ResponseConverter method convert.

public CustomConfigurationsV4Response convert(CustomConfigurations source) {
    CustomConfigurationsV4Response response = new CustomConfigurationsV4Response();
    response.setName(source.getName());
    response.setCreated(source.getCreated());
    response.setCrn(source.getCrn());
    response.setConfigurations(source.getConfigurations().stream().map(c -> customConfigurationPropertyConverter.convertToResponseJson(c)).collect(Collectors.toSet()));
    response.setAccount(source.getAccount());
    response.setRuntimeVersion(source.getRuntimeVersion());
    return response;
}
Also used : CustomConfigurationsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response)

Aggregations

CustomConfigurationsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response)3 CustomConfigurationProperty (com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty)2 Test (org.junit.jupiter.api.Test)2 Sets (com.google.common.collect.Sets)1 CustomConfigurationPropertyParameters (com.sequenceiq.cloudbreak.api.model.CustomConfigurationPropertyParameters)1 CustomConfigurations (com.sequenceiq.cloudbreak.domain.CustomConfigurations)1 Collection (java.util.Collection)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 InjectMocks (org.mockito.InjectMocks)1 Mock (org.mockito.Mock)1 Mockito.when (org.mockito.Mockito.when)1 MockitoAnnotations (org.mockito.MockitoAnnotations)1