Search in sources :

Example 6 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.

the class AbstractWebServiceTest method createAndValidate.

protected static CallResult<RoomDTO> createAndValidate(String sid, RoomDTO r) {
    if (sid == null) {
        ServiceResult sr = login();
        sid = sr.getMessage();
    }
    RoomDTO room = getClient(getRoomUrl()).query("sid", sid).type(APPLICATION_FORM_URLENCODED).post(new Form().param("room", r.toString()), RoomDTO.class);
    assertNotNull("Valid room should be returned", room);
    assertNotNull("Room ID should be not empty", room.getId());
    RoomDTO room1 = getClient(getRoomUrl()).path(String.format("/%s", room.getId())).query("sid", sid).get(RoomDTO.class);
    assertNotNull("Valid room should be returned", room1);
    assertEquals("Room with same ID should be returned", room.getId(), room1.getId());
    assertEquals("Room with same Name should be returned", r.getName(), room1.getName());
    assertEquals("Room with same ExternalType should be returned", r.getExternalType(), room1.getExternalType());
    assertEquals("Room with same ExternalId should be returned", r.getExternalId(), room1.getExternalId());
    // TODO check other fields
    return new CallResult<>(sid, room1);
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RoomDTO(org.apache.openmeetings.db.dto.room.RoomDTO) Form(javax.ws.rs.core.Form)

Example 7 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult 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 8 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult 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 9 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.

the class TestCalendarService method loginNewUser.

private String loginNewUser() 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());
    return sr.getMessage();
}
Also used : 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) GroupDao(org.apache.openmeetings.db.dao.user.GroupDao)

Example 10 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.

the class TestErrorService method getTestBadKey.

@Test
public void getTestBadKey() {
    Locale[] locales = Locale.getAvailableLocales();
    ServiceResult sr = getClient(getErrorUrl()).path(String.format("/%s/%s", UUID.randomUUID().toString(), LabelDao.getLanguage(locales[rnd.nextInt(locales.length)], 1L))).get(ServiceResult.class);
    assertNotNull("Valid Result should be returned", sr);
    assertEquals("SUCCESS result should be returned", ServiceResult.Type.SUCCESS.name(), sr.getType());
}
Also used : Locale(java.util.Locale) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) Test(org.junit.Test)

Aggregations

ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)37 Test (org.junit.Test)18 Path (javax.ws.rs.Path)12 User (org.apache.openmeetings.db.entity.user.User)8 Response (javax.ws.rs.core.Response)7 WebMethod (javax.jws.WebMethod)5 POST (javax.ws.rs.POST)5 Room (org.apache.openmeetings.db.entity.room.Room)5 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)5 DELETE (javax.ws.rs.DELETE)4 Form (javax.ws.rs.core.Form)4 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)4 GET (javax.ws.rs.GET)3 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)3 RoomDTO (org.apache.openmeetings.db.dto.room.RoomDTO)3 Locale (java.util.Locale)2 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)2 UserDTO (org.apache.openmeetings.db.dto.user.UserDTO)2 FileItem (org.apache.openmeetings.db.entity.file.FileItem)2