Package org.sonar.api.test

Examples of org.sonar.api.test.Testable


  @Override
  public void store(TestCaseCoverage testCaseCoverage) {
    File testRes = getTestResource(testCaseCoverage.testFile());
    File mainRes = getMainResource(testCaseCoverage.coveredFile());
    Testable testAbleFile = perspectives.as(MutableTestable.class, mainRes);
    if (testAbleFile != null) {
      MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, testRes);
      if (testPlan != null) {
        for (MutableTestCase mutableTestCase : testPlan.testCasesByName(testCaseCoverage.testName())) {
          mutableTestCase.setCoverageBlock(testAbleFile, testCaseCoverage.coveredLines());
View Full Code Here


  /**
   * Test cases is only return for unit tests
   */
  public Map<Integer, Integer> getTestCases(String fileKey, CoverageService.TYPE type) {
    if (TYPE.UT.equals(type)) {
      Testable testable = snapshotPerspectives.as(MutableTestable.class, fileKey);
      if (testable != null) {
        return testable.testCasesByLines();
      }
    }
    return Maps.newHashMap();
  }
View Full Code Here

  public void handle(Request request, Response response) {
    String fileKey = request.mandatoryParam(KEY);
    UserSession.get().checkComponentPermission(UserRole.CODEVIEWER, fileKey);
    int line = request.mandatoryParamAsInt(LINE);

    Testable testable = snapshotPerspectives.as(MutableTestable.class, fileKey);
    JsonWriter json = response.newJsonWriter().beginObject();
    if (testable != null) {
      Map<String, Integer> refByTestPlan = newHashMap();
      Map<String, Component> componentsByKey = newHashMap();
      writeTests(testable, line, refByTestPlan, componentsByKey, json);
View Full Code Here

      "  ]\n" +
      "}\n");
  }

  private MutableTestCase testCase(String fileKey, String fileLongName, int coveredLines) {
    Testable testable = mock(Testable.class);
    when(testable.component()).thenReturn(new ComponentDto().setKey(fileKey).setLongName(fileLongName));

    CoverageBlock block = mock(CoverageBlock.class);
    when(block.testable()).thenReturn(testable);
    when(block.lines()).thenReturn(Arrays.asList(new Integer[coveredLines]));
View Full Code Here

TOP

Related Classes of org.sonar.api.test.Testable

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.