Example usage for java.time Duration ofMinutes

List of usage examples for java.time Duration ofMinutes

Introduction

In this page you can find the example usage for java.time Duration ofMinutes.

Prototype

public static Duration ofMinutes(long minutes) 

Source Link

Document

Obtains a Duration representing a number of standard minutes.

Usage

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void listRoutesFilterByPath() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();
    String domainName = this.nameFactory.getDomainName();

    Mono.when(this.organizationId, this.spaceId)
            .then(function((organizationId, spaceId) -> Mono.when(Mono.just(organizationId), Mono.just(spaceId),
                    createApplicationId(this.cloudFoundryClient, spaceId, applicationName))))
            .then(function((organizationId, spaceId, applicationId) -> Mono.when(Mono.just(applicationId),
                    createApplicationRoute(this.cloudFoundryClient, organizationId, spaceId, domainName,
                            applicationId))))
            .then(function(//from   w  ww.j a  va 2  s  .c om
                    (applicationId, routeResponse) -> Mono
                            .when(Mono.just(ResourceUtils.getId(routeResponse)),
                                    PaginationUtils
                                            .requestClientV2Resources(
                                                    page -> this.cloudFoundryClient.applicationsV2()
                                                            .listRoutes(ListApplicationRoutesRequest.builder()
                                                                    .applicationId(applicationId)
                                                                    .path(ResourceUtils.getEntity(routeResponse)
                                                                            .getPath())
                                                                    .page(page).build()))
                                            .single().map(ResourceUtils::getId))))
            .as(StepVerifier::create).consumeNextWith(tupleEquality()).expectComplete()
            .verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void listRoutesFilterByPort() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();
    String domainName = this.nameFactory.getDomainName();

    Mono.when(this.organizationId, this.spaceId)
            .then(function((organizationId, spaceId) -> Mono.when(Mono.just(organizationId), Mono.just(spaceId),
                    createApplicationId(this.cloudFoundryClient, spaceId, applicationName))))
            .then(function((organizationId, spaceId, applicationId) -> Mono.when(Mono.just(applicationId),
                    createApplicationRoute(this.cloudFoundryClient, organizationId, spaceId, domainName,
                            applicationId))))
            .then(function(//from www  .j  ava2  s.com
                    (applicationId, routeResponse) -> Mono.when(Mono.just(ResourceUtils.getId(routeResponse)),
                            PaginationUtils.requestClientV2Resources(page -> {
                                ListApplicationRoutesRequest.Builder builder = ListApplicationRoutesRequest
                                        .builder().applicationId(applicationId).page(page);

                                Optional.ofNullable(ResourceUtils.getEntity(routeResponse).getPort())
                                        .ifPresent(builder::port);

                                return this.cloudFoundryClient.applicationsV2().listRoutes(builder.build());
                            }).single().map(ResourceUtils::getId))))
            .as(StepVerifier::create).consumeNextWith(tupleEquality()).expectComplete()
            .verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void listServiceBindings() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();
    String serviceInstanceName = this.nameFactory.getServiceInstanceName();

    this.spaceId//from w  ww  .  j a  va  2 s .  c o m
            .then(spaceId -> Mono.when(createApplicationId(this.cloudFoundryClient, spaceId, applicationName),
                    createUserServiceInstanceId(this.cloudFoundryClient, spaceId, serviceInstanceName)))
            .as(thenKeep(function((applicationId, serviceInstanceId) -> createServiceBindingId(
                    this.cloudFoundryClient, applicationId, serviceInstanceId))))
            .then(function((applicationId, serviceInstanceId) -> Mono.when(Mono.just(serviceInstanceId),
                    getSingleServiceBindingInstanceId(this.cloudFoundryClient, applicationId))))
            .as(StepVerifier::create).consumeNextWith(tupleEquality()).expectComplete()
            .verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void listServiceBindingsFilterByServiceInstanceId() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();
    String serviceInstanceName = this.nameFactory.getServiceInstanceName();

    this.spaceId//from   w ww. j  a va2s.c om
            .then(spaceId -> Mono.when(createApplicationId(this.cloudFoundryClient, spaceId, applicationName),
                    createUserServiceInstanceId(this.cloudFoundryClient, spaceId, serviceInstanceName)))
            .then(function((applicationId, serviceInstanceId) -> Mono.when(Mono.just(applicationId),
                    Mono.just(serviceInstanceId),
                    createServiceBindingId(this.cloudFoundryClient, applicationId, serviceInstanceId))))
            .then(function(
                    (applicationId, serviceInstanceId,
                            serviceBindingId) -> Mono
                                    .when(Mono.just(serviceBindingId),
                                            PaginationUtils
                                                    .requestClientV2Resources(page -> this.cloudFoundryClient
                                                            .applicationsV2().listServiceBindings(
                                                                    ListApplicationServiceBindingsRequest
                                                                            .builder()
                                                                            .applicationId(applicationId)
                                                                            .serviceInstanceId(
                                                                                    serviceInstanceId)
                                                                            .page(page).build()))
                                                    .single().map(ResourceUtils::getId))))
            .as(StepVerifier::create).consumeNextWith(tupleEquality()).expectComplete()
            .verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void removeRoute() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();
    String domainName = this.nameFactory.getDomainName();

    Mono.when(this.organizationId, this.spaceId)
            .then(function((organizationId, spaceId) -> Mono.when(Mono.just(organizationId), Mono.just(spaceId),
                    createApplicationId(this.cloudFoundryClient, spaceId, applicationName))))
            .then(function((organizationId, spaceId, applicationId) -> Mono.when(Mono.just(applicationId),
                    createApplicationRoute(this.cloudFoundryClient, organizationId, spaceId, domainName,
                            applicationId))))
            .as(thenKeep(function((applicationId, routeResponse) -> this.cloudFoundryClient.applicationsV2()
                    .removeRoute(RemoveApplicationRouteRequest.builder().applicationId(applicationId)
                            .routeId(ResourceUtils.getId(routeResponse)).build()))))
            .flatMap(function(/*from  w w w  . j av  a2  s. c  o m*/
                    (applicationId, routeResponse) -> requestRoutes(this.cloudFoundryClient, applicationId)))
            .as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void removeServiceBinding() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();
    String serviceInstanceName = this.nameFactory.getServiceInstanceName();

    this.spaceId//w  w  w .  j ava  2  s. co  m
            .then(spaceId -> Mono.when(createApplicationId(this.cloudFoundryClient, spaceId, applicationName),
                    createUserServiceInstanceId(this.cloudFoundryClient, spaceId, serviceInstanceName)))
            .then(function((applicationId, serviceInstanceId) -> Mono.when(Mono.just(applicationId),
                    createServiceBindingId(this.cloudFoundryClient, applicationId, serviceInstanceId))))
            .as(thenKeep(function((applicationId, serviceBindingId) -> this.cloudFoundryClient.applicationsV2()
                    .removeServiceBinding(RemoveApplicationServiceBindingRequest.builder()
                            .applicationId(applicationId).serviceBindingId(serviceBindingId).build()))))
            .flatMap(function((applicationId,
                    serviceBindingId) -> requestServiceBindings(this.cloudFoundryClient, applicationId)))
            .as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void restage() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();

    this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName))
            .as(thenKeep(applicationId -> uploadAndStartApplication(this.cloudFoundryClient, applicationId)))
            .as(thenKeep(applicationId -> this.cloudFoundryClient.applicationsV2()
                    .restage(RestageApplicationRequest.builder().applicationId(applicationId).build())))
            .then(applicationId -> waitForStagingApplication(this.cloudFoundryClient, applicationId))
            .map(resource -> ResourceUtils.getEntity(resource).getName()).as(StepVerifier::create)
            .expectNext(applicationName).expectComplete().verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void statistics() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();

    this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName))
            .as(thenKeep(applicationId -> uploadAndStartApplication(this.cloudFoundryClient, applicationId)))
            .then(applicationId -> this.cloudFoundryClient.applicationsV2()
                    .statistics(ApplicationStatisticsRequest.builder().applicationId(applicationId).build())
                    .map(instanceStatistics -> instanceStatistics.getInstances().get("0").getStatistics()
                            .getName()))
            .as(StepVerifier::create).expectNext(applicationName).expectComplete()
            .verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void summary() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();

    this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName))
            .then(applicationId -> this.cloudFoundryClient.applicationsV2()
                    .summary(SummaryApplicationRequest.builder().applicationId(applicationId).build())
                    .map(SummaryApplicationResponse::getId).and(Mono.just(applicationId)))
            .as(StepVerifier::create).consumeNextWith(tupleEquality()).expectComplete()
            .verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

@Test
public void terminateInstance() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();

    this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName))
            .as(thenKeep(applicationId -> uploadAndStartApplication(this.cloudFoundryClient, applicationId)))
            .then(applicationId -> Mono.when(Mono.just(applicationId),
                    getInstanceInfo(this.cloudFoundryClient, applicationId, "0")
                            .map(info -> Optional.ofNullable(info.getSince()))))
            .as(thenKeep(function((applicationId, optionalSince) -> this.cloudFoundryClient.applicationsV2()
                    .terminateInstance(TerminateApplicationInstanceRequest.builder()
                            .applicationId(applicationId).index("0").build()))))
            .then(function((applicationId, optionalSince) -> waitForInstanceRestart(this.cloudFoundryClient,
                    applicationId, "0", optionalSince)))
            .as(StepVerifier::create).expectNextCount(1).expectComplete().verify(Duration.ofMinutes(5));
}