Search in sources :

Example 1 with AppointmentDTO

use of org.apache.openmeetings.db.dto.calendar.AppointmentDTO in project openmeetings by apache.

the class TestCalendarService method actualTest.

private void actualTest(Room r) throws Exception {
    String uuid = UUID.randomUUID().toString();
    User u = getUser(uuid);
    u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
    webCreateUser(u);
    ServiceResult sr = login(u.getLogin(), createPass());
    u = getBean(UserDao.class).get(u.getId());
    Date start = new Date();
    Appointment a = AbstractJUnitDefaults.createAppointment(getBean(AppointmentDao.class), getAppointment(u, r, start, new Date(start.getTime() + ONE_HOUR)));
    AppointmentDTO app = getClient(getCalendarUrl()).path("/room/" + a.getRoom().getId()).query("sid", sr.getMessage()).get(AppointmentDTO.class);
    assertNotNull("Valid DTO should be returned", app);
}
Also used : AbstractJUnitDefaults.getAppointment(org.apache.openmeetings.AbstractJUnitDefaults.getAppointment) Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) AbstractJUnitDefaults.createUser(org.apache.openmeetings.AbstractJUnitDefaults.createUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) AbstractJUnitDefaults.getUser(org.apache.openmeetings.AbstractJUnitDefaults.getUser) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) GroupDao(org.apache.openmeetings.db.dao.user.GroupDao) AppointmentDao(org.apache.openmeetings.db.dao.calendar.AppointmentDao) Date(java.util.Date)

Example 2 with AppointmentDTO

use of org.apache.openmeetings.db.dto.calendar.AppointmentDTO in project openmeetings by apache.

the class TestCalendarService method testCreateWithOmMm.

@Test
public void testCreateWithOmMm() throws Exception {
    JSONObject o = createAppointment("test").put("meetingMembers", new JSONArray().put(new JSONObject().put("user", new JSONObject().put("id", 1))));
    String uuid = UUID.randomUUID().toString();
    User u = getUser(uuid);
    u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
    u = createUser(getBean(UserDao.class), u);
    ServiceResult sr = login(u.getLogin(), createPass());
    Response resp = getClient(getCalendarUrl()).path("/").query("sid", sr.getMessage()).form(new Form().param("appointment", o.toString()));
    assertNotNull("Valid AppointmentDTO should be returned", resp);
    assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
    AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
    assertNotNull("Valid DTO should be returned", dto);
    assertNotNull("DTO id should be valid", dto.getId());
}
Also used : Response(javax.ws.rs.core.Response) User(org.apache.openmeetings.db.entity.user.User) AbstractJUnitDefaults.createUser(org.apache.openmeetings.AbstractJUnitDefaults.createUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) AbstractJUnitDefaults.getUser(org.apache.openmeetings.AbstractJUnitDefaults.getUser) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) JSONObject(com.github.openjson.JSONObject) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Form(javax.ws.rs.core.Form) JSONArray(com.github.openjson.JSONArray) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) GroupDao(org.apache.openmeetings.db.dao.user.GroupDao) Test(org.junit.Test)

Example 3 with AppointmentDTO

use of org.apache.openmeetings.db.dto.calendar.AppointmentDTO in project openmeetings by apache.

the class TestCalendarService method createApp.

private String createApp(String title) throws Exception {
    JSONObject o = createAppointment(title);
    String sid = loginNewUser();
    Response resp = getClient(getCalendarUrl()).path("/").query("sid", sid).form(new Form().param("appointment", o.toString()));
    assertNotNull("Valid AppointmentDTO should be returned", resp);
    assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
    AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
    assertNotNull("Valid DTO should be returned", dto);
    assertNotNull("DTO id should be valid", dto.getId());
    return sid;
}
Also used : Response(javax.ws.rs.core.Response) JSONObject(com.github.openjson.JSONObject) Form(javax.ws.rs.core.Form) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO)

Example 4 with AppointmentDTO

use of org.apache.openmeetings.db.dto.calendar.AppointmentDTO in project openmeetings by apache.

the class AppointmentParamConverter method fromString.

@Override
public AppointmentDTO fromString(String val) {
    JSONObject o = new JSONObject(val);
    if (o.has(ROOT)) {
        o = o.getJSONObject(ROOT);
    }
    AppointmentDTO a = new AppointmentDTO();
    a.setId(optLong(o, "id"));
    a.setTitle(o.optString("title"));
    a.setLocation(o.optString("location"));
    a.setOwner(UserDTO.get(o.optJSONObject("owner")));
    String tzId = a.getOwner() == null ? null : a.getOwner().getTimeZoneId();
    a.setStart(CalendarParamConverter.get(o.optString("start"), tzId));
    a.setEnd(CalendarParamConverter.get(o.optString("end"), tzId));
    a.setDescription(o.optString("description"));
    a.setInserted(DateParamConverter.get(o.optString("inserted")));
    a.setUpdated(DateParamConverter.get(o.optString("updated")));
    a.setDeleted(o.optBoolean("deleted"));
    a.setReminder(optEnum(Reminder.class, o, "reminder"));
    a.setRoom(RoomDTO.get(o.optJSONObject("room")));
    a.setIcalId(o.optString("icalId"));
    JSONArray mm = o.optJSONArray("meetingMembers");
    if (mm != null) {
        for (int i = 0; i < mm.length(); ++i) {
            a.getMeetingMembers().add(MeetingMemberDTO.get(mm.getJSONObject(i)));
        }
    }
    a.setLanguageId(o.optLong("languageId"));
    a.setPassword(o.optString("password"));
    a.setPasswordProtected(o.optBoolean("passwordProtected"));
    a.setConnectedEvent(o.optBoolean("connectedEvent"));
    a.setReminderEmailSend(o.optBoolean("reminderEmailSend"));
    return a;
}
Also used : Reminder(org.apache.openmeetings.db.entity.calendar.Appointment.Reminder) JSONObject(com.github.openjson.JSONObject) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) JSONArray(com.github.openjson.JSONArray)

Example 5 with AppointmentDTO

use of org.apache.openmeetings.db.dto.calendar.AppointmentDTO in project openmeetings by apache.

the class TestCalendarService method testCreateWithGuests.

@Test
public void testCreateWithGuests() throws Exception {
    String sid = loginNewUser();
    AppointmentDTO dto = createEventWithGuests(sid);
    // try to change MM list
    JSONObject o1 = AppointmentParamConverter.json(dto).put("meetingMembers", new JSONArray().put(new JSONObject().put("user", new JSONObject().put("id", 1))));
    Response resp = getClient(getCalendarUrl()).path("/").query("sid", sid).form(new Form().param("appointment", o1.toString()));
    assertNotNull("Valid AppointmentDTO should be returned", resp);
    assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
    dto = resp.readEntity(AppointmentDTO.class);
    assertNotNull("Valid DTO should be returned", dto);
    assertNotNull("DTO id should be valid", dto.getId());
    assertEquals("DTO should have 1 attendees", 1, dto.getMeetingMembers().size());
}
Also used : Response(javax.ws.rs.core.Response) JSONObject(com.github.openjson.JSONObject) Form(javax.ws.rs.core.Form) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) JSONArray(com.github.openjson.JSONArray) Test(org.junit.Test)

Aggregations

AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)9 JSONObject (com.github.openjson.JSONObject)7 JSONArray (com.github.openjson.JSONArray)5 Form (javax.ws.rs.core.Form)5 Response (javax.ws.rs.core.Response)5 User (org.apache.openmeetings.db.entity.user.User)4 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)3 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)3 Test (org.junit.Test)3 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)2 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)2 MeetingMemberDTO (org.apache.openmeetings.db.dto.calendar.MeetingMemberDTO)2 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 WebMethod (javax.jws.WebMethod)1 POST (javax.ws.rs.POST)1