Package appointment.test

Source Code of appointment.test.AddMultipleAppointmentTest

package appointment.test;

import static org.junit.Assert.assertEquals;

import java.util.Calendar;
import java.util.Date;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import appointment.core.IAddAppointmentRemote;
import appointment.core.IRegisterRemote;
import appointment.core.IRemoveUserRemote;
import appointment.core.IViewAppointmentRemote;
import appointment.helper.BeanConnector;
import appointment.objects.AppointmentState;
import appointment.test.objects.TestUser;

public class AddMultipleAppointmentTest {
  private IAddAppointmentRemote addAppointmentBean;
  private IRegisterRemote registerUserBean;
  private IRemoveUserRemote removeUserBean;
  private IViewAppointmentRemote viewAppointmentBean;
  private TestUser user1;
  private TestUser user2;

  @Before
  public void setUp() {

    registerUserBean = BeanConnector.getBean("IRegister/remote",
        IRegisterRemote.class);

    addAppointmentBean = BeanConnector.getBean("IAddAppointment/remote",
        IAddAppointmentRemote.class);

    viewAppointmentBean = BeanConnector.getBean("IViewAppointment/remote",
        IViewAppointmentRemote.class);

    // Testnutzerobjekte anlegen
    user1 = new TestUser("Horst", "blubb");
    user2 = new TestUser("Hans", "bla");

    // Nutzer registrieren
    registerUserBean.register(user1.name, "test@test.de", user1.password);
    registerUserBean.register(user2.name, "test@tester.de", user2.password);
  }

  @Test
  public void addAppointmentTest() {

    Date start = new Date();
    Date end = new Date();

    Calendar cal = Calendar.getInstance();
   
    //------------------ERSTES APP--------------------
    cal.add(Calendar.HOUR, 2);
    end = cal.getTime();

    Boolean appointmentAdded = false;

    appointmentAdded = addAppointmentBean.addAppointment(user1.name, start,
        end, "test_title1", "should be public",
        AppointmentState.BLOCKED, true);
   
    assertEquals(true, appointmentAdded);
   
    //------------------ZWEITES APP--------------------
   
    cal.add(Calendar.DAY_OF_MONTH, 1);
    start = cal.getTime();
   
    cal.add(Calendar.HOUR, 1);
    end = cal.getTime();
   
    appointmentAdded = addAppointmentBean.addAppointment(user1.name, start,
        end, "test_title2", "should be public",
        AppointmentState.BLOCKED, true);

    assertEquals(true, appointmentAdded);

    long appointmentId = viewAppointmentBean.getAppointments(user1.name)
        .get(1);

    assertEquals("test_title2", viewAppointmentBean.getTitle(appointmentId));

  }
 
  @After
  public void tearDown() {

    removeUserBean = BeanConnector.getBean("IRemoveUser/remote",
        IRemoveUserRemote.class);

    removeUserBean.remove(user1.name);
    removeUserBean.remove(user2.name);

  }
}
TOP

Related Classes of appointment.test.AddMultipleAppointmentTest

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.