Search in sources :

Example 46 with StepVerifier

use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.

the class ApplicationsTest method uploadDirectory.

@Test
public void uploadDirectory() {
    String applicationName = this.nameFactory.getApplicationName();
    this.spaceId.flatMap(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName)).flatMap(applicationId -> {
        try {
            return this.cloudFoundryClient.applicationsV2().upload(UploadApplicationRequest.builder().application(new ClassPathResource("test-application").getFile().toPath()).async(true).applicationId(applicationId).build()).flatMap(job -> JobUtils.waitForCompletion(this.cloudFoundryClient, Duration.ofMinutes(5), job));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }).as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) StepVerifier(reactor.test.StepVerifier) OperationUtils(org.cloudfoundry.util.OperationUtils) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) UploadApplicationRequest(org.cloudfoundry.client.v2.applications.UploadApplicationRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) Duration(java.time.Duration) Map(java.util.Map) ZipExpectations.zipEquality(org.cloudfoundry.client.ZipExpectations.zipEquality) TerminateApplicationInstanceRequest(org.cloudfoundry.client.v2.applications.TerminateApplicationInstanceRequest) ListApplicationsRequest(org.cloudfoundry.client.v2.applications.ListApplicationsRequest) ListApplicationRoutesRequest(org.cloudfoundry.client.v2.applications.ListApplicationRoutesRequest) DownloadApplicationRequest(org.cloudfoundry.client.v2.applications.DownloadApplicationRequest) UploadApplicationDropletRequest(org.cloudfoundry.client.v2.applications.UploadApplicationDropletRequest) Set(java.util.Set) UploadApplicationResponse(org.cloudfoundry.client.v2.applications.UploadApplicationResponse) RestageApplicationRequest(org.cloudfoundry.client.v2.applications.RestageApplicationRequest) UpdateApplicationRequest(org.cloudfoundry.client.v2.applications.UpdateApplicationRequest) CreateServiceBindingResponse(org.cloudfoundry.client.v2.servicebindings.CreateServiceBindingResponse) CreateApplicationResponse(org.cloudfoundry.client.v2.applications.CreateApplicationResponse) SummaryApplicationRequest(org.cloudfoundry.client.v2.applications.SummaryApplicationRequest) ServiceBindingResource(org.cloudfoundry.client.v2.servicebindings.ServiceBindingResource) CloudFoundryClient(org.cloudfoundry.client.CloudFoundryClient) CreatePrivateDomainResponse(org.cloudfoundry.client.v2.privatedomains.CreatePrivateDomainResponse) CreateRouteRequest(org.cloudfoundry.client.v2.routes.CreateRouteRequest) Optional(java.util.Optional) RouteResource(org.cloudfoundry.client.v2.routes.RouteResource) AbstractApplicationResource(org.cloudfoundry.client.v2.applications.AbstractApplicationResource) Exceptions(reactor.core.Exceptions) TupleUtils.function(org.cloudfoundry.util.tuple.TupleUtils.function) TupleUtils.consumer(org.cloudfoundry.util.tuple.TupleUtils.consumer) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) CreateUserProvidedServiceInstanceRequest(org.cloudfoundry.client.v2.userprovidedserviceinstances.CreateUserProvidedServiceInstanceRequest) ServiceBindingEntity(org.cloudfoundry.client.v2.servicebindings.ServiceBindingEntity) ClassPathResource(org.springframework.core.io.ClassPathResource) Tuple2(reactor.util.function.Tuple2) CreateRouteResponse(org.cloudfoundry.client.v2.routes.CreateRouteResponse) ResourceUtils(org.cloudfoundry.util.ResourceUtils) DeleteApplicationRequest(org.cloudfoundry.client.v2.applications.DeleteApplicationRequest) CreatePrivateDomainRequest(org.cloudfoundry.client.v2.privatedomains.CreatePrivateDomainRequest) AssociateApplicationRouteRequest(org.cloudfoundry.client.v2.applications.AssociateApplicationRouteRequest) HashSet(java.util.HashSet) TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry) GetApplicationRequest(org.cloudfoundry.client.v2.applications.GetApplicationRequest) CopyApplicationRequest(org.cloudfoundry.client.v2.applications.CopyApplicationRequest) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) GetApplicationPermissionsResponse(org.cloudfoundry.client.v2.applications.GetApplicationPermissionsResponse) CreateUserProvidedServiceInstanceResponse(org.cloudfoundry.client.v2.userprovidedserviceinstances.CreateUserProvidedServiceInstanceResponse) CloudFoundryVersion(org.cloudfoundry.CloudFoundryVersion) ApplicationInstanceInfo(org.cloudfoundry.client.v2.applications.ApplicationInstanceInfo) PaginationUtils(org.cloudfoundry.util.PaginationUtils) GetApplicationPermissionsRequest(org.cloudfoundry.client.v2.applications.GetApplicationPermissionsRequest) RemoveApplicationRouteRequest(org.cloudfoundry.client.v2.applications.RemoveApplicationRouteRequest) ApplicationEnvironmentRequest(org.cloudfoundry.client.v2.applications.ApplicationEnvironmentRequest) ListApplicationServiceBindingsRequest(org.cloudfoundry.client.v2.applications.ListApplicationServiceBindingsRequest) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) ApplicationStatisticsRequest(org.cloudfoundry.client.v2.applications.ApplicationStatisticsRequest) AssociateApplicationRouteResponse(org.cloudfoundry.client.v2.applications.AssociateApplicationRouteResponse) Consumer(java.util.function.Consumer) UpdateApplicationResponse(org.cloudfoundry.client.v2.applications.UpdateApplicationResponse) CreateServiceBindingRequest(org.cloudfoundry.client.v2.servicebindings.CreateServiceBindingRequest) Flux(reactor.core.publisher.Flux) ApplicationInstancesResponse(org.cloudfoundry.client.v2.applications.ApplicationInstancesResponse) DownloadApplicationDropletRequest(org.cloudfoundry.client.v2.applications.DownloadApplicationDropletRequest) CreateApplicationRequest(org.cloudfoundry.client.v2.applications.CreateApplicationRequest) DelayUtils(org.cloudfoundry.util.DelayUtils) RemoveApplicationServiceBindingRequest(org.cloudfoundry.client.v2.applications.RemoveApplicationServiceBindingRequest) JobUtils(org.cloudfoundry.util.JobUtils) Collections(java.util.Collections) ApplicationInstancesRequest(org.cloudfoundry.client.v2.applications.ApplicationInstancesRequest) SummaryApplicationResponse(org.cloudfoundry.client.v2.applications.SummaryApplicationResponse) Assert(org.springframework.util.Assert) IOException(java.io.IOException) StepVerifier(reactor.test.StepVerifier) ClassPathResource(org.springframework.core.io.ClassPathResource) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 47 with StepVerifier

use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.

the class BuildpacksTest method upload.

@Test
public void upload() throws IOException {
    Path buildpack = new ClassPathResource("test-buildpack.zip").getFile().toPath();
    String buildpackName = this.nameFactory.getBuildpackName();
    createBuildpackId(this.cloudFoundryClient, buildpackName).flatMap(buildpackId -> this.cloudFoundryClient.buildpacks().upload(UploadBuildpackRequest.builder().buildpack(buildpack).buildpackId(buildpackId).filename(buildpack.getFileName().toString()).build())).map(ResourceUtils::getEntity).as(StepVerifier::create).expectNext(BuildpackEntity.builder().enabled(false).filename(buildpack.getFileName().toString()).locked(false).name(buildpackName).position(3).build()).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : Path(java.nio.file.Path) StepVerifier(reactor.test.StepVerifier) CreateBuildpackResponse(org.cloudfoundry.client.v2.buildpacks.CreateBuildpackResponse) UploadBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.UploadBuildpackRequest) ClassPathResource(org.springframework.core.io.ClassPathResource) CreateBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.CreateBuildpackRequest) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) ResourceUtils(org.cloudfoundry.util.ResourceUtils) BuildpackResource(org.cloudfoundry.client.v2.buildpacks.BuildpackResource) DeleteBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.DeleteBuildpackRequest) Flux(reactor.core.publisher.Flux) BuildpackEntity(org.cloudfoundry.client.v2.buildpacks.BuildpackEntity) UpdateBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.UpdateBuildpackRequest) ListBuildpacksRequest(org.cloudfoundry.client.v2.buildpacks.ListBuildpacksRequest) CloudFoundryClient(org.cloudfoundry.client.CloudFoundryClient) JobUtils(org.cloudfoundry.util.JobUtils) Duration(java.time.Duration) GetBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.GetBuildpackRequest) PaginationUtils(org.cloudfoundry.util.PaginationUtils) Path(java.nio.file.Path) ResourceUtils(org.cloudfoundry.util.ResourceUtils) ClassPathResource(org.springframework.core.io.ClassPathResource) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 48 with StepVerifier

use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.

the class ApplicationsTest method startNotStarted.

@Test
public void startNotStarted() throws IOException {
    String applicationName = this.nameFactory.getApplicationName();
    createApplication(this.cloudFoundryOperations, new ClassPathResource("test-application.zip").getFile().toPath(), applicationName, true).then(this.cloudFoundryOperations.applications().start(StartApplicationRequest.builder().name(applicationName).build())).as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : StepVerifier(reactor.test.StepVerifier) ClassPathResource(org.springframework.core.io.ClassPathResource) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 49 with StepVerifier

use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.

the class ApplicationsTest method restartNotStarted.

@Test
public void restartNotStarted() throws IOException {
    String applicationName = this.nameFactory.getApplicationName();
    createApplication(this.cloudFoundryOperations, new ClassPathResource("test-application.zip").getFile().toPath(), applicationName, true).then(this.cloudFoundryOperations.applications().restart(RestartApplicationRequest.builder().name(applicationName).build())).as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : StepVerifier(reactor.test.StepVerifier) ClassPathResource(org.springframework.core.io.ClassPathResource) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 50 with StepVerifier

use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.

the class ApplicationsTest method terminateTask.

@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_1_11)
@Test
public void terminateTask() throws IOException {
    String applicationName = this.nameFactory.getApplicationName();
    String taskName = this.nameFactory.getTaskName();
    createApplication(this.cloudFoundryOperations, new ClassPathResource("test-application.zip").getFile().toPath(), applicationName, false).then(getLongLivedTaskId(this.cloudFoundryOperations, applicationName, taskName)).flatMap(sequenceId -> this.cloudFoundryOperations.applications().terminateTask(TerminateApplicationTaskRequest.builder().applicationName(applicationName).sequenceId(sequenceId).build()).thenReturn(sequenceId)).flatMapMany(sequenceId -> requestListTasks(this.cloudFoundryOperations, applicationName).filter(task -> sequenceId.equals(task.getSequenceId()))).map(Task::getState).as(StepVerifier::create).expectNext(TaskState.FAILED).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : StepVerifier(reactor.test.StepVerifier) GetApplicationManifestRequest(org.cloudfoundry.operations.applications.GetApplicationManifestRequest) PushApplicationRequest(org.cloudfoundry.operations.applications.PushApplicationRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Task(org.cloudfoundry.operations.applications.Task) ClassPathResource(org.springframework.core.io.ClassPathResource) Route(org.cloudfoundry.operations.applications.Route) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) ApplicationHealthCheck(org.cloudfoundry.operations.applications.ApplicationHealthCheck) TaskState(org.cloudfoundry.operations.applications.TaskState) CreateDomainRequest(org.cloudfoundry.operations.domains.CreateDomainRequest) RestartApplicationRequest(org.cloudfoundry.operations.applications.RestartApplicationRequest) DeleteApplicationRequest(org.cloudfoundry.operations.applications.DeleteApplicationRequest) ApplicationDetail(org.cloudfoundry.operations.applications.ApplicationDetail) ApplicationEnvironments(org.cloudfoundry.operations.applications.ApplicationEnvironments) ApplicationSummary(org.cloudfoundry.operations.applications.ApplicationSummary) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) Duration(java.time.Duration) Map(java.util.Map) GetApplicationEventsRequest(org.cloudfoundry.operations.applications.GetApplicationEventsRequest) RunApplicationTaskRequest(org.cloudfoundry.operations.applications.RunApplicationTaskRequest) CloudFoundryVersion(org.cloudfoundry.CloudFoundryVersion) GetApplicationEnvironmentsRequest(org.cloudfoundry.operations.applications.GetApplicationEnvironmentsRequest) ListApplicationTasksRequest(org.cloudfoundry.operations.applications.ListApplicationTasksRequest) CreateSharedDomainRequest(org.cloudfoundry.operations.domains.CreateSharedDomainRequest) CreateUserProvidedServiceInstanceRequest(org.cloudfoundry.operations.services.CreateUserProvidedServiceInstanceRequest) GetApplicationRequest(org.cloudfoundry.operations.applications.GetApplicationRequest) Path(java.nio.file.Path) ApplicationEvent(org.cloudfoundry.operations.applications.ApplicationEvent) GetServiceInstanceRequest(org.cloudfoundry.operations.services.GetServiceInstanceRequest) UnsetEnvironmentVariableApplicationRequest(org.cloudfoundry.operations.applications.UnsetEnvironmentVariableApplicationRequest) ServiceInstance(org.cloudfoundry.operations.services.ServiceInstance) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) ApplicationManifest(org.cloudfoundry.operations.applications.ApplicationManifest) GetApplicationHealthCheckRequest(org.cloudfoundry.operations.applications.GetApplicationHealthCheckRequest) CreateServiceInstanceRequest(org.cloudfoundry.operations.services.CreateServiceInstanceRequest) Flux(reactor.core.publisher.Flux) BindServiceInstanceRequest(org.cloudfoundry.operations.services.BindServiceInstanceRequest) StartApplicationRequest(org.cloudfoundry.operations.applications.StartApplicationRequest) ListRoutesRequest(org.cloudfoundry.operations.routes.ListRoutesRequest) FluentMap(org.cloudfoundry.util.FluentMap) TerminateApplicationTaskRequest(org.cloudfoundry.operations.applications.TerminateApplicationTaskRequest) SetEnvironmentVariableApplicationRequest(org.cloudfoundry.operations.applications.SetEnvironmentVariableApplicationRequest) Collections(java.util.Collections) PushApplicationManifestRequest(org.cloudfoundry.operations.applications.PushApplicationManifestRequest) Task(org.cloudfoundry.operations.applications.Task) ClassPathResource(org.springframework.core.io.ClassPathResource) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

StepVerifier (reactor.test.StepVerifier)82 Mono (reactor.core.publisher.Mono)56 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)48 Test (org.junit.jupiter.api.Test)45 Flux (reactor.core.publisher.Flux)41 Test (org.junit.Test)37 Duration (java.time.Duration)31 ClassPathResource (org.springframework.core.io.ClassPathResource)28 AbstractIntegrationTest (org.cloudfoundry.AbstractIntegrationTest)24 Collections (java.util.Collections)20 Mockito.mock (org.mockito.Mockito.mock)20 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)20 ConnectionFactory (io.r2dbc.spi.ConnectionFactory)19 Connection (io.r2dbc.spi.Connection)17 IOException (java.io.IOException)17 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)17 BeforeEach (org.junit.jupiter.api.BeforeEach)16 Autowired (org.springframework.beans.factory.annotation.Autowired)16 Result (io.r2dbc.spi.Result)14 Path (java.nio.file.Path)14