use of com.sequenceiq.environment.environment.service.freeipa.FreeIpaService in project cloudbreak by hortonworks.
the class FreeIpaCreationHandlerTest method testFreeIpaInstanceTypeIsPopulatedIfProvided.
@Test
public void testFreeIpaInstanceTypeIsPopulatedIfProvided() {
EnvironmentDto environmentDto = someEnvironmentWithFreeIpaCreation();
environmentDto.getFreeIpaCreation().setInstanceType(INSTANCE_TYPE);
environmentDto.setCredential(new Credential());
Environment environment = new Environment();
environment.setCreateFreeIpa(true);
ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build();
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
when(supportedPlatforms.supportedPlatformForFreeIpa(environment.getCloudPlatform())).thenReturn(true);
when(freeIpaService.describe(ENVIRONMENT_CRN)).thenReturn(Optional.empty());
when(connectors.getDefault(any())).thenReturn(mock(CloudConnector.class));
when(freeIpaPollingService.pollWithTimeout(any(FreeIpaCreationRetrievalTask.class), any(FreeIpaPollerObject.class), anyLong(), anyInt(), anyInt())).thenReturn(extendedPollingResult);
victim.accept(new Event<>(environmentDto));
ArgumentCaptor<CreateFreeIpaRequest> freeIpaRequestCaptor = ArgumentCaptor.forClass(CreateFreeIpaRequest.class);
verify(freeIpaService).create(freeIpaRequestCaptor.capture());
CreateFreeIpaRequest freeIpaRequest = freeIpaRequestCaptor.getValue();
assertThat(freeIpaRequest.getInstanceGroups()).extracting(ig -> ig.getInstanceTemplate().getInstanceType()).containsOnly(INSTANCE_TYPE);
}
Aggregations