From acf96cf18a2255253e728b0f2a264ec2dfa61042 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 23 Feb 2015 12:13:52 +0100 Subject: [PATCH] Revert change on equals on Category since it is breaking UI --- .../java/org/sonar/api/config/Category.java | 2 +- .../org/sonar/api/config/SubCategoryTest.java | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/config/SubCategoryTest.java diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java index 690b2c99181..114abe3fd27 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java @@ -59,7 +59,7 @@ public class Category { @Override public boolean equals(Object obj) { - if (!(this.getClass() == obj.getClass())) { + if (!(obj instanceof Category)) { return false; } return StringUtils.equalsIgnoreCase(((Category) obj).originalKey, this.originalKey); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/SubCategoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/SubCategoryTest.java new file mode 100644 index 00000000000..a89c6164f71 --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/SubCategoryTest.java @@ -0,0 +1,34 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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.config; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SubCategoryTest { + + // see processProperties in application_controller.rb + @Test + public void defaultSubCategoryShouldEqualParentCategory() { + assertThat(new Category("general")).isEqualTo(new SubCategory("general")); + } + +} -- 2.39.5