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.uaa.IdentityProvidersTest.java

@Test
public void createSaml() {
    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(SamlConfiguration.builder().addShadowUserOnLogin(true).metaDataLocation(
                            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><md:EntityDescriptor xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"http://www.okta"
                                    + ".com/SAML\"><md:IDPSSODescriptor WantAuthnRequestsSigned=\"true\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\"><md:KeyDescriptor "
                                    + "use=\"signing\"><ds:KeyInfo xmlns:ds=\"http://www"
                                    + ".w3.org/2000/09/xmldsig#\"><ds:X509Data><ds:X509Certificate>MIICmTCCAgKgAwIBAgIGAUPATqmEMA0GCSqGSIb3DQEBBQUAMIGPMQswCQYDVQQGEwJVUzETMBEG"
                                    + "\nA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEU\nMBIGA1UECwwLU1NPUHJvdmlkZXIxEDAOBgNVBAMMB1Bpdm90YWwxHDAaBgkqhkiG9w0BCQEWDWlu"
                                    + "\nZm9Ab2t0YS5jb20wHhcNMTQwMTIzMTgxMjM3WhcNNDQwMTIzMTgxMzM3WjCBjzELMAkGA1UEBhMC\nVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xDTALBgNVBAoM"
                                    + "\nBE9rdGExFDASBgNVBAsMC1NTT1Byb3ZpZGVyMRAwDgYDVQQDDAdQaXZvdGFsMRwwGgYJKoZIhvcN\nAQkBFg1pbmZvQG9rdGEuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCeil67/TLOiTZU"
                                    + "\nWWgW2XEGgFZ94bVO90v5J1XmcHMwL8v5Z/8qjdZLpGdwI7Ph0CyXMMNklpaR/Ljb8fsls3amdT5O\nBw92Zo8ulcpjw2wuezTwL0eC0wY/GQDAZiXL59npE6U+fH1lbJIq92hx0HJSru/0O1q3+A/+jjZL\n3tL"
                                    + "/SwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAI5BoWZoH6Mz9vhypZPOJCEKa/K+biZQsA4Zqsuk\nvvphhSERhqk/Nv76Vkl8uvJwwHbQrR9KJx4L3PRkGCG24rix71jEuXVGZUsDNM3CUKnARx4MEab6\nGFHNkZ6DmoT"
                                    + "/PFagngecHu+EwmuDtaG0rEkFrARwe+d8Ru0BN558abFb</ds:X509Certificate></ds:X509Data></ds:KeyInfo></md:KeyDescriptor><md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid"
                                    + "-format:emailAddress</md:NameIDFormat><md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat><md:SingleSignOnService "
                                    + "Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\" Location=\"https://pivotal.oktapreview"
                                    + ".com/app/pivotal_pivotalcfstaging_1/k2lw4l5bPODCMIIDBRYZ/sso/saml\"/><md:SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" "
                                    + "Location=\"https://pivotal.oktapreview.com/app/pivotal_pivotalcfstaging_1/k2lw4l5bPODCMIIDBRYZ/sso/saml\"/></md:IDPSSODescriptor></md:EntityDescriptor>\n")
                            .nameId("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress")
                            .assertionConsumerIndex(0).metadataTrustCheck(false).showSamlLink(false)
                            .socketFactoryClassName(
                                    "org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory")
                            .linkText("IDPEndpointsMockTests Saml Provider:SAML")
                            .groupMappingMode(ExternalGroupMappingMode.EXPLICITLY_MAPPED).build())
                    .identityZoneId(identityZoneName).name(name).originKey("SAML").type(SAML).build()))
            .then(requestListIdentityProviders(this.uaaClient, identityZoneName))
            .flatMapIterable(ListIdentityProvidersResponse::getIdentityProviders)
            .filter(provider -> SAML.equals(provider.getType())).as(StepVerifier::create).expectNextCount(1)
            .expectComplete().verify(Duration.ofMinutes(5));
}

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

@Test
public void delete() {
    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 -> requestCreateIdentityProvider(this.uaaClient, identityZoneName, name))
            .then(response -> this.uaaClient.identityProviders().delete(
                    DeleteIdentityProviderRequest.builder().identityProviderId(response.getId()).build()))
            .then(requestListIdentityProviders(this.uaaClient, identityZoneName))
            .flatMapIterable(ListIdentityProvidersResponse::getIdentityProviders)
            .filter(provider -> name.equals(provider.getName())).as(StepVerifier::create).expectNextCount(0)
            .expectComplete().verify(Duration.ofMinutes(5));
}

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

@Test
public void get() {
    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(requestCreateIdentityProvider(this.uaaClient, identityZoneName, name))
            .then(response -> this.uaaClient.identityProviders()
                    .get(GetIdentityProviderRequest.builder().identityProviderId(response.getId())
                            .identityZoneId(identityZoneName).build()))
            .as(StepVerifier::create).expectNextCount(1).expectComplete().verify(Duration.ofMinutes(5));
}

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

@Test
public void list() {
    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(requestCreateIdentityProvider(this.uaaClient, identityZoneName, name))
            .then(this.uaaClient.identityProviders()
                    .list(ListIdentityProvidersRequest.builder().identityZoneId(identityZoneName).build()))
            .flatMapIterable(ListIdentityProvidersResponse::getIdentityProviders)
            .filter(provider -> OAUTH2.equals(provider.getType())).as(StepVerifier::create).expectNextCount(1)
            .expectComplete().verify(Duration.ofMinutes(5));
}

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

@Test
public void update() {
    String identityZoneName = this.nameFactory.getIdentityZoneName();
    String oldName = this.nameFactory.getIdentityProviderName();
    String newName = this.nameFactory.getIdentityProviderName();
    String subdomainName = this.nameFactory.getDomainName();

    this.userId.then(userId -> requestCreateIdentityZone(this.uaaClient, identityZoneName, subdomainName))
            .then(requestCreateIdentityProvider(this.uaaClient, identityZoneName, oldName))
            .then(response -> this.uaaClient.identityProviders()
                    .update(UpdateIdentityProviderRequest.builder()
                            .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())
                            .identityProviderId(response.getId()).identityZoneId(identityZoneName).name(newName)
                            .originKey("oauth2.0").type(OAUTH2).version(1).build()))
            .then(requestListIdentityProviders(this.uaaClient, identityZoneName))
            .flatMapIterable(ListIdentityProvidersResponse::getIdentityProviders)
            .filter(provider -> newName.equals(provider.getName())).as(StepVerifier::create).expectNextCount(1)
            .expectComplete().verify(Duration.ofMinutes(5));
}

From source file:org.codice.ddf.admin.insecure.defaults.service.DefaultUsersDeletionScheduler.java

@VisibleForTesting
String getCronOrDelete() {//  w  w w. j  a  va 2  s. co m
    if (!getTempTimestampFilePath().toFile().exists()) {

        // Create temp file and add timestamp
        Instant instant = Instant.now();
        if (!createTempFile(instant)) {
            return null;
        }
        return cronCalculator(instant);

    } else {

        // Read timestamp
        Instant firstInstall = installationDate();
        if (firstInstall == null) {
            return null;
        }

        if (Instant.now().isAfter(firstInstall.plus(Duration.ofDays(3)).minus(Duration.ofMinutes(30)))) { // Timestamp expired
            removeDefaultUsers();
            return null;
        }

        return cronCalculator(firstInstall);
    }
}

From source file:org.codice.ddf.admin.insecure.defaults.service.DefaultUsersDeletionScheduler.java

private String cronCalculator(Instant firstInstall) {
    Instant threeDayTimestamp = firstInstall.plus(Duration.ofDays(3).minus(Duration.ofMinutes(30)));
    LocalDateTime localDateTime = LocalDateTime.ofInstant(threeDayTimestamp, ZoneId.systemDefault());

    return String.format("%d+%d+%d+%d+%d+?+%d", localDateTime.getSecond(), localDateTime.getMinute(),
            localDateTime.getHour(), localDateTime.getDayOfMonth(), localDateTime.getMonthValue(),
            localDateTime.getYear());//from  w  w w  .  ja  va 2s.  co  m
}

From source file:org.hawkular.client.test.metrics.openshift.CollectionRateDetailTest.java

@Test
public void findZeroValuesTest() throws Exception {
    String project = "zproject9";
    String container = "stress";
    String testID = "namespace: " + project + ", container: " + container;

    // for easy identification in the log
    String metricID = super.getMetricID(project, container, METRIC_SUFFIX.CPU_USAGE);

    // Get a lot of data in the last few days
    long now = Instant.now().toEpochMilli();
    long start = now - Duration.ofHours(36).toMillis();
    long end = start + Duration.ofHours(36).toMillis();

    Duration timeBucket = Duration.ofHours(1);
    getData(metricID, testID, start, end, timeBucket);

    // get data in the last hour
    start = now - Duration.ofHours(1).toMillis();
    end = now;//from  w w w  .  ja  va 2s.  com
    timeBucket = Duration.ofMinutes(1);
    getData(metricID, testID, start, end, timeBucket);
}

From source file:org.opengrok.suggest.SuggesterTest.java

@Test(expected = IllegalArgumentException.class)
public void testNullSuggesterDir() {
    new Suggester(null, 10, Duration.ofMinutes(5), false, true, null, Integer.MAX_VALUE, 1);
}

From source file:org.opengrok.suggest.SuggesterTest.java

@Test(expected = IllegalArgumentException.class)
public void testNegativeDuration() throws IOException {
    Path tempFile = Files.createTempFile("opengrok", "test");
    try {//from  w  w  w.jav a  2  s .c  o m
        new Suggester(tempFile.toFile(), 10, Duration.ofMinutes(-4), false, true, null, Integer.MAX_VALUE, 1);
    } finally {
        tempFile.toFile().delete();
    }
}