use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackCreationHandlerTest method acceptTest.
@Test
void acceptTest() {
long stackId = 2L;
StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
Event receivedEvent = new Event<>(stackCreationWaitRequest);
StackV4Response stackV4Response = new StackV4Response();
when(provisionerService.waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class))).thenReturn(stackV4Response);
stackCreationHandler.accept(receivedEvent);
verify(provisionerService, times(1)).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
verify(sdxService, times(1)).updateRuntimeVersionFromStackResponse(any(), eq(stackV4Response));
verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
String eventNotified = eventSelector.getValue();
Event event = sentEvent.getValue();
Assertions.assertEquals("StackCreationSuccessEvent", eventNotified);
Assertions.assertEquals(StackCreationSuccessEvent.class, event.getData().getClass());
Assertions.assertEquals(stackId, ((StackCreationSuccessEvent) event.getData()).getResourceId());
verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(STACK_CREATION_FINISHED, "Datalake stack created", (Long) stackId);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method testConvertWithoutCluster.
@Test
public void testConvertWithoutCluster() throws CloudbreakImageNotFoundException {
Stack source = getSource();
// GIVEN
getSource().setCluster(null);
given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
given(imageToStackImageV4ResponseConverter.convert(any())).willReturn(new StackImageV4Response());
given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any())).willReturn(new StackAuthenticationV4Response());
given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
// WHEN
StackV4Response result = underTest.convert(source);
// THEN
assertAllFieldsNotNull(result, Arrays.asList("cluster", "gcp", "mock", "openstack", "aws", "yarn", "azure", "telemetry", "environmentName", "credentialName", "credentialCrn", "telemetry", "flowIdentifier", "loadBalancers"));
assertNull(result.getCluster());
verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method setUp.
@Before
public void setUp() throws CloudbreakImageNotFoundException {
underTest = new StackToStackV4ResponseConverter();
MockitoAnnotations.initMocks(this);
when(imageService.getImage(anyLong())).thenReturn(new Image("cb-centos66-amb200-2015-05-25", Collections.emptyMap(), "redhat6", "redhat6", "", "default", "default-id", new HashMap<>()));
when(componentConfigProviderService.getCloudbreakDetails(anyLong())).thenReturn(new CloudbreakDetails("version"));
when(componentConfigProviderService.getStackTemplate(anyLong())).thenReturn(new StackTemplate("{}", "version"));
when(componentConfigProviderService.getTelemetry(anyLong())).thenReturn(new Telemetry());
Mockito.doAnswer(answer -> {
StackV4Response result = answer.getArgument(1, StackV4Response.class);
result.setSharedService(new SharedServiceV4Response());
return null;
}).when(datalakeService).addSharedServiceResponse(any(Stack.class), any(StackV4Response.class));
when(serviceEndpointCollector.filterByStackType(any(StackType.class), any(List.class))).thenReturn(new ArrayList());
credentialResponse = new CredentialResponse();
credentialResponse.setName("cred-name");
credentialResponse.setCrn("crn");
when(loadBalancerService.findByStackId(any())).thenReturn(Set.of());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method testConvertWithLoadBalancers.
@Test
public void testConvertWithLoadBalancers() throws CloudbreakImageNotFoundException {
Set<LoadBalancer> loadBalancers = Set.of(new LoadBalancer());
Stack source = getSource();
// GIVEN
given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
given(imageToStackImageV4ResponseConverter.convert(any())).willReturn(new StackImageV4Response());
given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any())).willReturn(new StackAuthenticationV4Response());
given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
given(loadBalancerService.findByStackId(any())).willReturn(loadBalancers);
// WHEN
source.setLoadBalancers(loadBalancers);
StackV4Response result = underTest.convert(source);
// THEN
assertNotNull(result.getLoadBalancers());
assertTrue(result.isEnableLoadBalancer());
verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackOperationsTest method testGetWhenNameOrCrnNameFilledThenProperGetCalled.
@Test
public void testGetWhenNameOrCrnNameFilledThenProperGetCalled() {
StackV4Response expected = stackResponse();
NameOrCrn nameOrCrn = NameOrCrn.ofName(stack.getName());
when(stackCommonService.findStackByNameOrCrnAndWorkspaceId(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE)).thenReturn(expected);
StackV4Response result = underTest.get(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE);
assertEquals(expected, result);
verify(stackCommonService, times(1)).findStackByNameOrCrnAndWorkspaceId(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE);
}
Aggregations