PartRevision implements Serializable, Comparable<PartRevision> { public PartIteration getLastAccessibleIteration(User user) { if(isCheckoutByAnotherUser(user)) { return partIterations.size() <= 1 ? null : partIterations.get(partIterations.size() -2); } else { return getLastIteration(); } } PartRevision();  PartRevision(PartMaster pPartMaster,
            String pStringVersion,
            User pAuthor);  PartRevision(PartMaster pPartMaster,
            Version pVersion,
            User pAuthor);  PartRevision(PartMaster pPartMaster, User pAuthor); private  PartRevision(PartMaster pPartMaster); void setPartMaster(PartMaster partMaster); @XmlTransient PartMaster getPartMaster(); PartRevisionKey getKey(); boolean isCheckedOut(); User getAuthor(); void setAuthor(User author); Date getCreationDate(); void setCreationDate(Date creationDate); Date getCheckOutDate(); void setCheckOutDate(Date checkOutDate); User getCheckOutUser(); void setCheckOutUser(User checkOutUser); String getVersion(); void setVersion(String version); String getType(); Workflow getWorkflow(); void setWorkflow(Workflow pWorkflow); String getLifeCycleState(); boolean hasWorkflow(); ACL getACL(); void setACL(ACL acl); Set<Tag> getTags(); Set<Tag> setTags(Set<Tag> pTags); boolean addTag(Tag pTag); boolean removeTag(Tag pTag); List<Workflow> getAbortedWorkflows(); void addAbortedWorkflows(Workflow abortedWorkflow); PartIteration createNextIteration(User pUser); List<PartIteration> getPartIterations(); void setPartIterations(List<PartIteration> partIterations); PartIteration getLastIteration(); PartIteration getLastCheckedInIteration(); int getLastIterationNumber(); PartIteration getWorkingCopy(); PartIteration removeLastIteration(); PartIteration getIteration(int pIteration); int getNumberOfIterations(); String getDescription(); void setDescription(String description); PartMasterKey getPartMasterKey(); String getWorkspaceId(); String getPartNumber(); String getPartName(); String getPartMasterNumber(); void setPartMasterNumber(String pPartMasterNumber); String getPartMasterWorkspaceId(); void setPartMasterWorkspaceId(String pPartMasterWorkspaceId); Set<Effectivity> getEffectivities(); void setEffectivities(Set<Effectivity> effectivities); boolean removeEffectivity(Effectivity pEffectivity); boolean isPublicShared(); void setPublicShared(boolean publicShared); RevisionStatus getStatus(); void setStatus(RevisionStatus status); boolean isReleased(); boolean isObsolete(); boolean release(User user); boolean markAsObsolete(User user); boolean isAttributesLocked(); StatusChange getObsoleteStatusChange(); void setObsoleteStatusChange(StatusChange statusChange); StatusChange getReleaseStatusChange(); void setReleaseStatusChange(StatusChange statusChange); User getObsoleteAuthor(); Date getObsoleteDate(); User getReleaseAuthor(); Date getReleaseDate(); boolean isLastRevision(); @Override String toString(); @Override boolean equals(Object pObj); @Override int hashCode(); @Override int compareTo(PartRevision pPartR); PartIteration getLastAccessibleIteration(User user);  }
@Test public void testGetLastAccessibleIteration() throws Exception { PartIteration partIteration = Mockito.mock(PartIteration.class); partIterations.add(partIteration); Assert.assertTrue(partRevision.getLastAccessibleIteration(new User()) != null); partRevision.setCheckOutUser(user); Assert.assertTrue(partRevision.getLastAccessibleIteration(new User()) == null); Assert.assertTrue(partRevision.getLastAccessibleIteration(user) != null); partIterations.add(Mockito.mock(PartIteration.class)); Assert.assertTrue(partRevision.getLastAccessibleIteration(new User()) == partIteration); }