public ProjectDto validateProjectKey(String projectKey) {
    try (DbSession dbSession = dbClient.openSession(false)) {
      return componentFinder.getProjectByKey(dbSession, projectKey);
    } catch (NotFoundException e) {
      // To hide information about the existence or not of the project.
      throw insufficientPrivilegesException();
    }
  }
@Test
  public void givenValidProjectKey_whenValidateProjectKey_thenReturnProjectDto() {
    // given
    String projectKey = "validProjectKey";
    DbSession dbSession = mockDbSession();
    ProjectDto projectDto = new ProjectDto();
    doReturn(projectDto).when(componentFinder).getProjectByKey(dbSession, projectKey);

    // when
    ProjectDto returnedProjectDto = underTest.validateProjectKey(projectKey);

    // then
    assertThat(projectDto).isEqualTo(returnedProjectDto);
  }