Search in sources :

Example 6 with StepVerifier

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

the class ApplicationsTest method uploadDroplet.

@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_1_9)
@Test
public void uploadDroplet() {
    String applicationName = this.nameFactory.getApplicationName();
    this.spaceId.flatMap(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName)).flatMap(applicationId -> {
        try {
            return this.cloudFoundryClient.applicationsV2().uploadDroplet(UploadApplicationDropletRequest.builder().applicationId(applicationId).droplet(new ClassPathResource("test-droplet.tgz").getFile().toPath()).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) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with StepVerifier

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

the class BuildpacksTest method uploadDirectory.

@Test
public void uploadDirectory() throws IOException {
    Path buildpack = new ClassPathResource("test-buildpack").getFile().toPath();
    String buildpackName = this.nameFactory.getBuildpackName();
    String filename = buildpack.getFileName().toString();
    createBuildpackId(this.cloudFoundryClient, buildpackName).flatMap(buildpackId -> this.cloudFoundryClient.buildpacks().upload(UploadBuildpackRequest.builder().buildpack(buildpack).buildpackId(buildpackId).filename(filename).build())).map(ResourceUtils::getEntity).as(StepVerifier::create).expectNext(BuildpackEntity.builder().enabled(false).filename(filename + ".zip").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 8 with StepVerifier

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

the class ApplicationsTest method pushDomainNotFound.

@Test
public void pushDomainNotFound() throws IOException {
    String applicationName = this.nameFactory.getApplicationName();
    String domainName = this.nameFactory.getDomainName();
    this.cloudFoundryOperations.applications().push(PushApplicationRequest.builder().path(new ClassPathResource("test-application.zip").getFile().toPath()).buildpack("staticfile_buildpack").domain(domainName).diskQuota(512).memory(64).name(applicationName).build()).as(StepVerifier::create).consumeErrorWith(t -> assertThat(t).isInstanceOf(IllegalArgumentException.class).hasMessage("Domain %s not found", domainName)).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) StepVerifier(reactor.test.StepVerifier) ClassPathResource(org.springframework.core.io.ClassPathResource) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 with StepVerifier

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

the class ApplicationsTest method pushNoRoute.

@Test
public void pushNoRoute() throws IOException {
    String applicationName = this.nameFactory.getApplicationName();
    String domainName = this.nameFactory.getDomainName();
    createDomain(this.cloudFoundryOperations, domainName, this.organizationName).then(this.cloudFoundryOperations.applications().push(PushApplicationRequest.builder().path(new ClassPathResource("test-application.zip").getFile().toPath()).buildpack("staticfile_buildpack").diskQuota(512).domain(domainName).memory(64).name(applicationName).noStart(true).build())).then(this.cloudFoundryOperations.applications().push(PushApplicationRequest.builder().path(new ClassPathResource("test-application.zip").getFile().toPath()).buildpack("staticfile_buildpack").diskQuota(512).memory(64).name(applicationName).noRoute(true).noStart(true).build())).thenMany(requestListRoutes(this.cloudFoundryOperations)).flatMapIterable(org.cloudfoundry.operations.routes.Route::getApplications).filter(applicationName::equals).as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : StepVerifier(reactor.test.StepVerifier) ClassPathResource(org.springframework.core.io.ClassPathResource) Route(org.cloudfoundry.operations.applications.Route) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 10 with StepVerifier

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

the class ApplicationsTest method deleteApplication.

@Test
public void deleteApplication() throws IOException {
    String applicationName = this.nameFactory.getApplicationName();
    createApplication(this.cloudFoundryOperations, new ClassPathResource("test-application.zip").getFile().toPath(), applicationName, false).then(this.cloudFoundryOperations.applications().delete(DeleteApplicationRequest.builder().name(applicationName).build())).thenMany(requestListApplications(this.cloudFoundryOperations)).filter(response -> applicationName.equals(response.getName())).as(StepVerifier::create).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) StepVerifier(reactor.test.StepVerifier) ClassPathResource(org.springframework.core.io.ClassPathResource) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

StepVerifier (reactor.test.StepVerifier)234 Test (org.junit.jupiter.api.Test)176 Mono (reactor.core.publisher.Mono)111 Flux (reactor.core.publisher.Flux)92 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)77 Duration (java.time.Duration)76 BeforeEach (org.junit.jupiter.api.BeforeEach)60 Test (org.junit.Test)55 Query (org.springframework.data.mongodb.core.query.Query)54 Assertions (org.assertj.core.api.Assertions)53 Document (org.bson.Document)49 Arrays (java.util.Arrays)46 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)44 Criteria (org.springframework.data.mongodb.core.query.Criteria)44 TimeUnit (java.util.concurrent.TimeUnit)42 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)42 Disposable (reactor.core.Disposable)39 List (java.util.List)38 ClassPathResource (org.springframework.core.io.ClassPathResource)38 AtomicReference (java.util.concurrent.atomic.AtomicReference)37