All Downloads are FREE. Search and download functionalities are using the official Maven repository.

js.share.srctree.test-method-table.js Maven / Gradle / Ivy

There is a newer version: 0.10.1
Show newest version
/**
 * @class
 */
sahagin.TestMethodTable = function() {

  /**
   * @private
   * @type {Array.}
   */
  this.testMethods = new Array();
};

/**
 * @returns {Array.}
 */
sahagin.TestMethodTable.prototype.getTestMethods = function() {
  return this.testMethods;
};

/**
 * @param {sahagin.TestMethod} testMethod
 */
sahagin.TestMethodTable.prototype.addTestMethod = function(testMethod) {
  this.testMethods.push(testMethod);
};

/**
 * @returns {boolean}
 */
sahagin.TestMethodTable.prototype.isEmpty = function() {
  this.testMethods.length == 0;
};

/**
 * returns null if not found
 * @param {string} key
 * @returns {sahagin.TestMethod}
 */
sahagin.TestMethodTable.prototype.getByKey = function(key) {
  if (key == null || key == undefined) {
    throw new Error(key);
  }
  for (var i = 0; i < this.testMethods.length; i++) {
    var testMethod = this.testMethods[i];
    if (key == testMethod.getKey()) {
      return testMethod;
    }
  }
  return null;
};

/**
 * @param {string} classQualifiedName
 * @param {string} methodSimpleName
 * @returns {Array.}
 */
sahagin.TestMethodTable.prototype.getByName = function(
    classQualifiedName, methodSimpleName) {
  if (classQualifiedName == null || classQualifiedName == undefined) {
    throw new Error(classQualifiedName);
  }
  if (methodSimpleName == null || methodSimpleName == undefined) {
    throw new Error(methodSimpleName);
  }
  var result = new Array();
  for (var i = 0; i < this.testMethods.length; i++) {
    var testMethod = this.testMethods[i];
    if ((classQualifiedName == testMethod.getTestClass().getQualifiedName()) &&
        (methodSimpleName == testMethod.getSimpleName())) {
      result.push(testMethod);
    }
  }
  return result;
};

// TODO define sort method as well as Java implementation

/**
 * @returns {Object.}
 */
sahagin.TestMethodTable.prototype.toYamlObject = function() {
  var result = new Object();
  if (!this.isEmpty()) {
    result['methods'] = sahagin.YamlUtils.toYamlObjectList(this.testMethods);
  }
  return result;
};

/**
 * @param {Object.} yamlObject
 */
sahagin.TestMethodTable.prototype.fromYamlObject = function(yamlObject) {
  var testMethodsYamlObj = sahagin.YamlUtils.getYamlObjectListValue(yamlObject, 'methods', true);
  this.testMethods = new Array();
  for (var i = 0; i < testMethodsYamlObj.length; i++) {
    var testMethod = new sahagin.TestMethod();
    testMethod.fromYamlObject(testMethodsYamlObj[i]);
    this.testMethods.push(testMethod);
  }
};




© 2015 - 2024 Weber Informatics LLC | Privacy Policy