Package org.sonar.api.resources

Examples of org.sonar.api.resources.Project


  public void setUp() {
    fileLinesContextFactory = mock(FileLinesContextFactory.class);
    FileLinesContext fileLinesContext = mock(FileLinesContext.class);
    when(fileLinesContextFactory.createFor(any(Resource.class))).thenReturn(fileLinesContext);

    project = new Project("key");
    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
    when(pfs.getSourceDirs()).thenReturn(Arrays.asList(new File("src/test/resources/cpd/")));

    project.setFileSystem(pfs);
  }
View Full Code Here


  }

  @Test
  public void should_execute_if_js_files() {
    ModuleFileSystem fs = mock(ModuleFileSystem.class);
    project = new Project("key");

    JavaScriptSquidSensor sensor = new JavaScriptSquidSensor(mock(RulesProfile.class), fileLinesContextFactory, mock(ResourcePerspectives.class), fs, new NoSonarFilter());

    // no JS files -> do not execute
    when(fs.files(any(FileQuery.class))).thenReturn(Collections.<File>emptyList());
View Full Code Here

  public void test_toString() {
    assertThat(sensor.toString()).isEqualTo("JsTestSensor");
  }

  private Project mockProject(final String language) {
    return new Project("mock") {
      @Override
      public String getLanguageKey() {
        return language;
      }
    };
View Full Code Here

    File baseDir = TestUtils.getResource("org/sonar/plugins/javascript/unittest/jstestdriver/sensortests");
    when(fileSystem.baseDir()).thenReturn(baseDir);
    when(fileSystem.testDirs()).thenReturn(Arrays.asList(new File(baseDir, "test")));

    Project project = mockProject("js");

    sensor.analyse(project, context);

    verify(context).saveMeasure((Resource) anyObject(), eq(CoreMetrics.TESTS), eq(2.0));
    verify(context).saveMeasure((Resource) anyObject(), eq(CoreMetrics.SKIPPED_TESTS), eq(0.0));
View Full Code Here

  public void test_toString() {
    assertThat(sensor.toString()).isEqualTo("JsTestDriverSensor");
  }

  private Project mockProject(final String language) {
    return new Project("mock") {
      @Override
      public String getLanguageKey() {
        return language;
      }
    };
View Full Code Here

  }

  @Test
  public void should_send_new_issues() throws Exception {
    Date date = DateUtils.parseDateTime("2013-05-18T13:00:03+0200");
    Project project = new Project("struts").setAnalysisDate(date);
    IssuesBySeverity issuesBySeverity = mock(IssuesBySeverity.class);
    when(issuesBySeverity.size()).thenReturn(42);
    when(issuesBySeverity.issues("MINOR")).thenReturn(10);
    Notification notification = issueNotifications.sendNewIssues(project, issuesBySeverity);
View Full Code Here

      .setFieldChange(context, "assignee", "simon", null)
      .setSendNotifications(true)
      .setComponentKey("struts:Action")
      .setProjectKey("struts");

    Notification notification = issueNotifications.sendChanges(issue, context, null, new Project("struts"), null).get(0);

    assertThat(notification.getFieldValue("message")).isEqualTo("the message");
    assertThat(notification.getFieldValue("key")).isEqualTo("ABCDE");
    assertThat(notification.getFieldValue("componentKey")).isEqualTo("struts:Action");
    assertThat(notification.getFieldValue("componentName")).isNull();
View Full Code Here

      .setMessage("the message")
      .setKey("ABCDE")
      .setAssignee("freddy")
      .setComponentKey("struts:Action")
      .setProjectKey("struts");
    Notification notification = issueNotifications.sendChanges(issue, context, null, new Project("struts"), null, "I don't know how to fix it?").get(0);

    assertThat(notification.getFieldValue("message")).isEqualTo("the message");
    assertThat(notification.getFieldValue("key")).isEqualTo("ABCDE");
    assertThat(notification.getFieldValue("comment")).isEqualTo("I don't know how to fix it?");
    Mockito.verify(manager).scheduleForSending(eq(Arrays.asList(notification)));
View Full Code Here

      .setAssignee("freddy")
      .setFieldChange(context, "resolution", null, "FIXED")
      .setSendNotifications(true)
      .setComponentKey("struts:Action.java")
      .setProjectKey("struts");
    Notification notification = issueNotifications.sendChanges(issue, context, null, new Project("struts"),
      new ResourceComponent(File.create("Action.java", "Action.java", null, false).setEffectiveKey("struts:Action.java"))).get(0);

    assertThat(notification.getFieldValue("message")).isEqualTo("the message");
    assertThat(notification.getFieldValue("key")).isEqualTo("ABCDE");
    assertThat(notification.getFieldValue("componentKey")).isEqualTo("struts:Action.java");
View Full Code Here

    DefaultIssue issue = new DefaultIssue()
      .setMessage("the message")
      .setKey("ABCDE")
      .setComponentKey("struts:Action")
      .setProjectKey("struts");
    List<Notification> notifications = issueNotifications.sendChanges(issue, context, null, new Project("struts"), null);

    assertThat(notifications).isEmpty();
    Mockito.verifyZeroInteractions(manager);
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.resources.Project

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.