Package org.joda.time

Examples of org.joda.time.DateTime.minusDays()


    public static void testJanitorWithFutureTerminationTime() {
        Collection<Resource> crawledResources = new ArrayList<Resource>();
        Map<String, Resource> trackedResources = new HashMap<String, Resource>();
        int n = 10;
        DateTime now = DateTime.now();
        Date markTime = new Date(now.minusDays(5).getMillis());
        Date notifyTime = new Date(now.minusDays(4).getMillis());
        Date terminationTime = new Date(now.plusDays(10).getMillis());
        for (Resource r : generateTestingResources(n)) {
            trackedResources.put(r.getId(), r);
            r.setState(CleanupState.MARKED);
View Full Code Here


        Collection<Resource> crawledResources = new ArrayList<Resource>();
        Map<String, Resource> trackedResources = new HashMap<String, Resource>();
        int n = 10;
        DateTime now = DateTime.now();
        Date markTime = new Date(now.minusDays(5).getMillis());
        Date notifyTime = new Date(now.minusDays(4).getMillis());
        Date terminationTime = new Date(now.plusDays(10).getMillis());
        for (Resource r : generateTestingResources(n)) {
            trackedResources.put(r.getId(), r);
            r.setState(CleanupState.MARKED);
            r.setNotificationTime(notifyTime);
View Full Code Here

    public static void testJanitorWithUnmarkingUserTerminated() {
        Collection<Resource> crawledResources = new ArrayList<Resource>();
        Map<String, Resource> trackedResources = new HashMap<String, Resource>();
        int n = 10;
        DateTime now = DateTime.now();
        Date markTime = new Date(now.minusDays(5).getMillis());
        Date notifyTime = new Date(now.minusDays(4).getMillis());
        Date terminationTime = new Date(now.minusDays(1).getMillis());
        for (Resource r : generateTestingResources(n)) {
            if (Integer.parseInt(r.getId()) % 3 != 0) {
                crawledResources.add(r);
View Full Code Here

        Collection<Resource> crawledResources = new ArrayList<Resource>();
        Map<String, Resource> trackedResources = new HashMap<String, Resource>();
        int n = 10;
        DateTime now = DateTime.now();
        Date markTime = new Date(now.minusDays(5).getMillis());
        Date notifyTime = new Date(now.minusDays(4).getMillis());
        Date terminationTime = new Date(now.minusDays(1).getMillis());
        for (Resource r : generateTestingResources(n)) {
            if (Integer.parseInt(r.getId()) % 3 != 0) {
                crawledResources.add(r);
            } else {
View Full Code Here

        Map<String, Resource> trackedResources = new HashMap<String, Resource>();
        int n = 10;
        DateTime now = DateTime.now();
        Date markTime = new Date(now.minusDays(5).getMillis());
        Date notifyTime = new Date(now.minusDays(4).getMillis());
        Date terminationTime = new Date(now.minusDays(1).getMillis());
        for (Resource r : generateTestingResources(n)) {
            if (Integer.parseInt(r.getId()) % 3 != 0) {
                crawledResources.add(r);
            } else {
                trackedResources.put(r.getId(), r);
View Full Code Here

            id = Integer.parseInt(resource.getId());
        } catch (Exception e) {
            return true;
        }
        DateTime now = DateTime.now();
        resource.setExpectedTerminationTime(new Date(now.minusDays(1).getMillis()));
        // Set the resource as notified so it can be cleaned
        // set the notification time at more than 1 day before the termination time
        resource.setNotificationTime(new Date(now.minusDays(4).getMillis()));
        return id % 2 == 0;
    }
View Full Code Here

        }
        DateTime now = DateTime.now();
        resource.setExpectedTerminationTime(new Date(now.minusDays(1).getMillis()));
        // Set the resource as notified so it can be cleaned
        // set the notification time at more than 1 day before the termination time
        resource.setNotificationTime(new Date(now.minusDays(4).getMillis()));
        return id % 2 == 0;
    }
}

/**
 
View Full Code Here

    @Test
    public void testTaggedAsNotMark() {
        int ageThreshold = 5;
        DateTime now = DateTime.now();
        Resource resource = new AWSResource().withId("snap123").withResourceType(AWSResourceType.EBS_SNAPSHOT)
                .withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
        ((AWSResource) resource).setAWSResourceState("completed");
        int retentionDays = 4;
        NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(),
                ageThreshold, retentionDays);
        resource.setTag(JanitorMonkey.JANITOR_TAG, "donotmark");
View Full Code Here

    @Test
    public void testUserSpecifiedTerminationDate() {
        int ageThreshold = 5;
        DateTime now = DateTime.now();
        Resource resource = new AWSResource().withId("snap123").withResourceType(AWSResourceType.EBS_SNAPSHOT)
                .withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
        ((AWSResource) resource).setAWSResourceState("completed");
        int retentionDays = 4;
        DateTime userDate = new DateTime(now.plusDays(3).withTimeAtStartOfDay());
        resource.setTag(JanitorMonkey.JANITOR_TAG,
                NoGeneratedAMIRule.TERMINATION_DATE_FORMATTER.print(userDate));
View Full Code Here

    @Test
    public void testOldSnapshotWithoutAMI() {
        int ageThreshold = 5;
        DateTime now = DateTime.now();
        Resource resource = new AWSResource().withId("snap123").withResourceType(AWSResourceType.EBS_SNAPSHOT)
                .withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
        ((AWSResource) resource).setAWSResourceState("completed");
        int retentionDays = 4;
        NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(),
                ageThreshold, retentionDays);
        Assert.assertFalse(rule.isValid(resource));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.