Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@

import java.util.NoSuchElementException;
import org.cloudfoundry.client.CloudFoundryClient;
import org.cloudfoundry.client.v2.stacks.ListStacksRequest;
import org.cloudfoundry.client.v2.stacks.StackResource;
import org.cloudfoundry.client.v3.stacks.ListStacksRequest;
import org.cloudfoundry.client.v3.stacks.StackResource;
import org.cloudfoundry.operations.util.OperationsLogging;
import org.cloudfoundry.util.ExceptionUtils;
import org.cloudfoundry.util.PaginationUtils;
import org.cloudfoundry.util.ResourceUtils;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -64,26 +63,26 @@ private static Mono<StackResource> getStack(

private static Flux<StackResource> requestStack(
CloudFoundryClient cloudFoundryClient, String stack) {
return PaginationUtils.requestClientV2Resources(
return PaginationUtils.requestClientV3Resources(
page ->
cloudFoundryClient
.stacks()
.stacksV3()
.list(ListStacksRequest.builder().name(stack).page(page).build()));
}

private static Flux<StackResource> requestStacks(CloudFoundryClient cloudFoundryClient) {
return PaginationUtils.requestClientV2Resources(
return PaginationUtils.requestClientV3Resources(
page ->
cloudFoundryClient
.stacks()
.stacksV3()
.list(ListStacksRequest.builder().page(page).build()));
}

private Stack toStack(StackResource stackResource) {
return Stack.builder()
.description(ResourceUtils.getEntity(stackResource).getDescription())
.id(ResourceUtils.getId(stackResource))
.name(ResourceUtils.getEntity(stackResource).getName())
.description(stackResource.getDescription())
.id(stackResource.getId())
.name(stackResource.getName())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.cloudfoundry.client.v3.organizations.OrganizationsV3;
import org.cloudfoundry.client.v3.routes.RoutesV3;
import org.cloudfoundry.client.v3.spaces.SpacesV3;
import org.cloudfoundry.client.v3.stacks.StacksV3;
import org.cloudfoundry.client.v3.tasks.Tasks;
import org.cloudfoundry.doppler.DopplerClient;
import org.cloudfoundry.routing.RoutingClient;
Expand Down Expand Up @@ -154,6 +155,7 @@ public abstract class AbstractOperationsTest {
protected final SpacesV3 spacesV3 = mock(SpacesV3.class, RETURNS_SMART_NULLS);

protected final Stacks stacks = mock(Stacks.class, RETURNS_SMART_NULLS);
protected final StacksV3 stacksV3 = mock(StacksV3.class, RETURNS_SMART_NULLS);

protected final Tasks tasks = mock(Tasks.class, RETURNS_SMART_NULLS);

Expand Down Expand Up @@ -203,6 +205,7 @@ public final void mockClient() {
when(this.cloudFoundryClient.spaces()).thenReturn(this.spaces);
when(this.cloudFoundryClient.spacesV3()).thenReturn(this.spacesV3);
when(this.cloudFoundryClient.stacks()).thenReturn(this.stacks);
when(this.cloudFoundryClient.stacksV3()).thenReturn(this.stacksV3);
when(this.cloudFoundryClient.tasks()).thenReturn(this.tasks);
when(this.cloudFoundryClient.userProvidedServiceInstances())
.thenReturn(this.userProvidedServiceInstances);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import java.time.Duration;
import org.cloudfoundry.client.CloudFoundryClient;
import org.cloudfoundry.client.v2.stacks.ListStacksRequest;
import org.cloudfoundry.client.v2.stacks.ListStacksResponse;
import org.cloudfoundry.client.v2.stacks.StackResource;
import org.cloudfoundry.client.v3.stacks.ListStacksRequest;
import org.cloudfoundry.client.v3.stacks.ListStacksResponse;
import org.cloudfoundry.client.v3.stacks.StackResource;
import org.cloudfoundry.operations.AbstractOperationsTest;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -58,7 +58,7 @@ void listStacks() {
}

private static void requestStacks(CloudFoundryClient cloudFoundryClient) {
when(cloudFoundryClient.stacks().list(ListStacksRequest.builder().page(1).build()))
when(cloudFoundryClient.stacksV3().list(ListStacksRequest.builder().page(1).build()))
.thenReturn(
Mono.just(
fill(ListStacksResponse.builder())
Expand All @@ -68,7 +68,7 @@ private static void requestStacks(CloudFoundryClient cloudFoundryClient) {

private static void requestStacks(CloudFoundryClient cloudFoundryClient, String name) {
when(cloudFoundryClient
.stacks()
.stacksV3()
.list(ListStacksRequest.builder().name(name).page(1).build()))
.thenReturn(
Mono.just(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.cloudfoundry.operations;

import java.time.Duration;
import org.cloudfoundry.AbstractIntegrationTest;
import org.cloudfoundry.operations.stacks.GetStackRequest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

class StacksTest extends AbstractIntegrationTest {
@Autowired private CloudFoundryOperations cloudFoundryOperations;

@Autowired private Mono<String> stackName;

@Test
public void create() {
this.stackName
.flatMap(
name ->
this.cloudFoundryOperations
.stacks()
.get(GetStackRequest.builder().name(name).build()))
.as(StepVerifier::create)
.expectNextMatches(
s -> s.getDescription().contains("Cloud Foundry Linux-based filesystem"))
.expectComplete()
.verify(Duration.ofMinutes(5));
}

@Test
public void list() {
String stackName = this.stackName.block();
this.cloudFoundryOperations
.stacks()
.list()
.filter(s -> s.getName().equals(stackName))
.as(StepVerifier::create)
.expectNextMatches(
s -> s.getDescription().startsWith("Cloud Foundry Linux-based filesystem"))
.expectComplete()
.verify(Duration.ofMinutes(5));
}
}