Examples of ResourceDto


Examples of org.sonar.core.resource.ResourceDto

  public void reportGlobalModification(SqlSession session) {
    propertiesDao.setProperty(new PropertyDto().setKey(SONAR_PREVIEW_CACHE_LAST_UPDATE_KEY).setValue(String.valueOf(System.currentTimeMillis())), session);
  }

  public void reportResourceModification(String resourceKey) {
    ResourceDto rootProject = resourceDao.getRootProjectByComponentKey(resourceKey);
    if (rootProject == null) {
      throw new SonarException("Unable to find root project for component with [key=" + resourceKey + "]");
    }
    propertiesDao.setProperty(new PropertyDto().setKey(SONAR_PREVIEW_CACHE_LAST_UPDATE_KEY).setResourceId(rootProject.getId())
      .setValue(String.valueOf(System.currentTimeMillis())));
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  }

  @Test
  public void set_status() {
    when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey));
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l));

    ActionPlan result = actionPlanService.setStatus("ABCD", "CLOSED", projectAdministratorUserSession);
    verify(actionPlanDao).update(any(ActionPlanDto.class));

    assertThat(result).isNotNull();
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    assertThat(result.status()).isEqualTo("CLOSED");
  }

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

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

Examples of org.sonar.core.resource.ResourceDto

  }

  @Test
  public void delete() {
    when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey));
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l));
    actionPlanService.delete("ABCD", projectAdministratorUserSession);
    verify(actionPlanDao).delete("ABCD");
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  }

  @Test
  public void unplan_all_linked_issues_when_deleting_an_action_plan() {
    when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey));
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l));

    IssueDto issueDto = new IssueDto().setId(100L).setStatus(Issue.STATUS_OPEN).setRuleKey("squid", "s100");
    when(issueDao.findByActionPlan(session, "ABCD")).thenReturn(newArrayList(issueDto));
    when(issueUpdater.plan(any(DefaultIssue.class), eq((ActionPlan) null), any(IssueChangeContext.class))).thenReturn(true);
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

  }

  @Test
  public void find_by_key() {
    when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey));
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l));

    ActionPlan result = actionPlanService.findByKey("ABCD", projectUserSession);
    assertThat(result).isNotNull();
    assertThat(result.key()).isEqualTo("ABCD");
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    assertThat(results.iterator().next().key()).isEqualTo("ABCD");
  }

  @Test
  public void find_open_by_project_key() {
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l));
    when(actionPlanDao.findOpenByProjectId(1l)).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD")));
    Collection<ActionPlan> results = actionPlanService.findOpenByProjectKey(projectKey, projectUserSession);
    assertThat(results).hasSize(1);
    assertThat(results.iterator().next().key()).isEqualTo("ABCD");
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    assertThat(results.iterator().next().key()).isEqualTo("ABCD");
  }

  @Test
  public void find_open_by_project_key_required_user_role() {
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l));
    when(actionPlanDao.findOpenByProjectId(1l)).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD")));

    try {
      actionPlanService.findOpenByProjectKey(projectKey, unauthorizedUserSession);
      Fail.fail();
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

    actionPlanService.findOpenByProjectKey("<Unkown>", projectUserSession);
  }

  @Test
  public void find_action_plan_stats() {
    when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setId(1L).setKey(projectKey));
    when(actionPlanStatsDao.findByProjectId(1L)).thenReturn(newArrayList(new ActionPlanStatsDto()));

    Collection<ActionPlanStats> results = actionPlanService.findActionPlanStats(projectKey, projectUserSession);
    assertThat(results).hasSize(1);
  }
View Full Code Here

Examples of org.sonar.core.resource.ResourceDto

        File dbFile = new File(new File(dryRunCacheLocation, "123"), (String) args[2] + ".h2.db");
        FileUtils.write(dbFile, "fake db content");
        return dbFile;
      }
    });
    when(resourceDao.getRootProjectByComponentId(123L)).thenReturn(new ResourceDto().setId(123L));
    byte[] dbContent = dryRunCache.getDatabaseForPreview(123L);
    assertThat(new String(dbContent)).isEqualTo("fake db content");

    dbContent = dryRunCache.getDatabaseForPreview(123L);
    assertThat(new String(dbContent)).isEqualTo("fake db content");
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.