aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-02 12:29:58 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-02 14:44:37 +0100
commit211f8bbf72b8c4d50b0493db8b995f922b1d470d (patch)
tree0b3d701569ca6cc23c80e16ff06f96e5bfde792b /sonar-plugin-api
parent11ce39d38a3cba818285a6e373db2cdb3a76a05d (diff)
downloadsonarqube-211f8bbf72b8c4d50b0493db8b995f922b1d470d.tar.gz
sonarqube-211f8bbf72b8c4d50b0493db8b995f922b1d470d.zip
SONAR-4891 Remove useless characteristics columns and tables
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java369
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/CharacteristicProperty.java110
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java227
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelDefinition.java70
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelFinder.java35
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicPropertyTest.java55
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicTest.java80
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/ModelTest.java85
8 files changed, 0 insertions, 1031 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java
deleted file mode 100644
index 474b7509e34..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import com.google.common.collect.Lists;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.hibernate.annotations.Sort;
-import org.hibernate.annotations.SortType;
-import org.sonar.api.rules.Rule;
-
-import javax.persistence.*;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @since 2.3
- */
-@Entity
-@Table(name = "characteristics")
-public final class Characteristic implements Comparable<Characteristic> {
-
- public static final int ROOT_DEPTH = 1;
-
- @Id
- @Column(name = "id")
- @GeneratedValue
- private Integer id;
-
- @Column(name = "kee", nullable = true, length = 100)
- private String key;
-
- @Column(name = "name", nullable = true, length = 100)
- private String name;
-
- @Column(name = "depth")
- private int depth = ROOT_DEPTH;
-
- @Column(name = "characteristic_order")
- private int order = 0;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "quality_model_id")
- private Model model;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "rule_id")
- private Rule rule;
-
- @Column(name = "description", nullable = true, length = 4000)
- private String description;
-
- @Column(name = "enabled", updatable = true, nullable = true)
- private Boolean enabled = Boolean.TRUE;
-
- @ManyToMany
- @JoinTable(
- name = "characteristic_edges",
- joinColumns = @JoinColumn(name = "child_id", referencedColumnName = "id"),
- inverseJoinColumns = @JoinColumn(name = "parent_id",
- referencedColumnName = "id")
- )
- private List<Characteristic> parents = Lists.newArrayList();
-
- @Sort(type = SortType.NATURAL)
- @ManyToMany(mappedBy = "parents", cascade = CascadeType.ALL)
- private List<Characteristic> children = Lists.newArrayList();
-
- @OneToMany(mappedBy = "characteristic", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
- private List<CharacteristicProperty> properties = Lists.newArrayList();
-
- Characteristic() {
- }
-
- public Integer getId() {
- return id;
- }
-
- Characteristic setId(Integer id) {
- this.id = id;
- return this;
- }
-
- public String getKey() {
- return key;
- }
-
- public Characteristic setKey(String s) {
- this.key = StringUtils.trimToNull(s);
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public Characteristic setName(String s) {
- return setName(s, false);
- }
-
- public Characteristic setName(String s, boolean asKey) {
- this.name = StringUtils.trimToNull(s);
- if (asKey) {
- this.key = StringUtils.upperCase(this.name);
- this.key = StringUtils.replaceChars(this.key, ' ', '_');
- }
- return this;
- }
-
- public Model getModel() {
- return model;
- }
-
- Characteristic setModel(Model model) {
- this.model = model;
- return this;
- }
-
- public Rule getRule() {
- return rule;
- }
-
- public boolean hasRule() {
- return rule != null;
- }
-
- public Characteristic setRule(Rule r) {
- this.rule = r;
- return this;
- }
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- public Characteristic setEnabled(Boolean b) {
- this.enabled = b;
- return this;
- }
-
- public Characteristic addChildren(Characteristic... list) {
- if (list != null) {
- for (Characteristic c : list) {
- addChild(c);
- }
- }
- return this;
- }
-
- public Characteristic addChild(Characteristic child) {
- propagateDepth(child, depth + 1);
- child.addParents(this);
- child.setModel(model);
- children.add(child);
- return this;
- }
-
- public Characteristic removeChild(Characteristic child) {
- children.remove(child);
- return this;
- }
-
- private static void propagateDepth(Characteristic characteristic, int depth) {
- characteristic.setDepth(depth);
- for (Characteristic child : characteristic.getChildren()) {
- propagateDepth(child, depth + 1);
- }
- }
-
- Characteristic addParents(Characteristic... pc) {
- if (pc != null) {
- Collections.addAll(this.parents, pc);
- }
- return this;
- }
-
- public List<Characteristic> getParents() {
- return parents;
- }
-
- public Characteristic getParent(String name) {
- for (Characteristic parent : parents) {
- if (StringUtils.equals(parent.getName(), name)) {
- return parent;
- }
- }
- return null;
- }
-
- /**
- * Enabled children sorted by insertion order
- */
- public List<Characteristic> getChildren() {
- return getChildren(true);
- }
-
- /**
- * Enabled children sorted by insertion order
- */
- public List<Characteristic> getChildren(boolean onlyEnabled) {
- if (!onlyEnabled) {
- return children;
- }
- List<Characteristic> result = Lists.newArrayList();
- for (Characteristic child : children) {
- if (child.getEnabled()) {
- result.add(child);
- }
- }
- return result;
- }
-
- public Characteristic getChild(String name) {
- for (Characteristic child : children) {
- if (StringUtils.equals(child.getName(), name)) {
- return child;
- }
- }
- return null;
- }
-
- public int getDepth() {
- return depth;
- }
-
- public boolean isRoot() {
- return depth == ROOT_DEPTH;
- }
-
- Characteristic setDepth(int i) {
- this.depth = i;
- return this;
- }
-
- public int getOrder() {
- return order;
- }
-
- public Characteristic setOrder(int i) {
- this.order = i;
- return this;
- }
-
- public String getDescription() {
- return description;
- }
-
- public Characteristic setDescription(String s) {
- this.description = s;
- return this;
- }
-
- public CharacteristicProperty setProperty(String key, String value) {
- return addProperty(CharacteristicProperty.create(key).setTextValue(value));
- }
-
- public CharacteristicProperty setProperty(String key, Double value) {
- return addProperty(CharacteristicProperty.create(key).setValue(value));
- }
-
- public CharacteristicProperty addProperty(CharacteristicProperty property) {
- property.setCharacteristic(this);
- properties.add(property);
- return property;
- }
-
- public CharacteristicProperty getProperty(String key) {
- for (CharacteristicProperty property : properties) {
- if (StringUtils.equals(key, property.getKey())) {
- return property;
- }
- }
- return null;
- }
-
- public String getPropertyTextValue(String key, String defaultValue) {
- CharacteristicProperty property = getProperty(key);
- String value = property != null ? property.getTextValue() : null;
- return StringUtils.defaultIfEmpty(value, defaultValue);
- }
-
- public Double getPropertyValue(String key, Double defaultValue) {
- CharacteristicProperty property = getProperty(key);
- Double value = property != null ? property.getValue() : null;
- return value == null ? defaultValue : value;
- }
-
- public List<CharacteristicProperty> getProperties() {
- return properties;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Characteristic that = (Characteristic) o;
- if (key != null ? !key.equals(that.key) : that.key != null) {
- return false;
- }
- if (rule != null ? !rule.equals(that.rule) : that.rule != null) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = key != null ? key.hashCode() : 0;
- result = 31 * result + (rule != null ? rule.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("key", key)
- .append("name", name)
- .append("rule", rule)
- .append("description", description)
- .toString();
- }
-
- public int compareTo(Characteristic o) {
- if (equals(o)) {
- return 0;
- }
- return order - o.order;
- }
-
- public static Characteristic create() {
- return new Characteristic();
- }
-
- public static Characteristic createByName(String name) {
- return new Characteristic().setName(name, true);
- }
-
- public static Characteristic createByKey(String key, String name) {
- return new Characteristic().setKey(key).setName(name, false);
- }
-
- public static Characteristic createByRule(Rule rule) {
- return new Characteristic().setRule(rule);
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/CharacteristicProperty.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/CharacteristicProperty.java
deleted file mode 100644
index cd2c3dc2613..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/CharacteristicProperty.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import javax.persistence.*;
-
-/**
- * @since 2.3
- */
-@Entity
-@Table(name = "characteristic_properties")
-public final class CharacteristicProperty {
-
- @Id
- @Column(name = "id")
- @GeneratedValue
- private Integer id;
-
- @Column(name = "kee", nullable = true, length = 100)
- private String key;
-
- @Column(name = "value", nullable = true)
- private Double value;
-
- @Column(name = "text_value", nullable = true, length = 4000)
- private String textValue;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "characteristic_id", updatable = true, nullable = false)
- private Characteristic characteristic;
-
- /**
- * Use the factory method create()
- */
- CharacteristicProperty() {
- }
-
- public static CharacteristicProperty create(String key) {
- return new CharacteristicProperty().setKey(key);
- }
-
- public Integer getId() {
- return id;
- }
-
- CharacteristicProperty setId(Integer i) {
- this.id = i;
- return this;
- }
-
- public String getKey() {
- return key;
- }
-
- public CharacteristicProperty setKey(String s) {
- this.key = s;
- return this;
- }
-
- public String getTextValue() {
- return textValue;
- }
-
- public Double getValue() {
- return value;
- }
-
- public Long getValueAsLong() {
- if (value!=null) {
- return value.longValue();
- }
- return null;
- }
-
- public CharacteristicProperty setTextValue(String s) {
- this.textValue = s;
- return this;
- }
-
- public CharacteristicProperty setValue(Double d) {
- this.value = d;
- return this;
- }
-
- Characteristic getCharacteristic() {
- return characteristic;
- }
-
- CharacteristicProperty setCharacteristic(Characteristic c) {
- this.characteristic = c;
- return this;
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java
deleted file mode 100644
index 131fa2a41e1..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import com.google.common.collect.Lists;
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.rules.Rule;
-
-import javax.persistence.*;
-import java.util.List;
-
-/**
- * @since 2.3
- */
-@Entity
-@Table(name = "quality_models")
-public final class Model implements Comparable<Model> {
-
- @Id
- @Column(name = "id")
- @GeneratedValue
- private Integer id;
-
- @Column(name = "name", nullable = false, unique = true, length = 100)
- private String name;
-
- @OneToMany(mappedBy = "model", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
- private List<Characteristic> characteristics = Lists.newArrayList();
-
- /**
- * Use the factory method <code>Model</code>
- */
- Model() {
- }
-
- public static Model create() {
- return new Model();
- }
-
- public static Model createByName(String s) {
- return new Model().setName(s);
- }
-
- public Characteristic createCharacteristicByName(String name) {
- Characteristic c = new Characteristic().setName(name, true);
- return addCharacteristic(c);
- }
-
- public Characteristic createCharacteristicByKey(String key, String name) {
- Characteristic c = new Characteristic().setKey(key).setName(name, false);
- return addCharacteristic(c);
- }
-
- public Characteristic createCharacteristicByRule(Rule rule) {
- Characteristic c = new Characteristic().setRule(rule);
- return addCharacteristic(c);
- }
-
- public Integer getId() {
- return id;
- }
-
- Model setId(Integer id) {
- this.id = id;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public List<Characteristic> getRootCharacteristics() {
- return getCharacteristicsByDepth(Characteristic.ROOT_DEPTH);
- }
-
- public Model setName(String name) {
- this.name = StringUtils.trim(name);
- return this;
- }
-
- public Characteristic addCharacteristic(Characteristic c) {
- c.setModel(this);
- c.setOrder(characteristics.size() + 1);
- characteristics.add(c);
- return c;
- }
-
- /**
- * @return enabled characteristics
- */
- public List<Characteristic> getCharacteristics() {
- return getCharacteristics(true);
- }
-
- public List<Characteristic> getCharacteristics(boolean onlyEnabled) {
- if (!onlyEnabled) {
- return characteristics;
- }
- List<Characteristic> result = Lists.newArrayList();
- for (Characteristic characteristic : characteristics) {
- if (characteristic.getEnabled()) {
- result.add(characteristic);
- }
- }
- return result;
- }
-
- /**
- * Search for an ENABLED characteristic by its key.
- */
- public Characteristic getCharacteristicByKey(String key) {
- for (Characteristic characteristic : characteristics) {
- if (characteristic.getEnabled() && StringUtils.equals(key, characteristic.getKey())) {
- return characteristic;
- }
- }
- return null;
- }
-
- /**
- * Search for an ENABLED characteristic with the specified rule.
- */
- public Characteristic getCharacteristicByRule(Rule rule) {
- if (rule != null) {
- for (Characteristic characteristic : characteristics) {
- if (characteristic.getEnabled() && ObjectUtils.equals(rule, characteristic.getRule())) {
- return characteristic;
- }
- }
- }
- return null;
- }
-
- /**
- * Search for ENABLED characteristics by their depth.
- */
- public List<Characteristic> getCharacteristicsByDepth(int depth) {
- List<Characteristic> result = Lists.newArrayList();
- for (Characteristic c : characteristics) {
- if (c.getEnabled() && c.getDepth() == depth) {
- result.add(c);
- }
- }
- return result;
- }
-
- /**
- * Search for an ENABLED characteristic by its name.
- */
- public Characteristic getCharacteristicByName(String name) {
- for (Characteristic characteristic : characteristics) {
- if (characteristic.getEnabled() && StringUtils.equals(name, characteristic.getName())) {
- return characteristic;
- }
- }
- return null;
- }
-
- public Model removeCharacteristic(Characteristic characteristic) {
- if (characteristic.getId() == null) {
- characteristics.remove(characteristic);
- for (Characteristic parent : characteristic.getParents()) {
- parent.removeChild(characteristic);
- }
- } else {
- characteristic.setEnabled(false);
- }
- for (Characteristic child : characteristic.getChildren()) {
- removeCharacteristic(child);
- }
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Model model = (Model) o;
- if (name != null ? !name.equals(model.name) : model.name != null) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return name != null ? name.hashCode() : 0;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("id", id)
- .append("name", name)
- .toString();
- }
-
- public int compareTo(Model o) {
- return getName().compareTo(o.getName());
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelDefinition.java
deleted file mode 100644
index fc60a319668..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelDefinition.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.ServerExtension;
-
-/**
- *
- * @since 2.3
- * @deprecated since 4.0. It no more possible to define new quality models.
- */
-@Deprecated
-public abstract class ModelDefinition implements ServerExtension {
-
- private String name;
-
- protected ModelDefinition(String name) {
- this.name = name;
- }
-
- public final String getName() {
- return name;
- }
-
- public abstract Model createModel();
-
- @Override
- public final boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- ModelDefinition that = (ModelDefinition) o;
- return name.equals(that.name);
- }
-
- @Override
- public final int hashCode() {
- return name.hashCode();
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("name", name)
- .toString();
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelFinder.java
deleted file mode 100644
index 669e5b51646..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelFinder.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.sonar.api.BatchComponent;
-import org.sonar.api.ServerComponent;
-
-/**
- * @since 2.3
- */
-public interface ModelFinder extends BatchComponent, ServerComponent {
-
- /**
- * @return null if the name is not found
- */
- Model findByName(String name);
-
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicPropertyTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicPropertyTest.java
deleted file mode 100644
index 0ce05e3133c..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicPropertyTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-public class CharacteristicPropertyTest {
-
- @Test
- public void testNullValues() {
- CharacteristicProperty property = CharacteristicProperty.create("foo");
- assertThat(property.getTextValue(), nullValue());
- assertThat(property.getValue(), nullValue());
- assertThat(property.getValueAsLong(), nullValue());
- }
-
- @Test
- public void testNumericValue() {
- CharacteristicProperty property = CharacteristicProperty.create("foo");
- property.setValue(3.14);
- assertThat(property.getValue(), is(3.14));//stored in the value column
- assertThat(property.getValueAsLong(), is(3L));
- assertThat(property.getTextValue(), nullValue());
- }
-
- @Test
- public void testTextValue() {
- CharacteristicProperty property = CharacteristicProperty.create("foo");
- property.setTextValue("bar");
- assertThat(property.getTextValue(), is("bar"));
- assertThat(property.getValue(), nullValue());
- assertThat(property.getValueAsLong(), nullValue());
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicTest.java
deleted file mode 100644
index d9051ffd13f..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.junit.Test;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class CharacteristicTest {
-
- @Test
- public void testStringProperties() {
- Characteristic characteristic = Characteristic.create();
- characteristic.setProperty("foo", "bar");
-
- assertThat(characteristic.getProperty("foo")).isNotNull();
- assertThat(characteristic.getPropertyTextValue("foo", null)).isEqualTo("bar");
- assertThat(characteristic.getPropertyValue("foo", null)).isNull();
-
- assertThat(characteristic.getProperty("unknown")).isNull();
- assertThat(characteristic.getPropertyTextValue("unknown", null)).isNull();
- }
-
- @Test
- public void testDoubleProperties() {
- Characteristic characteristic = Characteristic.create();
- characteristic.setProperty("foo", 3.1);
-
- assertThat(characteristic.getProperty("foo")).isNotNull();
- assertThat(characteristic.getPropertyValue("foo", null)).isEqualTo(3.1);
- assertThat(characteristic.getPropertyTextValue("foo", null)).isNull();
- }
-
- @Test
- public void addProperty() {
- Characteristic characteristic = Characteristic.create();
- characteristic.addProperty(CharacteristicProperty.create("foo"));
-
- CharacteristicProperty property = characteristic.getProperty("foo");
- assertThat(property).isNotNull();
- assertThat(property.getCharacteristic()).isSameAs(characteristic);
- }
-
- @Test
- public void shouldCreateByName() {
- Characteristic characteristic = Characteristic.createByName("Foo");
-
- assertThat(characteristic.getKey()).isEqualTo("FOO");
- assertThat(characteristic.getName()).isEqualTo("Foo");
- }
-
- @Test
- public void shouldReturnDefaultValues() {
- Characteristic characteristic = Characteristic.create();
- characteristic.setProperty("foo", (String) null);
- characteristic.setProperty("bar", (Double) null);
-
- assertThat(characteristic.getPropertyTextValue("foo", "foodef")).isEqualTo("foodef");
- assertThat(characteristic.getPropertyTextValue("other", "otherdef")).isEqualTo("otherdef");
- assertThat(characteristic.getPropertyValue("bar", 3.14)).isEqualTo(3.14);
- assertThat(characteristic.getPropertyValue("other", 3.14)).isEqualTo(3.14);
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/ModelTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/ModelTest.java
deleted file mode 100644
index ff33f7c8b41..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/ModelTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.junit.Test;
-import org.sonar.api.rules.Rule;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-public class ModelTest {
- @Test
- public void searchEnabledCharacteristics() {
- Model model = Model.create();
- model.createCharacteristicByKey("foo", "enabled foo");
- model.createCharacteristicByKey("foo", "disabled foo").setEnabled(false);
-
- assertThat(model.getCharacteristicByKey("foo").getName(), is("enabled foo"));
- assertThat(model.getCharacteristicByKey("foo").getEnabled(), is(true));
-
- assertThat(model.getCharacteristicByName("enabled foo").getName(), is("enabled foo"));
- assertThat(model.getCharacteristicByName("disabled foo"), nullValue());
-
- assertThat(model.getCharacteristics().size(), is(1));
- assertThat(model.getCharacteristics(false).size(), is(2));
- }
-
- @Test
- public void shouldFindCharacteristicByRule() {
- Model model = Model.create();
- Rule rule1 = Rule.create("checkstyle", "regexp", "Regular expression");
- Rule rule2 = Rule.create("checkstyle", "import", "Check imports");
-
- Characteristic efficiency = model.createCharacteristicByName("Efficiency");
- Characteristic requirement1 = model.createCharacteristicByRule(rule1);
- Characteristic requirement2 = model.createCharacteristicByRule(rule2);
- efficiency.addChild(requirement1);
- efficiency.addChild(requirement2);
-
- assertThat(model.getCharacteristicByRule(rule1), is(requirement1));
- assertThat(model.getCharacteristicByRule(rule2), is(requirement2));
- assertThat(model.getCharacteristicByRule(null), nullValue());
- assertThat(model.getCharacteristicByRule(Rule.create("foo", "bar", "Bar")), nullValue());
- }
-
- @Test
- public void shouldRemoveCharacteristic() {
- Model model = Model.create();
- Characteristic efficiency = model.createCharacteristicByName("Efficiency");
- model.createCharacteristicByName("Usability");
- assertThat(model.getCharacteristics().size(), is(2));
-
- model.removeCharacteristic(efficiency);
- assertThat(model.getCharacteristics().size(), is(1));
- assertThat(model.getCharacteristicByName("Efficiency"), nullValue());
- assertThat(model.getCharacteristicByName("Usability"), notNullValue());
- }
-
- @Test
- public void shouldNotFailWhenRemovingUnknownCharacteristic() {
- Model model = Model.create();
- model.createCharacteristicByName("Efficiency");
- model.removeCharacteristic(Characteristic.createByKey("foo", "Foo"));
- assertThat(model.getCharacteristics().size(), is(1));
- }
-}