use of org.alfresco.rest.api.tests.client.data.Favourite in project alfresco-remote-api by Alfresco.
the class TestFavourites method testVerifyFavorite.
@Test
public void testVerifyFavorite() throws Exception {
setRequestContext(network1.getId(), person12Id, "password");
// person1's folder (Test Folder1)
final NodeRef folderNodeRef = person1PublicFolders.get(0);
// a file in the site's document library (Test Doc1)
final NodeRef nodeRef1 = person1PublicDocs.get(0);
// a file (Test Doc2) in the folder (Test Folder1)
final NodeRef nodeRef2 = person1PublicDocs.get(1);
// Favourite the doc (Test Doc1)
Favourite file1Favourite = makeFileFavourite(nodeRef1.getId());
favouritesProxy.createFavourite(person12Id, file1Favourite);
// Favourite the doc (Test Doc2)
Favourite file2Favourite = makeFileFavourite(nodeRef2.getId());
favouritesProxy.createFavourite(person12Id, file2Favourite);
Map<String, String> params = new HashMap<>();
params.put("include", "isFavorite");
HttpResponse response = getAll(getNodeChildrenUrl(folderNodeRef.getId()), null, params, 200);
List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
assertTrue(nodes.size() == 1);
assertTrue(nodes.get(0).getIsFavorite());
response = getAll(getNode(nodeRef1.getId()), null, params, 200);
Node node1 = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
assertTrue(node1.getIsFavorite());
}
use of org.alfresco.rest.api.tests.client.data.Favourite in project alfresco-remote-api by Alfresco.
the class TestFavourites method filter.
/**
* Returns a new list.
*
* @param favourites List<Favourite>
* @param types Set<Type>
* @return ArrayList<Favourite>
*/
private ArrayList<Favourite> filter(List<Favourite> favourites, final Set<Type> types) {
Predicate<Favourite> predicate = new Predicate<Favourite>() {
@Override
public boolean apply(Favourite other) {
Type type = null;
if (other.getTarget() instanceof FileFavouriteTarget) {
type = Type.FILE;
} else if (other.getTarget() instanceof FolderFavouriteTarget) {
type = Type.FOLDER;
} else if (other.getTarget() instanceof SiteFavouriteTarget) {
type = Type.SITE;
}
boolean ret = (type != null && types.contains(type));
return ret;
}
};
ArrayList<Favourite> ret = Lists.newArrayList(Collections2.filter(favourites, predicate));
return ret;
}
use of org.alfresco.rest.api.tests.client.data.Favourite in project alfresco-remote-api by Alfresco.
the class TestFavourites method makeFolderFavourite.
private Favourite makeFolderFavourite(String targetGuid) throws ParseException {
FavouriteFolder folder = new FavouriteFolder(targetGuid);
FolderFavouriteTarget target = new FolderFavouriteTarget(folder);
Date creationData = new Date();
Favourite favourite = new Favourite(creationData, null, target);
return favourite;
}
Aggregations