Repository: openmeetings
Updated Branches:
  refs/heads/master 13553185b -> b7e349585


[OPENMEETINGS-1705] get appointment by title api method is fixed


Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo
Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/b7e34958
Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/b7e34958
Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/b7e34958

Branch: refs/heads/master
Commit: b7e34958537abf571a06a88c116ea9afd95b25b1
Parents: 1355318
Author: Maxim Solodovnik <solomax...@gmail.com>
Authored: Sat Sep 16 00:47:30 2017 +0700
Committer: Maxim Solodovnik <solomax...@gmail.com>
Committed: Sat Sep 16 00:47:56 2017 +0700

----------------------------------------------------------------------
 .../db/dao/calendar/AppointmentDao.java         |  2 +-
 .../test/webservice/TestCalendarService.java    | 42 ++++++++++++++++----
 2 files changed, 36 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/openmeetings/blob/b7e34958/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/AppointmentDao.java
----------------------------------------------------------------------
diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/AppointmentDao.java
 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/AppointmentDao.java
index 8aec978..d516b3e 100644
--- 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/AppointmentDao.java
+++ 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/AppointmentDao.java
@@ -205,7 +205,7 @@ public class AppointmentDao {
        }
 
        public List<Appointment> searchAppointmentsByTitle(Long userId, String 
title) {
-               return em.createNamedQuery("getNextAppointment", 
Appointment.class)
+               return em.createNamedQuery("getAppointmentsByTitle", 
Appointment.class)
                                .setParameter("title", 
title).setParameter("userId", userId).getResultList();
        }
 

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/b7e34958/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java
----------------------------------------------------------------------
diff --git 
a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java
 
b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java
index 8258f61..63019c6 100644
--- 
a/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java
+++ 
b/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/TestCalendarService.java
@@ -90,9 +90,9 @@ public class TestCalendarService extends 
AbstractWebServiceTest {
                actualTest(roomDao.get(5L)); //default public presentation room
        }
 
-       private static JSONObject createAppointment() {
+       private static JSONObject createAppointment(String title) {
                return new JSONObject()
-                       .put("title", "test")
+                       .put("title", title)
                        .put("start", "2025-01-20T20:30:03+0300")
                        .put("end", "2025-01-20T21:30:03+0300")
                        .put("description", "Русский Тест")
@@ -136,9 +136,8 @@ public class TestCalendarService extends 
AbstractWebServiceTest {
                return sr.getMessage();
        }
 
-       @Test
-       public void testCreate() throws Exception {
-               JSONObject o = createAppointment();
+       private String createApp(String title) throws Exception {
+               JSONObject o = createAppointment(title);
 
                String sid = loginNewUser();
 
@@ -152,6 +151,13 @@ public class TestCalendarService extends 
AbstractWebServiceTest {
                AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
                assertNotNull("Valid DTO should be returned", dto);
                assertNotNull("DTO id should be valid", dto.getId());
+
+               return sid;
+       }
+
+       @Test
+       public void testCreate() throws Exception {
+               createApp("test");
        }
 
        @Test
@@ -167,7 +173,7 @@ public class TestCalendarService extends 
AbstractWebServiceTest {
 
        @Test
        public void testCreateWithOmMm() throws Exception {
-               JSONObject o = createAppointment()
+               JSONObject o = createAppointment("test")
                                .put("meetingMembers", new JSONArray()
                                                .put(new 
JSONObject().put("user", new JSONObject()
                                                                .put("id", 
1))));
@@ -191,7 +197,7 @@ public class TestCalendarService extends 
AbstractWebServiceTest {
        }
 
        private static AppointmentDTO createEventWithGuests(String sid) throws 
Exception {
-               JSONObject o = createAppointment()
+               JSONObject o = createAppointment("test")
                                .put("meetingMembers", new JSONArray()
                                                .put(new 
JSONObject().put("user", new JSONObject()
                                                                
.put("firstname", "John 1")
@@ -277,4 +283,26 @@ public class TestCalendarService extends 
AbstractWebServiceTest {
                assertNotNull("Meeting member user should not be deleted", uc);
                assertFalse("Meeting member user should not be deleted", 
uc.isDeleted());
        }
+
+       @Test
+       public void testGetByTitle() throws Exception {
+               String title = "title" + UUID.randomUUID().toString();
+               String sid = createApp(title);
+               @SuppressWarnings("unchecked")
+               List<AppointmentDTO> list = 
(List<AppointmentDTO>)getClient(CALENDAR_SERVICE_URL)
+                       .path(String.format("/title/%s", title))
+                       .query("sid", sid)
+                       .getCollection(AppointmentDTO.class);
+
+               assertEquals("List of one item should be returned", 1, 
list.size());
+               assertEquals("Title should match", title, 
list.get(0).getTitle());
+
+               title = UUID.randomUUID().toString();
+               @SuppressWarnings("unchecked")
+               List<AppointmentDTO> list1 = 
(List<AppointmentDTO>)getClient(CALENDAR_SERVICE_URL)
+                       .path(String.format("/title/%s", title))
+                       .query("sid", sid)
+                       .getCollection(AppointmentDTO.class);
+               assertEquals("None items should be returned", 0, list1.size());
+       }
 }

Reply via email to