use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.
the class SpaceServiceTest method testGetPendingSpacesByFilterWithSpaceNameSearchCondition.
/**
* Test {@link SpaceService#getPendingSpacesByFilter(String, SpaceFilter))}
*
* @throws Exception
* @since 1.2.0-GA
*/
public void testGetPendingSpacesByFilterWithSpaceNameSearchCondition() throws Exception {
int count = 20;
for (int i = 0; i < count; i++) {
tearDownSpaceList.add(this.getSpaceInstance(i));
}
String nameSpace = "my space";
ListAccess<Space> foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter(nameSpace));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
assertEquals("foundSpaces.load(0, 1).length must return: 1", 1, foundSpaces.load(0, 1).length);
assertEquals("foundSpaces.load(0, count).length must return: " + count, count, foundSpaces.load(0, count).length);
foundSpaces = spaceService.getPendingSpacesByFilter("paul", new SpaceFilter(nameSpace));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("hacker", new SpaceFilter("space"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("add new"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("add*"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("*add*"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("*add"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("*add*e"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("*add*e*"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("%add%e%"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("%add*e%"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("%add*e*"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter("no space"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: 0", 0, foundSpaces.getSize());
}
use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.
the class SpaceServiceTest method testGetPendingSpacesByFilterWithFirstCharacterOfSpaceName.
/**
* Test {@link SpaceService#getPendingSpacesByFilter(String, SpaceFilter)}
*
* @throws Exception
* @since 1.2.0-GA
*/
public void testGetPendingSpacesByFilterWithFirstCharacterOfSpaceName() throws Exception {
int count = 20;
for (int i = 0; i < count; i++) {
tearDownSpaceList.add(this.getSpaceInstance(i));
}
ListAccess<Space> foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter('m'));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
assertEquals("foundSpaces.load(0, 1).length must return: 1", 1, foundSpaces.load(0, 1).length);
assertEquals("foundSpaces.load(0, count).length must return: " + count, count, foundSpaces.load(0, count).length);
foundSpaces = spaceService.getPendingSpacesByFilter("paul", new SpaceFilter('M'));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter('*'));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter('H'));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: 0", 0, foundSpaces.getSize());
foundSpaces = spaceService.getPendingSpacesByFilter("jame", new SpaceFilter('k'));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: 0", 0, foundSpaces.getSize());
}
use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.
the class SpaceServiceTest method testGetPublicSpacesByFilterWithSpaceNameSearchCondition.
/**
* Test {@link SpaceService#getPublicSpacesByFilter(String, SpaceFilter)}
*
* @throws Exception
* @since 1.2.0-GA
*/
public void testGetPublicSpacesByFilterWithSpaceNameSearchCondition() throws Exception {
int count = 20;
for (int i = 0; i < count; i++) {
tearDownSpaceList.add(this.getSpaceInstance(i));
}
String nameSpace = "my space";
ListAccess<Space> foundSpaces = spaceService.getPublicSpacesByFilter("tom", new SpaceFilter(nameSpace));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: 0", 0, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter(nameSpace));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
assertEquals("foundSpaces.load(0, 1).length must return: 1", 1, foundSpaces.load(0, 1).length);
assertEquals("foundSpaces.load(0, count).length must return: " + count, count, foundSpaces.load(0, count).length);
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*m"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("m*"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*my*"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*my*e"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*my*e*"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("%my%e%"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("%my*e%"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("*my%e%"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + count, count, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("***"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter("%%%"));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
nameSpace = "my space 1";
foundSpaces = spaceService.getPublicSpacesByFilter("stranger", new SpaceFilter(""));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
nameSpace = "my space 20";
foundSpaces = spaceService.getPublicSpacesByFilter("hearBreaker", new SpaceFilter(nameSpace));
assertNotNull("foundSpaces must not be null", foundSpaces);
assertEquals("foundSpaces.getSize() must return: " + 0, 0, foundSpaces.getSize());
}
use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.
the class UIManageInvitationSpaces method loadInvitedSpaces.
private List<Space> loadInvitedSpaces(int index, int length) throws Exception {
String charSearch = getSelectedChar();
String searchCondition = uiSpaceSearch.getSpaceNameSearch();
if (SEARCH_ALL.equals(charSearch) || (charSearch == null && searchCondition == null)) {
setInvitedSpacesListAccess(getSpaceService().getInvitedSpacesWithListAccess(getUserId()));
} else if (searchCondition != null) {
setInvitedSpacesListAccess(getSpaceService().getInvitedSpacesByFilter(getUserId(), new SpaceFilter(searchCondition)));
} else if (charSearch != null) {
setInvitedSpacesListAccess(getSpaceService().getInvitedSpacesByFilter(getUserId(), new SpaceFilter(charSearch.charAt(0))));
}
setInvitedSpacesNum(getInvitedSpacesListAccess().getSize());
uiSpaceSearch.setSpaceNum(getInvitedSpacesNum());
Space[] spaces = getInvitedSpacesListAccess().load(index, length);
return new ArrayList<Space>(Arrays.asList(spaces));
}
use of org.exoplatform.social.core.space.SpaceFilter in project social by Meeds-io.
the class UIManageMySpaces method loadMySpaces.
private List<Space> loadMySpaces(int index, int length) throws Exception {
String charSearch = getSelectedChar();
String searchCondition = uiSpaceSearch.getSpaceNameSearch();
if (SEARCH_ALL.equals(charSearch) || (charSearch == null && searchCondition == null)) {
setMySpacesListAccess(getSpaceService().getMemberSpaces(getUserId()));
} else if (searchCondition != null) {
setMySpacesListAccess(getSpaceService().getMemberSpacesByFilter(getUserId(), new SpaceFilter(searchCondition)));
} else if (charSearch != null) {
setMySpacesListAccess(getSpaceService().getMemberSpacesByFilter(getUserId(), new SpaceFilter(charSearch.charAt(0))));
}
setMySpacesNum(getMySpacesListAccess().getSize());
uiSpaceSearch.setSpaceNum(getMySpacesNum());
Space[] spaces = getMySpacesListAccess().load(index, length);
return new ArrayList<Space>(Arrays.asList(spaces));
}
Aggregations