Package org.sonar.api.utils

Examples of org.sonar.api.utils.StaxParser


  }

  @Test
  public void streamRecordsHitsForLinesWithNoBranch() throws XMLStreamException {
    final Map<String, CoverageMeasuresBuilder> parseResults = new HashMap<String, CoverageMeasuresBuilder>();
    final StaxParser parser = new StaxParser(new CoberturaXMLStreamHandler(parseResults));

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(Integer.valueOf(1), parseResults.get(FILE_PATH).getHitsByLine().get(NO_BRANCH_LINE));
  }
View Full Code Here


  }

  @Test
  public void streamRecordsHitsForLinesWithBranch() throws XMLStreamException {
    final Map<String, CoverageMeasuresBuilder> parseResults = new HashMap<String, CoverageMeasuresBuilder>();
    final StaxParser parser = new StaxParser(new CoberturaXMLStreamHandler(parseResults));

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(Integer.valueOf(10), parseResults.get(FILE_PATH).getHitsByLine().get(BRANCH_LINE));
  }
View Full Code Here

  }

  @Test
  public void streamRecordsConditionsForLinesWithBranch() throws XMLStreamException {
    final Map<String, CoverageMeasuresBuilder> parseResults = new HashMap<String, CoverageMeasuresBuilder>();
    final StaxParser parser = new StaxParser(new CoberturaXMLStreamHandler(parseResults));

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(Integer.valueOf(2), parseResults.get(FILE_PATH).getConditionsByLine().get(BRANCH_LINE));
  }
View Full Code Here

  }

  @Test
  public void streamRecordsConditionsHitsForLinesWithBranch() throws XMLStreamException {
    final Map<String, CoverageMeasuresBuilder> parseResults = new HashMap<String, CoverageMeasuresBuilder>();
    final StaxParser parser = new StaxParser(new CoberturaXMLStreamHandler(parseResults));

    parser.parse(new StringInputStream(VALID_REPORT));

    assertEquals(Integer.valueOf(1), parseResults.get(FILE_PATH).getCoveredConditionsByLine().get(BRANCH_LINE));
  }
View Full Code Here

  private ProjectBuilder projectBuilder;

  @Test
  public void streamLeavesTheCollectionEmptyWhenNoLinesAreFound() throws XMLStreamException {
    final Collection<Violation> parseResults = new ArrayList<Violation>();
    final StaxParser parser = new StaxParser(new OCLintXMLStreamHandler(parseResults, null, null));

    parser.parse(new StringInputStream(EMPTY_REPORT));

    assertTrue(parseResults.isEmpty());
  }
View Full Code Here

    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("test");
    givenAProject().containingSourceDirectory("dummy");
    final SensorContext context = mock(SensorContext.class);

    final Collection<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));

    assertFalse(parseResults.isEmpty());
  }
View Full Code Here

    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(dummyFile, parseResults.get(0).getResource());
  }
View Full Code Here

    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(DESCRIPTION, parseResults.get(0).getMessage());
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.utils.StaxParser

Copyright © 2018 www.massapicom. 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.