/**
   * Transforms the Vector of the Repository parameters into a Repository Object.<br>
   * Structure of the parameters:<br>
   * Vector[name, Vector[project parameters], type, content type, uri]
   *
   * @param xmlRpcParameters Vector[name, Vector[project parameters], type, content type, uri]
   * @return the Repository.
   */
  @SuppressWarnings("unchecked")
  public static Repository toRepository(Vector<Object> xmlRpcParameters) {
    Repository repository = null;
    if (!xmlRpcParameters.isEmpty()) {
      repository = Repository.newInstance((String) xmlRpcParameters.get(REPOSITORY_UID_IDX));
      repository.setName((String) xmlRpcParameters.get(REPOSITORY_NAME_IDX));
      repository.setProject(toProject((Vector) xmlRpcParameters.get(REPOSITORY_PROJECT_IDX)));
      repository.setType(toRepositoryType((Vector) xmlRpcParameters.get(REPOSITORY_TYPE_IDX)));
      repository.setContentType(
          ContentType.getInstance((String) xmlRpcParameters.get(REPOSITORY_CONTENTTYPE_IDX)));
      repository.setBaseUrl((String) xmlRpcParameters.get(REPOSITORY_BASE_URL_IDX));
      repository.setBaseRepositoryUrl((String) xmlRpcParameters.get(REPOSITORY_BASEREPO_URL_IDX));
      repository.setBaseTestUrl((String) xmlRpcParameters.get(REPOSITORY_BASETEST_URL_IDX));
      repository.setUsername(toNullIfEmpty((String) xmlRpcParameters.get(REPOSITORY_USERNAME_IDX)));
      repository.setPassword(toNullIfEmpty((String) xmlRpcParameters.get(REPOSITORY_PASSWORD_IDX)));
      repository.setMaxUsers((Integer) xmlRpcParameters.get(REPOSITORY_MAX_USERS_IDX));
    }

    return repository;
  }
Esempio n. 2
0
 public void testThatTheInstanciateReturnsTheGoodInstance() {
   assertEquals(ContentType.BOTH, ContentType.getInstance("BOTH"));
   assertEquals(ContentType.TEST, ContentType.getInstance("TEST"));
   assertEquals(ContentType.REQUIREMENT, ContentType.getInstance("REQUIREMENT"));
   assertEquals(ContentType.UNKNOWN, ContentType.getInstance("TYPE-NOT-SUPPORTED"));
 }