Skip to content
Snippets Groups Projects
Commit 6d773d6a authored by srosse's avatar srosse
Browse files

FXOLAT-296: fix and enhance the unit tests for the /users/* array

parent c6311792
No related branches found
No related tags found
No related merge requests found
......@@ -271,13 +271,13 @@ public class BusinessGroupManagerImpl extends BasicManager implements BusinessGr
query.append(org.olat.group.BusinessGroupImpl.class.getName()).append(" as bgi ");
//inner joins if needed
if(ownedById) {
query.append("inner join bgi.ownerGroup ownerGroup ");
query.append("left join bgi.ownerGroup ownerGroup ");
}
if(attendedById) {
query.append("inner join bgi.partipiciantGroup participantGroup ");
query.append("left join bgi.partipiciantGroup participantGroup ");
}
if(bgContext != null) {
query.append("inner join bgi.groupContext context ");
query.append("left join bgi.groupContext context ");
}
boolean where = false;
......
......@@ -240,13 +240,12 @@ public class UserFoldersWebService {
List<Subscriber> subs = man.getSubscribers(retrievedUser, notiTypes);
for(Subscriber sub:subs) {
String resName = sub.getPublisher().getResName();
Long forumKey = sub.getPublisher().getKey();
if("BusinessGroup".equals(resName)) {
Long groupKey = sub.getPublisher().getResId();
groupNotified.put(groupKey, forumKey);
groupNotified.put(groupKey, sub.getPublisher().getResId());
} else if("CourseModule".equals(resName)) {
Long courseKey = sub.getPublisher().getResId();
courseNotified.put(courseKey, forumKey);
courseNotified.put(courseKey, sub.getPublisher().getResId());
}
}
}
......@@ -295,7 +294,7 @@ public class UserFoldersWebService {
FolderVO folderVo = new FolderVO();
folderVo.setName(bcNode.getShortTitle());
folderVo.setSubscribed(courseNotified.containsKey(entry.getKey()));
folderVo.setSubscribed(courseNotified.containsKey(bcNode.getIdent()));
folderVo.setCourseKey(course.getResourceableId());
folderVo.setCourseNodeId(bcNode.getIdent());
folderVOs.add(folderVo);
......
......@@ -149,7 +149,7 @@ public class UserMgmtTest extends OlatJerseyTestCase {
//create identities
owner1 = JunitTestHelper.createAndPersistIdentityAsUser("user-rest-zero");
id1 = JunitTestHelper.createAndPersistIdentityAsUser("user-rest-one");
id1 = JunitTestHelper.createAndPersistIdentityAsUser("user-rest-one-" + UUID.randomUUID().toString().replace("-", ""));
id2 = JunitTestHelper.createAndPersistIdentityAsUser("user-rest-two");
DBFactory.getInstance().intermediateCommit();
id2.getUser().setProperty("telMobile", "39847592");
......@@ -397,7 +397,7 @@ public class UserMgmtTest extends OlatJerseyTestCase {
@Test
public void testGetUserNotAdmin() throws IOException {
HttpClient c = loginWithCookie("rest-one", "A6B7C8");
HttpClient c = loginWithCookie(id1.getName(), "A6B7C8");
HttpMethod method = createGet("/users/" + id2.getKey(), MediaType.APPLICATION_JSON, true);
int code = c.executeMethod(method);
......@@ -578,9 +578,6 @@ public class UserMgmtTest extends OlatJerseyTestCase {
@Test
public void testUserForums() throws IOException {
System.out.println("************************************************************************");
System.out.println("* testUserForums");
HttpClient c = loginWithCookie(id1.getName(), "A6B7C8");
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("forums")
......@@ -617,9 +614,6 @@ public class UserMgmtTest extends OlatJerseyTestCase {
@Test
public void testUserGroupForum() throws IOException {
System.out.println("************************************************************************");
System.out.println("* testUserGroupForum");
HttpClient c = loginWithCookie(id1.getName(), "A6B7C8");
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("forums")
......@@ -639,9 +633,6 @@ public class UserMgmtTest extends OlatJerseyTestCase {
@Test
public void testUserCourseForum() throws IOException {
System.out.println("************************************************************************");
System.out.println("* testUserCourseForum");
HttpClient c = loginWithCookie(id1.getName(), "A6B7C8");
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("forums")
......@@ -661,9 +652,6 @@ public class UserMgmtTest extends OlatJerseyTestCase {
@Test
public void testUserFolders() throws IOException {
System.out.println("************************************************************************");
System.out.println("* testUserFolders");
HttpClient c = loginWithCookie(id1.getName(), "A6B7C8");
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("folders").build();
......@@ -706,9 +694,6 @@ public class UserMgmtTest extends OlatJerseyTestCase {
@Test
public void testUserGroupFolder() throws IOException {
System.out.println("************************************************************************");
System.out.println("* testUserGroupFolder");
HttpClient c = loginWithCookie(id1.getName(), "A6B7C8");
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("folders")
......@@ -730,9 +715,6 @@ public class UserMgmtTest extends OlatJerseyTestCase {
@Test
public void testUserBCCourseNodeFolder() throws IOException {
System.out.println("************************************************************************");
System.out.println("* testUserBCCourseNodeFolder");
HttpClient c = loginWithCookie(id1.getName(), "A6B7C8");
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("folders")
......@@ -754,9 +736,6 @@ public class UserMgmtTest extends OlatJerseyTestCase {
@Test
public void testUserPersonalFolder() throws Exception {
System.out.println("************************************************************************");
System.out.println("* testUserPersonalFolder");
HttpClient c = loginWithCookie(id1.getName(), "A6B7C8");
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("folders").path("personal").build();
......@@ -822,7 +801,7 @@ public class UserMgmtTest extends OlatJerseyTestCase {
String body = method.getResponseBodyAsString();
List<GroupVO> groups = parseGroupArray(body);
assertNotNull(groups);
assertTrue(groups.size() >= 4);
assertEquals(2, groups.size());//g1 and g2 as g3 and g4 are right groups which are not returned
}
@Test
......@@ -843,7 +822,7 @@ public class UserMgmtTest extends OlatJerseyTestCase {
assertNotNull(groups);
assertNotNull(groups.getGroups());
assertEquals(1, groups.getGroups().length);
assertTrue(groups.getTotalCount() >= 4);
assertEquals(2, groups.getTotalCount());//g1 and g2 as g3 and g4 are right groups which are not returned
}
@Test
......@@ -864,7 +843,7 @@ public class UserMgmtTest extends OlatJerseyTestCase {
assertNotNull(groups);
assertNotNull(groups.getGroups());
assertEquals(1, groups.getGroups().length);
assertTrue(groups.getTotalCount() >= 4);
assertEquals(2, groups.getTotalCount());//g1 and g2 as g3 and g4 are right groups which are not returned
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment