use of com.sequenceiq.cloudbreak.domain.CustomConfigurations in project cloudbreak by hortonworks.
the class CustomConfigurationsToCustomConfigurationsDetailsConverterTest method testConvert.
@Test
void testConvert() {
CustomConfigurations customConfigurations = new CustomConfigurations();
customConfigurations.setId(1L);
customConfigurations.setName("test-name");
customConfigurations.setConfigurations(Sets.newHashSet(new CustomConfigurationProperty("property1", "value1", null, "service1"), new CustomConfigurationProperty("property2", "value2", "role2", "service2"), new CustomConfigurationProperty("property3", "value3", null, "service3"), new CustomConfigurationProperty("property4", "value4", "role4", "service4")));
customConfigurations.setRuntimeVersion("test-runtime-version");
CustomConfigurationsDetails customConfigurationsDetails = underTest.convert(customConfigurations);
assertThat(customConfigurationsDetails).isNotNull();
assertThat(customConfigurationsDetails.getCustomConfigurationsName()).isEqualTo("test-name");
assertThat(customConfigurationsDetails.getId()).isEqualTo(1L);
assertThat(customConfigurationsDetails.getRuntimeVersion()).isEqualTo("test-runtime-version");
assertThat(customConfigurationsDetails.getRoles()).hasSameElementsAs(Lists.newArrayList("role2", "role4"));
assertThat(customConfigurationsDetails.getServices()).hasSameElementsAs(Lists.newArrayList("service1", "service2", "service3", "service4"));
}
use of com.sequenceiq.cloudbreak.domain.CustomConfigurations in project cloudbreak by hortonworks.
the class CustomConfigurationsServiceTest method testIfCustomConfigsAreRetrievedByCrn.
@Test
void testIfCustomConfigsAreRetrievedByCrn() {
when(customConfigurationsRepository.findByCrn(TEST_CRN_1)).thenReturn(Optional.of(customConfigurations));
CustomConfigurations returnedValue = underTest.getByNameOrCrn(NameOrCrn.ofCrn(TEST_CRN_1));
assertEquals(customConfigurations, returnedValue);
verify(customConfigurationsRepository).findByCrn(TEST_CRN_1);
}
use of com.sequenceiq.cloudbreak.domain.CustomConfigurations in project cloudbreak by hortonworks.
the class CustomConfigurationsServiceTest method testIfCustomConfigsAreRetrievedByName.
@Test
void testIfCustomConfigsAreRetrievedByName() {
when(customConfigurationsRepository.findByNameAndAccountId(TEST_NAME, TEST_ACCOUNT_ID_1)).thenReturn(Optional.of(customConfigurations));
ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN_1, () -> {
CustomConfigurations returnedValue = underTest.getByNameOrCrn(NameOrCrn.ofName(TEST_NAME));
assertEquals(customConfigurations, returnedValue);
assertThrows(NotFoundException.class, () -> underTest.getByNameOrCrn(NameOrCrn.ofName("not a valid name")));
verify(customConfigurationsRepository).findByNameAndAccountId(TEST_NAME, TEST_ACCOUNT_ID_1);
});
}
use of com.sequenceiq.cloudbreak.domain.CustomConfigurations 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);
}
use of com.sequenceiq.cloudbreak.domain.CustomConfigurations in project cloudbreak by hortonworks.
the class CustomConfigurationsV4RequestToCustomConfigurationsConverterTest method testConvert.
@Test
void testConvert() {
property.setName("property1");
property.setValue("value1");
property.setRoleType("role1");
property.setServiceType("service1");
request.setName("test");
request.setConfigurations(Set.of(property));
request.setRuntimeVersion("7.2.8");
when(customConfigurationPropertyConverter.convertFromRequestJson(any(CustomConfigurationPropertyParameters.class))).thenReturn(new CustomConfigurationProperty("property1", "value1", "role1", "service1"));
when(customConfigurationPropertyConverter.convertToResponseJson(any(CustomConfigurationProperty.class))).thenReturn(property);
CustomConfigurations result = underTest.convert(request);
assertEquals(request.getName(), result.getName());
assertEquals(request.getConfigurations(), result.getConfigurations().stream().map(c -> customConfigurationPropertyConverter.convertToResponseJson(c)).collect(Collectors.toSet()));
assertEquals(request.getRuntimeVersion(), result.getRuntimeVersion());
}
Aggregations