Exemple #1
0
  @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));
  }
Exemple #2
0
  @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));
  }
Exemple #3
0
  @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));
  }
Exemple #4
0
  @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));
  }
Exemple #5
0
  @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());
  }
Exemple #6
0
 @Test
 public void testGetUserRepoPrefix() {
   assertEquals(Constants.DEFAULT_USER_REPOSITORY_PREFIX, ModelUtils.getUserRepoPrefix());
 }
Exemple #7
0
 @After
 public void resetPrefix() {
   ModelUtils.setUserRepoPrefix(null);
 }