Examples of ResourceDto


Examples of org.sonar.core.resource.ResourceDto

  }

  @Test
  public void return_null_if_no_source_code_on_component() throws Exception {
    String componentKey = "org.sonar.sample:Sample";
    when(resourceDao.getResource(any(ResourceQuery.class), eq(session))).thenReturn(new ResourceDto().setKey(componentKey).setLanguage("java"));
    when(snapshotSourceDao.selectSnapshotSourceByComponentKey(componentKey, session)).thenReturn(null);

    assertThat(sourceDecorator.getSourceAsHtml(componentKey)).isNull();
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  public void get_source_as_html_with_from_and_to_params() throws Exception {
    String componentKey = "org.sonar.sample:Sample";
    String source = "line 1\nline 2\nline 3\n";
    String htmlSource = "<span>line 1</span>\n<span>line 2</span>\n<span>line 3</span>\n";

    when(resourceDao.getResource(any(ResourceQuery.class), eq(session))).thenReturn(new ResourceDto().setKey(componentKey).setLanguage("java"));
    when(snapshotSourceDao.selectSnapshotSourceByComponentKey(componentKey, session)).thenReturn(source);
    when(codeColorizers.toHtml(source, "java")).thenReturn(htmlSource);

    List<String> result = sourceDecorator.getSourceAsHtml(componentKey, 2, 3);
    assertThat(result).containsExactly("<span>line 2</span>", "<span>line 3</span>");
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  public void get_source_as_html_with_from_param() throws Exception {
    String componentKey = "org.sonar.sample:Sample";
    String source = "line 1\nline 2\nline 3\n";
    String htmlSource = "<span>line 1</span>\n<span>line 2</span>\n<span>line 3</span>\n";

    when(resourceDao.getResource(any(ResourceQuery.class), eq(session))).thenReturn(new ResourceDto().setKey(componentKey).setLanguage("java"));
    when(snapshotSourceDao.selectSnapshotSourceByComponentKey(componentKey, session)).thenReturn(source);
    when(codeColorizers.toHtml(source, "java")).thenReturn(htmlSource);

    List<String> result = sourceDecorator.getSourceAsHtml(componentKey, 2, null);
    assertThat(result).containsExactly("<span>line 2</span>", "<span>line 3</span>", "");
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  public void get_source_as_html_with_to_param() throws Exception {
    String componentKey = "org.sonar.sample:Sample";
    String source = "line 1\nline 2\nline 3\n";
    String htmlSource = "<span>line 1</span>\n<span>line 2</span>\n<span>line 3</span>\n";

    when(resourceDao.getResource(any(ResourceQuery.class), eq(session))).thenReturn(new ResourceDto().setKey(componentKey).setLanguage("java"));
    when(snapshotSourceDao.selectSnapshotSourceByComponentKey(componentKey, session)).thenReturn(source);
    when(codeColorizers.toHtml(source, "java")).thenReturn(htmlSource);

    List<String> result = sourceDecorator.getSourceAsHtml(componentKey, null, 3);
    assertThat(result).containsExactly("<span>line 1</span>", "<span>line 2</span>", "<span>line 3</span>");
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    AuthorizationDao authorizationDao = mock(AuthorizationDao.class);
    ResourceDao resourceDao = mock(ResourceDao.class);
    UserSession session = new SpyUserSession("marius", authorizationDao, resourceDao).setUserId(1);

    String componentKey = "com.foo:Bar:BarFile.xoo";
    when(resourceDao.getRootProjectByComponentKey(componentKey)).thenReturn(new ResourceDto().setKey(componentKey));
    when(authorizationDao.selectAuthorizedRootProjectsKeys(1, UserRole.USER)).thenReturn(newArrayList(componentKey));

    assertThat(session.hasComponentPermission(UserRole.USER, componentKey)).isTrue();
    assertThat(session.hasComponentPermission(UserRole.CODEVIEWER, componentKey)).isFalse();
    assertThat(session.hasComponentPermission(UserRole.ADMIN, componentKey)).isFalse();
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  public void check_component_permission_ok() throws Exception {
    AuthorizationDao authorizationDao = mock(AuthorizationDao.class);
    ResourceDao resourceDao = mock(ResourceDao.class);
    UserSession session = new SpyUserSession("marius", authorizationDao, resourceDao).setUserId(1);

    when(resourceDao.getRootProjectByComponentKey("com.foo:Bar:BarFile.xoo")).thenReturn(new ResourceDto().setKey("com.foo:Bar"));
    when(authorizationDao.selectAuthorizedRootProjectsKeys(1, UserRole.USER)).thenReturn(newArrayList("com.foo:Bar"));

    session.checkComponentPermission(UserRole.USER, "com.foo:Bar:BarFile.xoo");
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  public void check_component_permission_ko() throws Exception {
    AuthorizationDao authorizationDao = mock(AuthorizationDao.class);
    ResourceDao resourceDao = mock(ResourceDao.class);
    UserSession session = new SpyUserSession("marius", authorizationDao, resourceDao).setUserId(1);

    when(resourceDao.getRootProjectByComponentKey("com.foo:Bar:BarFile.xoo")).thenReturn(new ResourceDto().setKey("com.foo:Bar2"));
    when(authorizationDao.selectAuthorizedRootProjectsKeys(1, UserRole.USER)).thenReturn(newArrayList("com.foo:Bar"));

    session.checkComponentPermission(UserRole.USER, "com.foo:Bar:BarFile.xoo");
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

        return 0;
      }
      return Long.valueOf(dto.getValue());
    }
    // For modules look for root project last modification timestamp
    ResourceDto rootProject = resourceDao.getRootProjectByComponentId(projectId);
    if (rootProject == null) {
      throw new SonarException("Unable to find root project for project with [id=" + projectId + "]");
    }
    PropertyDto dto = propertiesDao.selectProjectProperty(rootProject.getId(), SONAR_PREVIEW_CACHE_LAST_UPDATE_KEY);
    if (dto == null) {
      return 0;
    }
    return Long.valueOf(dto.getValue());
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    actionPlanService = new ActionPlanService(dbClient, actionPlanDao, actionPlanStatsDao, resourceDao, issueUpdater, issueStorage);
  }

  @Test
  public void create() {
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l));
    ActionPlan actionPlan = DefaultActionPlan.create("Long term");

    actionPlanService.create(actionPlan, projectAdministratorUserSession);
    verify(actionPlanDao).save(any(ActionPlanDto.class));
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    verify(actionPlanDao).save(any(ActionPlanDto.class));
  }

  @Test
  public void create_required_admin_role() {
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l));
    ActionPlan actionPlan = DefaultActionPlan.create("Long term");

    try {
      actionPlanService.create(actionPlan, unauthorizedUserSession);
      Fail.fail();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.