@Test
public void testRequiredDependencyMissing() {

    PluginsAware pluginRegistry = mock(PluginsAware.class);
    doReturn(Optional.empty()).when(pluginRegistry).getPlugin(eq(MISSING_NAME));
    doReturn(getPluginIdentityMetadata(FIXED_VERSION_NAME))
            .when(pluginRegistry).getPlugin(eq(FIXED_VERSION_NAME));
    doReturn(getPluginIdentityMetadata(VERSION_RANGE_NAME))
            .when(pluginRegistry).getPlugin(eq(VERSION_RANGE_NAME));
    List<Dependency> missingDependencies = new ArrayList<>();
    try {
        new DefaultDependencyChecker().check(pluginRegistry, getPluginDependenciesMetadata(new Dependency[]{
                MISSING_DEPENDENCY, DEPENDENCY_WITH_FIXED_VERSION, DEPENDENCY_WITH_VERSION_RANGE
        }, new Dependency[0]));
    } catch (PluginException e) {
        assertTrue(e.getDependencyProblem().isPresent());
        assertTrue(e.getPluginMetadata().isPresent());
        missingDependencies.addAll(e.getDependencyProblem().get().getMissingDependencies());
    }
    assertThat(missingDependencies, hasSize(2));
    assertThat(missingDependencies, contains(MISSING_DEPENDENCY, DEPENDENCY_WITH_FIXED_VERSION));
}