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 update() throws TimeoutException, InterruptedException {
    String applicationName = this.nameFactory.getApplicationName();
    String applicationName2 = this.nameFactory.getApplicationName();

    this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName))
            .then(applicationId -> this.cloudFoundryClient.applicationsV2()
                    .update(UpdateApplicationRequest.builder().applicationId(applicationId)
                            .name(applicationName2).environmentJson("test-var", "test-value").build())
                    .map(ResourceUtils::getId))
            .then(applicationId -> Mono.when(Mono.just(applicationId),
                    requestGetApplication(this.cloudFoundryClient, applicationId)
                            .map(ResourceUtils::getEntity)))
            .then(function((applicationId, entity1) -> Mono.when(Mono.just(entity1),
                    this.cloudFoundryClient.applicationsV2()
                            .update(UpdateApplicationRequest.builder().applicationId(applicationId)
                                    .environmentJsons(Collections.emptyMap()).build())
                            .then(requestGetApplication(this.cloudFoundryClient, applicationId)
                                    .map(ResourceUtils::getEntity)))))
            .as(StepVerifier::create).consumeNextWith(consumer((entity1, entity2) -> {
                assertThat(entity1.getName()).isEqualTo(applicationName2);
                assertThat(entity1.getEnvironmentJsons()).containsEntry("test-var", "test-value");
                assertThat(entity2.getEnvironmentJsons()).isEmpty();
            })).expectComplete().verify(Duration.ofMinutes(5));
}

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

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

    this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName))
            .as(thenKeep(applicationId -> uploadApplication(this.cloudFoundryClient, applicationId)))
            .then(applicationId -> Mono.when(downloadApplication(this.cloudFoundryClient, applicationId),
                    getBytes("test-application.zip")))
            .as(StepVerifier::create).consumeNextWith(zipEquality()).expectComplete()
            .verify(Duration.ofMinutes(5));
}

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

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

    this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName))
            .as(thenKeep(applicationId -> uploadApplicationAsyncFalse(this.cloudFoundryClient, applicationId)))
            .then(applicationId -> Mono.when(downloadApplication(this.cloudFoundryClient, applicationId),
                    getBytes("test-application.zip")))
            .as(StepVerifier::create).consumeNextWith(zipEquality()).expectComplete()
            .verify(Duration.ofMinutes(5));
}

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

private static Mono<ApplicationInstanceInfo> waitForInstanceRestart(CloudFoundryClient cloudFoundryClient,
        String applicationId, String instanceName, Optional<Double> optionalSince) {
    return getInstanceInfo(cloudFoundryClient, applicationId, instanceName)
            .filter(info -> !isIdentical(info.getSince(), optionalSince.orElse(null)))
            .repeatWhenEmpty(DelayUtils.exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15),
                    Duration.ofMinutes(5)));
}

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

private static Mono<AbstractApplicationResource> waitForStagingApplication(
        CloudFoundryClient cloudFoundryClient, String applicationId) {
    return requestGetApplication(cloudFoundryClient, applicationId)
            .filter(response -> "STAGED".equals(response.getEntity().getPackageState()))
            .repeatWhenEmpty(DelayUtils.exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15),
                    Duration.ofMinutes(5)));
}

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

private static Mono<ApplicationInstanceInfo> waitForStartingInstanceInfo(CloudFoundryClient cloudFoundryClient,
        String applicationId) {/*from  www  .  ja va2 s .  com*/
    return cloudFoundryClient.applicationsV2()
            .instances(ApplicationInstancesRequest.builder().applicationId(applicationId).build())
            .flatMap(response -> Flux.fromIterable(response.getInstances().values()))
            .filter(applicationInstanceInfo -> "RUNNING".equals(applicationInstanceInfo.getState())).next()
            .repeatWhenEmpty(DelayUtils.exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15),
                    Duration.ofMinutes(5)));
}

From source file:org.cloudfoundry.dependency.resource.InAction.java

@Override
public final void run(String... args) {
    doRun().doOnNext(response -> writeVersion()).collectList().map(this::toMetadata)
            .map(metadata -> new InResponse(metadata, this.request.getVersion()))
            .doOnNext(this.outputUtils::write).block(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.identity.uaa.provider.oauth.XOAuthAuthenticationManagerIT.java

@BeforeEach
public void setUp() throws Exception {
    RestTemplateConfig restTemplateConfig = new RestTemplateConfig();
    RestTemplate nonTrustingRestTemplate = restTemplateConfig.nonTrustingRestTemplate();
    RestTemplate trustingRestTemplate = restTemplateConfig.trustingRestTemplate();
    SecurityContextHolder.clearContext();
    IdentityZoneHolder.clear();//from w ww  .  ja v a2s  .co  m
    String keyName = "testKey";
    header = map(entry("alg", "HS256"), entry("kid", keyName), entry("typ", "JWT"));
    signer = new RsaSigner(PRIVATE_KEY);
    IdentityZoneHolder.get().getConfig().getTokenPolicy()
            .setKeys(Collections.singletonMap(keyName, PRIVATE_KEY));

    provisioning = mock(IdentityProviderProvisioning.class);
    ScimGroupExternalMembershipManager externalMembershipManager = mock(
            ScimGroupExternalMembershipManager.class);

    for (String scope : SCOPES_LIST) {
        ScimGroupExternalMember member = new ScimGroupExternalMember();
        member.setDisplayName(scope);
        when(externalMembershipManager.getExternalGroupMapsByExternalGroup(eq(scope), anyString(), anyString()))
                .thenReturn(Collections.singletonList(member));
    }

    userDatabase = new InMemoryUaaUserDatabase(Collections.emptySet());
    publisher = mock(ApplicationEventPublisher.class);
    tokenEndpointBuilder = mock(TokenEndpointBuilder.class);
    when(tokenEndpointBuilder.getTokenEndpoint()).thenReturn(UAA_ISSUER_URL);
    OidcMetadataFetcher oidcMetadataFetcher = new OidcMetadataFetcher(
            new ExpiringUrlCache(Duration.ofMinutes(2), new TimeServiceImpl(), 10), trustingRestTemplate,
            nonTrustingRestTemplate);
    xoAuthProviderConfigurator = spy(new XOAuthProviderConfigurator(provisioning, oidcMetadataFetcher));
    xoAuthAuthenticationManager = spy(
            new XOAuthAuthenticationManager(xoAuthProviderConfigurator, trustingRestTemplate,
                    nonTrustingRestTemplate, tokenEndpointBuilder, new KeyInfoService(UAA_ISSUER_URL)));
    xoAuthAuthenticationManager.setUserDatabase(userDatabase);
    xoAuthAuthenticationManager.setExternalMembershipManager(externalMembershipManager);
    xoAuthAuthenticationManager.setApplicationEventPublisher(publisher);
    xoAuthAuthenticationManager.setTokenEndpointBuilder(tokenEndpointBuilder);
    xCodeToken = new XOAuthCodeToken(CODE, ORIGIN, "http://localhost/callback/the_origin");
    claims = map(entry("sub", "12345"), entry("preferred_username", "marissa"), entry("origin", UAA_ORIGIN),
            entry("iss", "http://localhost/oauth/token"), entry("given_name", "Marissa"),
            entry("client_id", "client"), entry("aud", Arrays.asList("identity", "another_trusted_client")),
            entry("zid", "uaa"), entry("user_id", "12345"), entry("azp", "client"),
            entry("scope", Collections.singletonList("openid")), entry("auth_time", 1458603913),
            entry("phone_number", "1234567890"), entry("exp", Instant.now().getEpochSecond() + 3600),
            entry("iat", 1458603913), entry("family_name", "Bloggs"),
            entry("jti", "b23fe183-158d-4adc-8aff-65c440bbbee1"), entry("email", "marissa@bloggs.com"),
            entry("rev_sig", "3314dc98"), entry("cid", "client"), entry("email_verified", true),
            entry(ClaimConstants.ACR, JsonUtils.readValue(
                    "{\"values\": [\"urn:oasis:names:tc:SAML:2.0:ac:classes:Password\"] }", Map.class)));

    attributeMappings = new HashMap<>();

    config = new OIDCIdentityProviderDefinition().setAuthUrl(new URL("http://localhost/oauth/authorize"))
            .setTokenUrl(new URL("http://localhost/oauth/token")).setIssuer("http://localhost/oauth/token")
            .setShowLinkText(true).setLinkText("My OIDC Provider").setRelyingPartyId("identity")
            .setRelyingPartySecret("identitysecret").setUserInfoUrl(new URL("http://localhost/userinfo"))
            .setTokenKey(PUBLIC_KEY);
    config.setExternalGroupsWhitelist(Collections.singletonList("*"));

    mockUaaServer = MockRestServiceServer.createServer(nonTrustingRestTemplate);

    invalidRsaSigningKey = "-----BEGIN RSA PRIVATE KEY-----\n"
            + "MIIBOgIBAAJBAJnlBG4lLmUiHslsKDODfd0MqmGZRNUOhn7eO3cKobsFljUKzRQe\n"
            + "GB7LYMjPavnKccm6+jWSXutpzfAc9A9wXG8CAwEAAQJADwwdiseH6cuURw2UQLUy\n"
            + "sVJztmdOG6b375+7IMChX6/cgoF0roCPP0Xr70y1J4TXvFhjcwTgm4RI+AUiIDKw\n"
            + "gQIhAPQHwHzdYG1639Qz/TCHzuai0ItwVC1wlqKpat+CaqdZAiEAoXFyS7249mRu\n"
            + "xtwRAvxKMe+eshHvG2le+ZDrM/pz8QcCIQCzmCDpxGL7L7sbCUgFN23l/11Lwdex\n"
            + "uXKjM9wbsnebwQIgeZIbVovUp74zaQ44xT3EhVwC7ebxXnv3qAkIBMk526sCIDVg\n"
            + "z1jr3KEcaq9zjNJd9sKBkqpkVSqj8Mv+Amq+YjBA\n" + "-----END RSA PRIVATE KEY-----";
}

From source file:org.cloudfoundry.uaa.IdentityProvidersTest.java

@Test
public void createLdapSimpleBind() {
    String identityZoneName = this.nameFactory.getIdentityZoneName();
    String name = this.nameFactory.getIdentityProviderName();
    String subdomainName = this.nameFactory.getDomainName();

    this.userId.then(userId -> requestCreateIdentityZone(this.uaaClient, identityZoneName, subdomainName))
            .then(this.uaaClient.identityProviders().create(CreateIdentityProviderRequest.builder().active(true)
                    .configuration(LdapConfiguration.builder().addShadowUserOnLogin(true).autoAddGroups(true)
                            .baseUrl(String.format("ldap://%s.url", name)).groupSearchDepthLimit(10)
                            .groupSearchSubTree(true).ldapGroupFile(LdapGroupFile.NO_GROUP)
                            .ldapProfileFile(LdapProfileFile.SIMPLE_BIND).mailAttributeName("mail")
                            .mailSubstituteOverridesLdap(false).skipSSLVerification(false)
                            .tlsConfiguration(TlsConfiguration.NONE)
                            .userDistinguishedNamePattern("cn={0},ou=Users,dc=test,dc=com")
                            .userDistinguishedNamePatternDelimiter(";").build())
                    .identityZoneId(identityZoneName).name(name).originKey("ldap").type(LDAP).build()))
            .then(requestListIdentityProviders(this.uaaClient, identityZoneName))
            .flatMapIterable(ListIdentityProvidersResponse::getIdentityProviders)
            .filter(provider -> LDAP.equals(provider.getType())).as(StepVerifier::create).expectNextCount(1)
            .expectComplete().verify(Duration.ofMinutes(5));
}

From source file:org.cloudfoundry.uaa.IdentityProvidersTest.java

@Test
public void createOAuth() {
    String identityZoneName = this.nameFactory.getIdentityZoneName();
    String name = this.nameFactory.getIdentityProviderName();
    String subdomainName = this.nameFactory.getDomainName();

    this.userId.then(userId -> requestCreateIdentityZone(this.uaaClient, identityZoneName, subdomainName))
            .then(ignore -> this.uaaClient.identityProviders()
                    .create(CreateIdentityProviderRequest.builder().active(true)
                            .configuration(OAuth2Configuration.builder().addShadowUserOnLogin(true)
                                    .authUrl("http://auth.url").relyingPartyId("uaa")
                                    .relyingPartySecret("secret").showLinkText(false).skipSslVerification(false)
                                    .tokenKey("token-key").tokenUrl("http://token.url").build())
                            .identityZoneId(identityZoneName).name(name).originKey("oauth2.0").type(OAUTH2)
                            .build()))// w ww.  j a va2s.c  o m
            .then(requestListIdentityProviders(this.uaaClient, identityZoneName))
            .flatMapIterable(ListIdentityProvidersResponse::getIdentityProviders)
            .filter(provider -> OAUTH2.equals(provider.getType())).as(StepVerifier::create).expectNextCount(1)
            .expectComplete().verify(Duration.ofMinutes(5));
}