@Test
public void excludesUnusedDeclaredDependencies() throws Exception {

    final ProjectDependencyAnalysis analysis =
        Mockito.mock(ProjectDependencyAnalysis.class);
    final Set<Artifact> unused = new HashSet<>();
    final ArtifactStub artifact = new ArtifactStub();
    artifact.setGroupId("othergroup");
    artifact.setArtifactId("otherartifact");
    artifact.setScope(DependenciesValidatorTest.SCOPE);
    artifact.setVersion("1.2.3");
    artifact.setType(DependenciesValidatorTest.TYPE);
    unused.add(artifact);
    Mockito.doReturn(unused).when(analysis).getUnusedDeclaredArtifacts();
    final ProjectDependencyAnalyzer analyzer = this.analyzer(analysis);
    final MavenEnvironment env = new MavenEnvironmentMocker().inPlexus(
        DependenciesValidatorTest.ROLE,
        DependenciesValidatorTest.HINT,
        analyzer
    ).mock();
    new DependenciesValidator().validate(
        new MavenEnvironment.Wrap(
            new Environment.Mock().withExcludes(
                Joiner.on(':').join(
                    artifact.getGroupId(), artifact.getArtifactId()
                )
            ), env
        )
    );
}