Tabnine Logo
ExceptionCauseMatcher.andMessage
Code IndexAdd Tabnine to your IDE (free)

How to use
andMessage
method
in
org.sonar.test.ExceptionCauseMatcher

Best Java code snippets using org.sonar.test.ExceptionCauseMatcher.andMessage (Showing top 8 results out of 315)

origin: SonarSource/sonarqube

@Test
public void fail_if_invalid_remediation_function() {
 expectedException.expect(IllegalStateException.class);
 expectedException.expectMessage("Fail to load the rule with key [squid:1]");
 expectedException.expectCause(hasType(IllegalArgumentException.class)
  .andMessage("No enum constant org.sonar.api.server.debt.DebtRemediationFunction.Type.UNKNOWN"));
 load("" +
  "<rules>" +
  "  <rule>" +
  "    <key>1</key>" +
  "    <name>One</name>" +
  "    <description>Desc</description>" +
  "    <remediationFunction>UNKNOWN</remediationFunction>" +
  "  </rule>" +
  "</rules>");
}
origin: SonarSource/sonarqube

@Test
public void retrieveSystemInfo_throws_ISE_if_http_error() {
 server.enqueue(new MockResponse().setResponseCode(500));
 // initialize registration of process
 setUpWithHttpUrl(ProcessId.COMPUTE_ENGINE);
 expectedException.expect(IllegalStateException.class);
 expectedException.expectMessage("Failed to call HTTP server of process " + ProcessId.COMPUTE_ENGINE);
 expectedException.expectCause(hasType(IOException.class)
  .andMessage(format("Server returned HTTP response code: 500 for URL: http://%s:%d/systemInfo", server.getHostName(), server.getPort())));
 underTest.retrieveSystemInfo();
}
origin: SonarSource/sonarqube

@Test
public void fail_if_unsupported_description_format() {
 String xml = "" +
  "<rules>" +
  "  <rule>" +
  "    <key>1</key>" +
  "    <name>One</name>" +
  "    <description>Desc</description>" +
  "    <descriptionFormat>UNKNOWN</descriptionFormat>" +
  "  </rule>" +
  "</rules>";
 expectedException.expect(IllegalStateException.class);
 expectedException.expectMessage("Fail to load the rule with key [squid:1]");
 expectedException.expectCause(hasType(IllegalArgumentException.class)
  .andMessage("No enum constant org.sonar.api.server.rule.RulesDefinitionXmlLoader.DescriptionFormat.UNKNOWN"));
 load(xml).rule("1");
}
origin: SonarSource/sonarqube

@Test
public void changeLogLevel_throws_ISE_if_http_error() {
 String message = "blah";
 server.enqueue(new MockResponse().setResponseCode(500).setBody(message));
 // initialize registration of process
 setUpWithHttpUrl(ProcessId.COMPUTE_ENGINE);
 expectedException.expect(IllegalStateException.class);
 expectedException.expectMessage("Failed to call HTTP server of process " + ProcessId.COMPUTE_ENGINE);
 expectedException.expectCause(hasType(IOException.class)
  .andMessage(format("Failed to change log level in Compute Engine. Code was '500' and response was 'blah' for url " +
   "'http://%s:%s/changeLogLevel'", server.getHostName(), server.getPort())));
 underTest.changeLogLevel(LoggerLevel.DEBUG);
}
origin: SonarSource/sonarqube

@Test
public void loads_duplication_with_otherFileRef_throws_IAE_if_references_itself() {
 int line = 2;
 reportReader.putDuplications(FILE_1_REF, createDuplication(singleLineTextRange(line), createInProjectDuplicate(FILE_1_REF, line + 1)));
 expectedException.expect(VisitException.class);
 expectedException.expectCause(hasType(IllegalArgumentException.class).andMessage("file and otherFile references can not be the same"));
 underTest.execute(new TestComputationStepContext());
}
origin: SonarSource/sonarqube

@Test
public void loads_duplication_with_otherFileRef_throws_IAE_if_component_does_not_exist() {
 int line = 2;
 reportReader.putDuplications(FILE_1_REF, createDuplication(singleLineTextRange(line), createInProjectDuplicate(666, line + 1)));
 expectedException.expect(VisitException.class);
 expectedException.expectCause(hasType(IllegalArgumentException.class).andMessage("Component with ref '666' can't be found"));
 underTest.execute(new TestComputationStepContext());
}
origin: SonarSource/sonarqube

@Test
public void fail_on_project_without_children_already_having_computed_measure() {
 ReportComponent root = builder(PROJECT, ROOT_REF).build();
 treeRootHolder.setRoot(root);
 measureRepository.addRawMeasure(ROOT_REF, NCLOC_KEY, newMeasureBuilder().create(10));
 expectedException.expectCause(hasType(UnsupportedOperationException.class)
  .andMessage(String.format("A measure can only be set once for Component (ref=%s), Metric (key=%s)", ROOT_REF, NCLOC_KEY)));
 new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula()))
  .visit(root);
}
origin: SonarSource/sonarqube

@Test
public void fail_when_trying_to_compute_file_measure_already_existing_in_report() {
 ReportComponent root = builder(PROJECT, ROOT_REF)
  .addChildren(
   builder(Component.Type.FILE, FILE_1_REF).build())
  .build();
 treeRootHolder.setRoot(root);
 measureRepository.addRawMeasure(FILE_1_REF, NCLOC_KEY, newMeasureBuilder().create(2));
 expectedException.expectCause(hasType(UnsupportedOperationException.class)
  .andMessage(String.format("A measure can only be set once for Component (ref=%s), Metric (key=%s)", FILE_1_REF, NCLOC_KEY)));
 new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula()))
  .visit(root);
}
org.sonar.testExceptionCauseMatcherandMessage

Popular methods of ExceptionCauseMatcher

  • hasType
  • <init>

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • putExtra (Intent)
  • getApplicationContext (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now