@Test public void testGetUserNameFromRepoPath() { String reponame = Constants.DEFAULT_USER_REPOSITORY_PREFIX + "lynn"; assertEquals("lynn", ModelUtils.getUserNameFromRepoPath(reponame)); ModelUtils.setUserRepoPrefix("@@"); reponame = "@@newton"; assertEquals("newton", ModelUtils.getUserNameFromRepoPath(reponame)); ModelUtils.setUserRepoPrefix("users/"); reponame = "users/fee"; assertEquals("fee", ModelUtils.getUserNameFromRepoPath(reponame)); }
@Test public void testGetPersonalPath() { String username = "******"; assertEquals( Constants.DEFAULT_USER_REPOSITORY_PREFIX + username.toLowerCase(), ModelUtils.getPersonalPath(username)); username = "******"; assertEquals( Constants.DEFAULT_USER_REPOSITORY_PREFIX + username.toLowerCase(), ModelUtils.getPersonalPath(username)); ModelUtils.setUserRepoPrefix("usr/"); username = "******"; assertEquals("usr/" + username.toLowerCase(), ModelUtils.getPersonalPath(username)); }
@Test public void testIsUsersPersonalRepository() { String reponame = Constants.DEFAULT_USER_REPOSITORY_PREFIX + "lynn"; assertTrue(ModelUtils.isUsersPersonalRepository("lynn", reponame)); reponame = "prjB"; assertFalse(ModelUtils.isUsersPersonalRepository("lynn", reponame)); ModelUtils.setUserRepoPrefix("@@"); reponame = "@@newton"; assertTrue(ModelUtils.isUsersPersonalRepository("newton", reponame)); assertFalse(ModelUtils.isUsersPersonalRepository("hertz", reponame)); ModelUtils.setUserRepoPrefix("users/"); reponame = "users/fee"; assertTrue(ModelUtils.isUsersPersonalRepository("fee", reponame)); assertFalse(ModelUtils.isUsersPersonalRepository("gnome", reponame)); reponame = "project/nsbl"; assertFalse(ModelUtils.isUsersPersonalRepository("fee", reponame)); }
@Test public void testIsPersonalRepository() { String reponame = Constants.DEFAULT_USER_REPOSITORY_PREFIX + "one"; assertTrue(ModelUtils.isPersonalRepository(reponame)); reponame = "none"; assertFalse(ModelUtils.isPersonalRepository(reponame)); ModelUtils.setUserRepoPrefix("@@"); reponame = "@@two"; assertTrue(ModelUtils.isPersonalRepository(reponame)); ModelUtils.setUserRepoPrefix("users/"); reponame = "users/three"; assertTrue(ModelUtils.isPersonalRepository(reponame)); reponame = "project/four"; assertFalse(ModelUtils.isPersonalRepository(reponame)); }
@Test public void testSetUserRepoPrefix() { assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix()); ModelUtils.setUserRepoPrefix("@"); assertEquals("@", ModelUtils.getUserRepoPrefix()); ModelUtils.setUserRepoPrefix(""); assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix()); ModelUtils.setUserRepoPrefix("user/"); assertEquals("user/", ModelUtils.getUserRepoPrefix()); ModelUtils.setUserRepoPrefix("u_"); assertEquals("u_", ModelUtils.getUserRepoPrefix()); ModelUtils.setUserRepoPrefix(null); assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix()); ModelUtils.setUserRepoPrefix("/somedir/otherdir/"); assertEquals("somedir/otherdir/", ModelUtils.getUserRepoPrefix()); }
@Test public void testGetUserRepoPrefix() { assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix()); }
@After public void resetPrefix() { ModelUtils.setUserRepoPrefix(null); }