⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rapabuildertest.java

📁 Rapla是一个灵活的多用户资源管理系统。它提供的一些功能有:日历GUI
💻 JAVA
字号:
/*--------------------------------------------------------------------------*
 | Copyright (C) 2006  Christopher Kohlhaas                                 |
 |                                                                          |
 | This program is free software; you can redistribute it and/or modify     |
 | it under the terms of the GNU General Public License as published by the |
 | Free Software Foundation. A copy of the license has been included with   |
 | these distribution in the COPYING file, if not go to www.fsf.org         |
 |                                                                          |
 | As a special exception, you are granted the permissions to link this     |
 | program with every library, which license fulfills the Open Source       |
 | Definition as published by the Open Source Initiative (OSI).             |
 *--------------------------------------------------------------------------*/

package org.rapla.gui.tests;
import java.util.Date;

import junit.framework.Test;
import junit.framework.TestSuite;

import org.rapla.RaplaTestCase;
import org.rapla.entities.domain.Appointment;
import org.rapla.entities.domain.AppointmentBlockArray;
import org.rapla.entities.domain.Reservation;
import org.rapla.plugin.abstractcalendar.RaplaBuilder;


public final class RapaBuilderTest extends RaplaTestCase
{
    public RapaBuilderTest(String name) {
        super(name);
    }

    public static Test suite() {
        return new TestSuite(RapaBuilderTest.class);
    }

    public void testSplitAppointments() throws Exception {
        Date start = formater().parseDate("2004-01-01",false);
        Date end = formater().parseDate("2004-01-10",true);

        // test 2 Blocks
        AppointmentBlockArray blocks = new AppointmentBlockArray();
        Reservation reservation = getFacade().newReservation();
        Appointment appointment = getFacade().newAppointment(
                    formater().parseDateTime("2004-01-01","18:30:00")
                    ,formater().parseDateTime("2004-01-02","12:00:00")
                                );
        reservation.addAppointment( appointment );
        appointment.createBlocks(start,end, blocks );
        blocks = RaplaBuilder.splitBlocks( blocks
                    ,start
                    ,end
        );

        assertEquals("Blocks are not split in two", 2, blocks.size());
        assertEquals( formater().parseDateTime("2004-01-01","23:59:59").getTime()/1000, blocks.getEndAt(0)/1000);
        assertEquals( formater().parseDateTime("2004-01-02","00:00:00").getTime(), blocks.getStartAt(1));
        assertEquals( formater().parseDateTime("2004-01-02","12:00:00").getTime(), blocks.getEndAt(1));

        //      test 3 Blocks
        blocks = new AppointmentBlockArray();
        reservation = getFacade().newReservation();
        appointment = getFacade().newAppointment(
                    formater().parseDateTime("2004-01-01","18:30:00")
                    ,formater().parseDateTime("2004-01-04","00:00:00")
                                );
        reservation.addAppointment( appointment );
        appointment.createBlocks(start,end, blocks );
        blocks = RaplaBuilder.splitBlocks( blocks
                                           ,start
                                           ,end
                                         );
        assertEquals("Blocks are not split in three", 3, blocks.size());
        assertEquals(formater().parseDateTime("2004-01-03","23:59:59").getTime()/1000, blocks.getEndAt(2)/1000);

        //      test 3 Blocks, but only the first two should show
        blocks = new AppointmentBlockArray();
        reservation = getFacade().newReservation();
        appointment = getFacade().newAppointment(
                formater().parseDateTime("2004-01-01","18:30:00")
                ,formater().parseDateTime("2004-01-04","00:00:00")
        );
        reservation.addAppointment( appointment );
        appointment.createBlocks(start,end, blocks );
        blocks = RaplaBuilder.splitBlocks( blocks
                ,start
                ,formater().parseDateTime("2004-01-03","00:00:00")

        );
        assertEquals("Blocks are not split in two", 2, blocks.size());
        assertEquals(formater().parseDateTime("2004-01-02","23:59:59").getTime()/1000, blocks.getEndAt(1)/1000);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -