Package org.sonar.api.resources

Examples of org.sonar.api.resources.Project


  @Test
  public void shouldDoNothingIfNoVersion() {
    VersionEventsSensor sensor = new VersionEventsSensor();
    SensorContext context = mock(SensorContext.class);
    Project project = mock(Project.class);
    when(project.getAnalysisVersion()).thenReturn(null);

    sensor.analyse(project, context);

    verify(context, never()).createEvent(any(Resource.class), anyString(), anyString(), anyString(), any(Date.class));
    verify(context, never()).deleteEvent(any(Event.class));
View Full Code Here


  @Test
  public void shouldCreateVersionEvent() {
    VersionEventsSensor sensor = new VersionEventsSensor();
    SensorContext context = mock(SensorContext.class);

    Project project = mock(Project.class);
    when(project.getAnalysisVersion()).thenReturn("1.5-SNAPSHOT");

    sensor.analyse(project, context);

    verify(context).createEvent(eq(project), eq("1.5-SNAPSHOT"), (String) isNull(), eq(Event.CATEGORY_VERSION), (Date) isNull());
  }
View Full Code Here

    Event anotherEvent = mockVersionEvent("1.3-SNAPSHOT");

    VersionEventsSensor sensor = new VersionEventsSensor();
    SensorContext context = mock(SensorContext.class);

    Project project = mock(Project.class);
    when(project.getAnalysisVersion()).thenReturn("1.5-SNAPSHOT");

    when(context.getEvents(project)).thenReturn(Lists.newArrayList(sameVersionEvent, otherEvent, anotherEvent));

    sensor.analyse(project, context);
View Full Code Here

    sensorContext = mock(SensorContext.class);
    settings = new Settings();
    resourcePerspectives = mock(ResourcePerspectives.class);
    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
    BlockCache blockCache = mock(BlockCache.class);
    project = new Project("myProject");
    sonarIndex = mock(SonarIndex.class);
    adaptor = new SensorContextAdapter(sensorContext, metricFinder, project,
      resourcePerspectives, settings, fs, activeRules, componentDataCache, blockCache, mock(DuplicationCache.class), sonarIndex);
  }
View Full Code Here

      ruleFinder);
  }

  @Test
  public void should_execute_on_project() {
    Project project = mock(Project.class);
    assertThat(decorator.shouldExecuteOnProject(project)).isTrue();
  }
View Full Code Here

    assertThat(issue.isOnDisabledRule()).isTrue();
  }

  @Test
  public void should_register_issues_on_deleted_components() throws Exception {
    Project project = new Project("struts");
    DefaultIssue openIssue = new DefaultIssue();
    when(issueCache.byComponent("struts")).thenReturn(Arrays.asList(openIssue));
    IssueDto deadIssue = new IssueDto().setKee("ABCDE").setResolution(null).setStatus("OPEN").setRuleKey("squid", "AvoidCycle");
    when(initialOpenIssues.selectAllIssues()).thenReturn(Arrays.asList(deadIssue));
View Full Code Here

  @Before
  public void setUp() {
    mode = mock(AnalysisMode.class);

    project = new Project("my-project-key");
    when(projectTree.getRootProject()).thenReturn(project);

    projectLock = new ProjectLock(semaphores, projectTree, mode, i18n);
  }
View Full Code Here

    }
  }

  public static Project loadProjectFromPom(Class clazz, String path) {
    MavenProject pom = loadPom(clazz, path);
    Project project = new Project(pom.getGroupId() + ":" + pom.getArtifactId())
      .setPom(pom);
    // configuration.setProperty("sonar.java.source", MavenUtils.getJavaSourceVersion(pom));
    // configuration.setProperty("sonar.java.target", MavenUtils.getJavaVersion(pom));
    // configuration.setProperty(CoreProperties.ENCODING_PROPERTY, MavenUtils.getSourceEncoding(pom));

    project.setFileSystem(new MavenModuleFileSystem(pom));
    return project;
  }
View Full Code Here

    decorator = new ApplyProjectRolesDecorator(resourcePermissions);
  }

  @Test
  public void alwaysExecute() {
    assertThat(decorator.shouldExecuteOnProject(new Project("project"))).isTrue();
  }
View Full Code Here

    assertThat(decorator.shouldExecuteOnProject(new Project("project"))).isTrue();
  }

  @Test
  public void doNotGrantDefaultRolesWhenExistingPermissions() {
    Project project = new Project("project");
    project.setId(10);
    when(resourcePermissions.hasRoles(project)).thenReturn(true);

    decorator.decorate(project, null);

    verify(resourcePermissions, never()).grantDefaultRoles(project);
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.