class SonarConnection implements MetricCapability, TestCapability {

    @Override
    public SoftwareProjectId identify(ProjectKey projectKey) throws ProjectNotFoundException {
        checkConnected();
        Preconditions.checkNotNull(projectKey, "projectKey is mandatory");
        try {
            String mavenId = projectKey.getMavenId();
            if (mavenId != null) {
                Resource resource = sonarClient.findResource(mavenId);
                SoftwareProjectId softwareProjectId = new SoftwareProjectId(resource.getKey());
                return softwareProjectId;
            }
        } catch (SonarResourceNotFoundException e) {
            throw new ProjectNotFoundException("Can't identify project key: " + projectKey, e);
        }
        throw new ProjectNotFoundException("Can't identify project key, there is not enough informations: "
                + projectKey);
    }

    public  SonarConnection();

}