### Question:
SVNClientImpl implements SVNClient { @Override public Optional<String> getBasePath(SVNRepository svnRepository, String branchPath) { if (isTrunk(branchPath)) { return Optional.of( StringUtils.stripEnd( StringUtils.substringBefore(branchPath, "trunk"), "/" ) ); } else if (isBranch(svnRepository, branchPath)) { return Optional.of( StringUtils.stripEnd( StringUtils.substringBefore(branchPath, "branches"), "/" ) ); } else { return Optional.empty(); } } @Autowired  SVNClientImpl(SVNEventDao svnEventDao, EnvService envService, TransactionService transactionService); @Override boolean exists(SVNRepository repository, SVNURL url, SVNRevision revision); @Override long getRepositoryRevision(SVNRepository repository, SVNURL url); @Override void log(SVNRepository repository, SVNURL url, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision stopRevision, boolean stopOnCopy, boolean discoverChangedPaths, long limit, boolean includeMergedRevisions, ISVNLogEntryHandler isvnLogEntryHandler); @Override List<Long> getMergedRevisions(SVNRepository repository, SVNURL url, long revision); @Override SVNHistory getHistory(SVNRepository repository, String path); @Override List<SVNRevisionPath> getRevisionPaths(SVNRepository repository, long revision); @Override List<String> getBranches(SVNRepository repository, SVNURL url); @Override String getDiff(SVNRepository repository, String path, List<Long> revisions); @Override Optional<String> download(SVNRepository repository, String path); @Override Optional<String> getBasePath(SVNRepository svnRepository, String branchPath); @Override SVNReference getReference(SVNRepository repository, String path); @Override SVNInfo getInfo(SVNRepository repository, SVNURL url, SVNRevision revision); @Override boolean isTrunkOrBranch(SVNRepository repository, String path); @Override boolean isTagOrBranch(SVNRepository repository, String path); @Override boolean isTag(SVNRepository repository, String path); @Override boolean isBranch(SVNRepository repository, String path); @Override boolean isTrunk(String path); static final int HISTORY_MAX_DEPTH; }### Answer:
@Test public void getBasePath_project_trunk_path() { assertFalse(client.getBasePath(repository(), "/project/trunk/path").isPresent()); }
@Test public void getBasePath_project_trunk() { assertEquals("/project", client.getBasePath(repository(), "/project/trunk").get()); }
@Test public void getBasePath_trunk() { assertEquals("", client.getBasePath(repository(), "/trunk").get()); }
@Test public void getBasePath_project_branch_path() { assertFalse(client.getBasePath(repository(), "/project/branches/1.1/path").isPresent()); }
@Test public void getBasePath_project_branch() { assertEquals("/project", client.getBasePath(repository(), "/project/branches/1.1").get()); }
@Test public void getBasePath_branch() { assertEquals("", client.getBasePath(repository(), "/branches/1.1").get()); }
@Test public void getBasePath_path() { assertFalse(client.getBasePath(repository(), "/project/any/path").isPresent()); }