Examples of SensorContext


Examples of org.sonar.api.batch.SensorContext

  @Test
  public void violationContainsTheLineFromTheReport() throws XMLStreamException {
    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("test");
    givenAProject().containingSourceDirectory("dummy");
    final SensorContext context = mock(SensorContext.class);

    final List<Violation> parseResults = new ArrayList<Violation>();
    final StaxParser parser = new StaxParser(new OCLintXMLStreamHandler(parseResults, project(), context));

    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(VIOLATION_LINE, parseResults.get(0).getLineId());
  }
View Full Code Here

Examples of org.sonar.api.batch.SensorContext

  @Test
  public void violationRuleSeverityContainsThePriorityFromTheReport() throws XMLStreamException {
    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("test");
    givenAProject().containingSourceDirectory("dummy");
    final SensorContext context = mock(SensorContext.class);

    final List<Violation> parseResults = new ArrayList<Violation>();
    final StaxParser parser = new StaxParser(new OCLintXMLStreamHandler(parseResults, project(), context));

    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(RulePriority.MAJOR, parseResults.get(0).getRule().getSeverity());
  }
View Full Code Here

Examples of org.sonar.api.batch.SensorContext

  @Test
  public void violationRuleKeyContainsThePriorityFromTheReport() throws XMLStreamException {
    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("test");
    givenAProject().containingSourceDirectory("dummy");
    final SensorContext context = mock(SensorContext.class);

    final List<Violation> parseResults = new ArrayList<Violation>();
    final StaxParser parser = new StaxParser(new OCLintXMLStreamHandler(parseResults, project(), context));

    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(RULE_KEY, parseResults.get(0).getRule().getKey());
  }
View Full Code Here

Examples of org.sonar.api.batch.sensor.SensorContext

  public void testRule() {
    DefaultFileSystem fs = new DefaultFileSystem();
    DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY).setLines(10);
    fs.add(inputFile);

    SensorContext context = mock(SensorContext.class);
    final SensorStorage sensorStorage = mock(SensorStorage.class);
    when(context.settings()).thenReturn(new Settings());
    when(context.fileSystem()).thenReturn(fs);
    when(context.newIssue()).thenAnswer(new Answer<Issue>() {
      @Override
      public Issue answer(InvocationOnMock invocation) throws Throwable {
        return new DefaultIssue(sensorStorage);
      }
    });
View Full Code Here

Examples of org.sonar.api.batch.sensor.SensorContext

  public void testForceSeverity() {
    DefaultFileSystem fs = new DefaultFileSystem();
    DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY).setLines(10);
    fs.add(inputFile);

    SensorContext context = mock(SensorContext.class);
    final SensorStorage sensorStorage = mock(SensorStorage.class);
    Settings settings = new Settings();
    settings.setProperty(OneIssuePerLineSensor.FORCE_SEVERITY_PROPERTY, "MINOR");
    when(context.settings()).thenReturn(settings);
    when(context.fileSystem()).thenReturn(fs);
    when(context.newIssue()).thenAnswer(new Answer<Issue>() {
      @Override
      public Issue answer(InvocationOnMock invocation) throws Throwable {
        return new DefaultIssue(sensorStorage);
      }
    });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.