Package org.sonar.api.component

Examples of org.sonar.api.component.Component


  @Test
  public void should_return_null_on_null_component() throws Exception {

    String componentKey = "org.foo.Bar";

    Component component = mock(Component.class);
    when(component.key()).thenReturn(componentKey);

    ScanGraph graph = mock(ScanGraph.class);
    when(graph.getComponent(componentKey)).thenReturn(null);

    GraphPerspectiveLoader perspectiveLoader = mock(GraphPerspectiveLoader.class);
View Full Code Here


public class ComponentVertexTest {
  @Test
  public void should_copy() {
    BeanGraph beanGraph = new BeanGraph(new TinkerGraph());
    ComponentVertex vertex = beanGraph.createVertex(ComponentVertex.class);
    Component file = MockSourceFile.createMain("myproject:org/Foo.java").setName("Foo.java").setQualifier(Qualifiers.FILE)
      .setPath("src/org/Foo.java");

    vertex.copyFrom(file);

    assertThat(vertex.key()).isEqualTo("myproject:org/Foo.java");
View Full Code Here

      if (!action.supports(issue)) {
        throw new IllegalStateException("A condition is not respected");
      }

      IssueChangeContext changeContext = IssueChangeContext.createUser(new Date(), userSession.login());
      Component project = dbClient.componentDao().getByKey(session, issue.projectKey());
      FunctionContext functionContext = new FunctionContext(issue, updater, changeContext, getProjectSettings(project));
      for (Function function : action.functions()) {
        function.execute(functionContext);
      }
      issueStorage.save(issue);
View Full Code Here

      json.beginObject();
      json.prop("name", testCase.name());
      json.prop("status", testCase.status().name());
      json.prop("durationInMs", testCase.durationInMs());

      Component testPlan = testCase.testPlan().component();
      Integer ref = refByTestPlan.get(testPlan.key());
      if (ref == null) {
        ref = refByTestPlan.size() + 1;
        refByTestPlan.put(testPlan.key(), ref);
        componentsByKey.put(testPlan.key(), testPlan);
      }
      json.prop("_ref", Integer.toString(ref));
      json.endObject();
    }
    json.endArray();
View Full Code Here

  private void writeFiles(Map<String, Integer> refByTestPlan, Map<String, Component> componentsByKey, JsonWriter json) {
    json.name("files").beginObject();
    for (Map.Entry<String, Integer> entry : refByTestPlan.entrySet()) {
      String componentKey = entry.getKey();
      Integer ref = entry.getValue();
      Component file = componentsByKey.get(componentKey);
      json.name(Integer.toString(ref)).beginObject();
      json.prop("key", file.key());
      json.prop("longName", file.longName());
      json.endObject();
    }
    json.endObject();
  }
View Full Code Here

  private void writeTests(TestPlan<MutableTestCase> testPlan, String test, JsonWriter json) {
    json.name("files").beginArray();
    for (TestCase testCase : testPlan.testCasesByName(test)) {
      for (CoverageBlock coverageBlock : testCase.coverageBlocks()) {
        json.beginObject();
        Component file = coverageBlock.testable().component();
        json.prop("key", file.key());
        json.prop("longName", file.longName());
        json.prop("coveredLines", coverageBlock.lines().size());
        json.endObject();
      }
    }
    json.endArray();
View Full Code Here

    ComponentQuery query = ComponentQuery.builder().build();
    DefaultComponentQueryResult results = finder.find(query, components);

    assertThat(results.components()).hasSize(3);
    Component component = results.components().iterator().next();
    assertThat(component.name()).isEqualTo("Apache Tika");
    assertThat(component.key()).isEqualTo("org.apache.tika:tika");
    assertThat(component.qualifier()).isEqualTo("TRK");
  }
View Full Code Here

    assertThat(actionService.listAvailableActions("ABCD")).isEmpty();
  }

  @Test
  public void get_project_settings(){
    Component project = mock(Component.class);
    when(project.key()).thenReturn("struts");

    // Global property
    settings.appendProperty("sonar.core.version", "3.6");

    // Project property
View Full Code Here

    assertThat(highlightablePerspective.getHighlightingRules().getSyntaxHighlightingRuleSet()).hasSize(2);
  }

  @Test
  public void should_apply_registered_highlighting() throws Exception {
    Component component = mock(Component.class);
    when(component.key()).thenReturn("myComponent");

    ComponentDataCache cache = mock(ComponentDataCache.class);

    DefaultHighlightable highlightable = new DefaultHighlightable(component, cache);
    highlightable.newHighlighting()
View Full Code Here

  ComponentDataCache dataCache = mock(ComponentDataCache.class);

  @Test
  public void should_load_perspective() throws Exception {
    Component component = mock(Component.class);

    SymbolizableBuilder perspectiveBuilder = new SymbolizableBuilder(dataCache);
    Perspective perspective = perspectiveBuilder.loadPerspective(Symbolizable.class, component);

    assertThat(perspective).isInstanceOf(Symbolizable.class);
View Full Code Here

TOP

Related Classes of org.sonar.api.component.Component

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.