Codota Logo
ExceptionCauseMatcher.hasType
Code IndexAdd Codota to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: SonarSource/sonarqube

@Test
public void input_stream_should_be_closed() throws Exception {
 logInAsSystemAdministrator();
 InputStream inputStream = newInputStream(plugin.toPath());
 call(inputStream, PLUGIN_NAME);
 // As the same InputStream is used, it will fail as it should have been called during the first execution of the WS
 expectedException.expectCause(hasType(ClosedChannelException.class));
 call(inputStream, PLUGIN_NAME);
}
origin: SonarSource/sonarqube

 @Test
 public void writeToJvmOptionFile_throws_ISE_in_case_of_IOException() throws IOException {
  File notAFile = temporaryFolder.newFolder();
  EsJvmOptions underTest = new EsJvmOptions();

  expectedException.expect(IllegalStateException.class);
  expectedException.expectMessage("Cannot write Elasticsearch jvm options file");
  expectedException.expectCause(ExceptionCauseMatcher.hasType(IOException.class));

  underTest.writeToJvmOptionFile(notAFile);
 }
}
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 rethrow_error_as_ISE_when_error_writing_message() {
 TestRequest request = new TestRequest();
 request.setMediaType(MediaTypes.PROTOBUF);
 Permissions.Permission message = Permissions.Permission.newBuilder().setName("permission-name").build();
 expectedException.expect(IllegalStateException.class);
 expectedException.expectCause(hasType(NullPointerException.class));
 expectedException.expectMessage("Error while writing protobuf message");
 // provoke NullPointerException
 WsUtils.writeProtobuf(message, null, new DumbResponse());
}
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);
}
origin: SonarSource/sonarqube

@Test
public void fail_to_insert_same_row_twice() {
 underTest.insert(db.getSession(), new QProfileEditUsersDto()
  .setUuid("UUID-1")
  .setUserId(100)
  .setQProfileUuid("QPROFILE")
 );
 expectedException.expectCause(hasType(SQLException.class));
 underTest.insert(db.getSession(), new QProfileEditUsersDto()
  .setUuid("UUID-2")
  .setUserId(100)
  .setQProfileUuid("QPROFILE")
 );
}
org.sonar.testExceptionCauseMatcherhasType

Popular methods of ExceptionCauseMatcher

  • andMessage
  • <init>

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • Collectors (java.util.stream)
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JFrame (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now