diff --git a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/stacks/DefaultStacks.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/stacks/DefaultStacks.java index b57dbca983..5ba88cc57e 100644 --- a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/stacks/DefaultStacks.java +++ b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/stacks/DefaultStacks.java @@ -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; @@ -64,26 +63,26 @@ private static Mono getStack( private static Flux 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 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(); } } diff --git a/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/AbstractOperationsTest.java b/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/AbstractOperationsTest.java index b435fab0c1..ab1250658a 100644 --- a/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/AbstractOperationsTest.java +++ b/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/AbstractOperationsTest.java @@ -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; @@ -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); @@ -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); diff --git a/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/stacks/DefaultStacksTest.java b/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/stacks/DefaultStacksTest.java index d64f055eef..1fb1635042 100644 --- a/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/stacks/DefaultStacksTest.java +++ b/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/stacks/DefaultStacksTest.java @@ -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; @@ -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()) @@ -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( diff --git a/integration-test/src/test/java/org/cloudfoundry/operations/StacksTest.java b/integration-test/src/test/java/org/cloudfoundry/operations/StacksTest.java new file mode 100644 index 0000000000..7db823dd95 --- /dev/null +++ b/integration-test/src/test/java/org/cloudfoundry/operations/StacksTest.java @@ -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 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)); + } +}