Skip to content

Commit

Permalink
add template for check test
Browse files Browse the repository at this point in the history
  • Loading branch information
kebetsi committed Nov 21, 2024
1 parent 2ce551f commit 84fde41
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tools/resources/ruletest.template_java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* SonarQube JavaScript Plugin
* Copyright (C) 2011-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program 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.
*
* This program 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.javascript.checks;

import static org.assertj.core.api.Assertions.assertThat;

import com.google.gson.Gson;
import org.junit.jupiter.api.Test;

// TODO: delete this file if the rule is not configurable
class ___JAVA_RULE_CLASS_NAME___Test {

@Test
void configurations() {
HardcodedCredentialsCheck check = new ___JAVA_RULE_CLASS_NAME___();
// default configuration
String defaultConfigAsString = new Gson().toJson(check.configurations());
assertThat(defaultConfigAsString).isEqualTo("[{\"foo\":\"42\"}]");

check.foo = "42";
String customConfigAsString = new Gson().toJson(check.configurations());
assertThat(customConfigAsString).isEqualTo("[{\"foo\":\"42\"}]");
}
}

0 comments on commit 84fde41

Please sign in to comment.