@Test
public void testGetEmbeddedLibraries() {

    final File testOutDir = new File(testOutBaseDir, "testGetEmbeddedLibraries");
    final OpearPackageMojo mojo = newMojo();
    final MavenProject project = mock(MavenProject.class);
    mojo.project = project;
    final MavenSession session = mock(MavenSession.class);
    mojo.session = session;
    final MavenExecutionRequest executionRequest = mock(MavenExecutionRequest.class);
    when(session.getRequest()).thenReturn(executionRequest);
    final RepositorySystem repositorySystem = mock(RepositorySystem.class);
    mojo.repositorySystem = repositorySystem;
    final String expectVersion = "0.31415926535898";
    final Dependency oakpalCoreDep = new DependencyFilter()
            .withGroupId(OAKPAL_GROUP_ID)
            .withArtifactId(OAKPAL_CORE_ARTIFACT_ID)
            .withVersion(expectVersion)
            .toDependency();
    final File oakpalDepFile = new File(testOutDir, "oakpal-core.jar");
    final Artifact oakpalArt = mock(Artifact.class);
    when(oakpalArt.getGroupId()).thenReturn(OAKPAL_GROUP_ID);
    when(oakpalArt.getArtifactId()).thenReturn(OAKPAL_CORE_ARTIFACT_ID);
    when(oakpalArt.getScope()).thenReturn("compile");
    when(oakpalArt.getFile()).thenReturn(oakpalDepFile);
    final Dependency importDep = new DependencyFilter().toDependency("import");
    final File importDepFile = new File(testOutDir, "import-scope.jar");
    final Artifact importArt = mock(Artifact.class);
    when(importArt.getGroupId()).thenReturn(OAKPAL_GROUP_ID);
    when(importArt.getArtifactId()).thenReturn("import-scope");
    when(importArt.getScope()).thenReturn("import");
    when(importArt.getFile()).thenReturn(importDepFile);
    final Dependency providedDep = new DependencyFilter().toDependency("provided");
    final File providedDepFile = new File(testOutDir, "provided-scope.jar");
    final Artifact providedArt = mock(Artifact.class);
    when(providedArt.getGroupId()).thenReturn(OAKPAL_GROUP_ID);
    when(providedArt.getArtifactId()).thenReturn("provided-scope");
    when(providedArt.getScope()).thenReturn("provided");
    when(providedArt.getFile()).thenReturn(providedDepFile);
    final Dependency testDep = new DependencyFilter().toDependency("test");
    final File testDepFile = new File(testOutDir, "test-scope.jar");
    final Artifact testArt = mock(Artifact.class);
    when(testArt.getGroupId()).thenReturn(OAKPAL_GROUP_ID);
    when(testArt.getArtifactId()).thenReturn("test-scope");
    when(testArt.getScope()).thenReturn("test");
    when(testArt.getFile()).thenReturn(testDepFile);
    final Dependency compileDep = new DependencyFilter().toDependency("compile");
    final File compileDepFile = new File(testOutDir, "compile-scope.jar");
    final Artifact compileArt = mock(Artifact.class);
    when(compileArt.getGroupId()).thenReturn(OAKPAL_GROUP_ID);
    when(compileArt.getArtifactId()).thenReturn("compile-scope");
    when(compileArt.getScope()).thenReturn("compile");
    when(compileArt.getFile()).thenReturn(compileDepFile);
    final Dependency runtimeDep = new DependencyFilter().toDependency("runtime");
    final File runtimeDepFile = new File(testOutDir, "runtime-scope.jar");
    final Artifact runtimeArt = mock(Artifact.class);
    when(runtimeArt.getGroupId()).thenReturn(OAKPAL_GROUP_ID);
    when(runtimeArt.getArtifactId()).thenReturn("runtime-scope");
    when(runtimeArt.getScope()).thenReturn("runtime");
    when(runtimeArt.getFile()).thenReturn(runtimeDepFile);
    final List<Dependency> projectDependencies =
            Arrays.asList(oakpalCoreDep, importDep, providedDep, testDep, importDep,
                    compileDep, runtimeDep);
    when(project.getDependencies()).thenReturn(projectDependencies);
    doAnswer(call -> {
        final Dependency input = call.getArgument(0, Dependency.class);
        if (input == oakpalCoreDep) {
            return oakpalArt;
        } else if (input == importDep) {
            return importArt;
        } else if (input == providedDep) {
            return providedArt;
        } else if (input == testDep) {
            return testArt;
        } else if (input == compileDep) {
            return compileArt;
        } else if (input == runtimeDep) {
            return runtimeArt;
        } else {
            return null;
        }
    }).when(repositorySystem).createDependencyArtifact(any(Dependency.class));
    doAnswer(call -> {
        final ArtifactResolutionRequest request = call.getArgument(0, ArtifactResolutionRequest.class);
        final ArtifactResolutionResult result = mock(ArtifactResolutionResult.class);
        when(result.getArtifacts()).thenReturn(Collections.singleton(request.getArtifact()));
        return result;
    }).when(repositorySystem).resolve(any(ArtifactResolutionRequest.class));
    final List<File> actualLibraries = mojo.getEmbeddedLibraries();
    assertFalse("not empty: " + actualLibraries, actualLibraries.isEmpty());
    assertEquals("expect files", Arrays.asList(compileDepFile, runtimeDepFile), actualLibraries);
}