List of usage examples for org.apache.commons.collections CollectionUtils select
public static Collection select(Collection inputCollection, Predicate predicate)
From source file:org.mule.module.facebook.automation.testcases.GetAlbumCommentsTestCases.java
@SuppressWarnings("unchecked") @Category({ RegressionTests.class }) @Test//from ww w . j a va2s.c om public void testGetAlbumComments() { try { String albumId = (String) getTestRunMessageValue("albumId"); upsertOnTestRunMessage("album", albumId); final String commentId = (String) getTestRunMessageValue("commentId"); Collection<Comment> comments = runFlowAndGetPayload("get-album-comments"); Collection<Comment> matching = CollectionUtils.select(comments, new Predicate() { @Override public boolean evaluate(Object object) { Comment comment = (Comment) object; return comment.getId().equals(commentId); } }); assertTrue(matching.size() == 1); } catch (Exception e) { fail(ConnectorTestUtils.getStackTrace(e)); } }
From source file:org.mule.module.facebook.automation.testcases.GetAlbumPhotosTestCases.java
@SuppressWarnings("unchecked") @Category({ RegressionTests.class }) @Test//from w ww . j ava2s . co m public void testGetAlbumPhotos() { try { final String photoId = (String) getTestRunMessageValue("photoId"); Collection<Photo> photos = runFlowAndGetPayload("get-album-photos"); Collection<Photo> matchingPhotos = CollectionUtils.select(photos, new Predicate() { @Override public boolean evaluate(Object object) { Photo photo = (Photo) object; return photo.getId().equals(photoId); } }); assertTrue(matchingPhotos.size() == 1); } catch (Exception e) { fail(ConnectorTestUtils.getStackTrace(e)); } }
From source file:org.mule.module.facebook.automation.testcases.GetUserAlbumsTestCases.java
@SuppressWarnings("unchecked") @Category({ RegressionTests.class }) @Test//from www .j a v a 2 s. c o m public void testGetUserAlbums() { try { String profileId = (String) getTestRunMessageValue("profileId"); final String albumId = (String) getTestRunMessageValue("albumId"); String since = (String) getTestRunMessageValue("since"); String until = (String) getTestRunMessageValue("until"); String limit = (String) getTestRunMessageValue("limit"); String offset = (String) getTestRunMessageValue("offset"); Collection<Album> albums = getUserAlbums(profileId, since, until, limit, offset); assertTrue(albums.size() > 0); Collection<Album> matching = CollectionUtils.select(albums, new Predicate() { @Override public boolean evaluate(Object object) { Album album = (Album) object; return album.getId().equals(albumId); } }); assertTrue(matching.size() == 1); } catch (Exception e) { fail(ConnectorTestUtils.getStackTrace(e)); } }
From source file:org.mule.module.facebook.automation.testcases.GetUserPostsTestCases.java
@SuppressWarnings("unchecked") @Category({ RegressionTests.class }) @Test//from w ww . j a va2 s .c o m public void testGetUserPosts() { try { String profileId = (String) getTestRunMessageValue("profileId"); upsertOnTestRunMessage("user", profileId); final List<String> messageIds = (List<String>) getTestRunMessageValue("messageIds"); Collection<Post> posts = runFlowAndGetPayload("get-user-posts"); // Assert that the inserted posts can be found in the user's list of posts Collection<Post> matching = CollectionUtils.select(posts, new Predicate() { @Override public boolean evaluate(Object object) { Post post = (Post) object; return messageIds.contains(post.getId()); } }); assertTrue(matching.size() == messageIds.size()); } catch (Exception e) { fail(ConnectorTestUtils.getStackTrace(e)); } }
From source file:org.mule.module.facebook.automation.testcases.GetUserWallTestCases.java
@SuppressWarnings("unchecked") @Category({ RegressionTests.class }) @Test//from w w w.j a va2 s.c o m public void testGetUserWall() { try { String profileId = (String) getTestRunMessageValue("profileId"); upsertOnTestRunMessage("user", profileId); final List<String> messageIds = (List<String>) getTestRunMessageValue("messageIds"); Collection<Post> posts = runFlowAndGetPayload("get-user-wall"); Collection<Post> matching = CollectionUtils.select(posts, new Predicate() { @Override public boolean evaluate(Object object) { Post post = (Post) object; return messageIds.contains(post.getId()); } }); assertEquals(matching.size(), messageIds.size()); } catch (Exception e) { fail(ConnectorTestUtils.getStackTrace(e)); } }
From source file:org.mule.module.google.spreadsheet.automation.testcases.GoogleSpreadsheetsTestParent.java
protected boolean isRowEqual(Row row1, Row row2) { List<Cell> inputCells = row1.getCells(); List<Cell> retrievedCells = row2.getCells(); for (final Cell cell : inputCells) { List<Cell> matchingCells = (List<Cell>) CollectionUtils.select(retrievedCells, new Predicate() { @Override//from w w w. j a v a 2 s . co m public boolean evaluate(Object object) { Cell cellObject = (Cell) object; return (cell.getColumnNumber() == cellObject.getColumnNumber()) && (cell.getRowNumber() == cellObject.getRowNumber()) && (StringUtils.equals(cell.getValueOrFormula(), cellObject.getValueOrFormula())); } }); if (matchingCells.size() != 1) return false; } return true; }
From source file:org.netbeans.jmiimpl.omg.uml.foundation.core.ClassifierImpl.java
public Collection getAttributes() { return CollectionUtils.select(getFeature(), new InstanceofPredicate(Attribute.class)); }
From source file:org.netbeans.jmiimpl.omg.uml.foundation.core.ClassifierImpl.java
public Collection getOperations() { return CollectionUtils.select(getFeature(), new InstanceofPredicate(Operation.class)); }
From source file:org.netbeans.jmiimpl.omg.uml.foundation.core.ClassifierImpl.java
public Collection getAbstractions() { // todo there's gotta be a better way to do this than iterating the list three times... Collection clientDependencies = getCore().getAClientClientDependency().getClientDependency(this); Collection collection = CollectionUtils.select(clientDependencies, new InstanceofPredicate(Abstraction.class)); return CollectionUtils.collect(collection, new Transformer() { public Object transform(Object object) { return ((Abstraction) object).getSupplier().iterator().next(); }// w w w. ja v a 2s.c om }); }
From source file:org.netbeans.jmiimpl.omg.uml.foundation.core.ModelElementImpl.java
/** * This returns all tags that have the same name. Can tags actually be defined with the same name twice? This is JavaDoc style... * * @param name Name of tag/*from w w w . j a v a 2 s.c om*/ * @param canonical Use fully qualified tag name * @return Collection of TaggedValues that match */ public Collection getTaggedValuesForName(final String name, final boolean canonical) { return CollectionUtils.select(getTaggedValue(), new Predicate() { public boolean evaluate(Object o) { String thisName; if (canonical) { thisName = ((TaggedValueImpl) o).getFullyQualifiedName(); } else { thisName = ((TaggedValueImpl) o).getName(); } return thisName.equals(name); } }); }