WorkspaceProject implements Cacheable { public String getName() { if (mainModule != null) { final String moduleName = mainModule.getModuleName(); if (moduleName != null && !mainModule.getModuleName().trim().isEmpty()) { return mainModule.getModuleName(); } else { return repository.getAlias(); } } else { return repository.getAlias(); } } WorkspaceProject();  WorkspaceProject(final OrganizationalUnit organizationalUnit,
                            final Repository repository,
                            final Branch branch,
                            final Module mainModule); OrganizationalUnit getOrganizationalUnit(); Repository getRepository(); Branch getBranch(); Module getMainModule(); String getEncodedIdentifier(); @Override boolean requiresRefresh(); String getName(); @Override void markAsCached(); Path getRootPath(); Space getSpace(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void getNameNoModule() { final Repository repository = mock(Repository.class); doReturn("my-repo").when(repository).getAlias(); final WorkspaceProject workspaceProject = new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), null); assertEquals("my-repo", workspaceProject.getName()); }
@Test public void getName() { final Repository repository = mock(Repository.class); doReturn("my-repo").when(repository).getAlias(); final Module mainModule = mock(Module.class); doReturn("my-module").when(mainModule).getModuleName(); final WorkspaceProject workspaceProject = new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mainModule); assertEquals("my-module", workspaceProject.getName()); }
@Test public void getNameNoModuleName() { final Repository repository = mock(Repository.class); doReturn("my-repo").when(repository).getAlias(); final Module mainModule = mock(Module.class); doReturn("").when(mainModule).getModuleName(); final WorkspaceProject workspaceProject = new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mainModule); assertEquals("my-repo", workspaceProject.getName()); }