@Test
public void testCopy() {

  String moduleName = "lib";
  IdeaDependencyScope scope = createMock(IdeaDependencyScope.class);
  // Setup GradleProject to construct module id.
  GradleProject gradleProject = mock(GradleProject.class);
  ProjectIdentifier projectIdentifier = mock(ProjectIdentifier.class);
  BuildIdentifier buildIdentifier = mock(BuildIdentifier.class);
  when(buildIdentifier.getRootDir()).thenReturn(new File(Jimfs.newFileSystem().getPath("mock", "project").toString()));
  when(projectIdentifier.getBuildIdentifier()).thenReturn(buildIdentifier);
  when(gradleProject.getProjectIdentifier()).thenReturn(projectIdentifier);
  when(gradleProject.getPath()).thenReturn(":lib");
  expect(myIdeaModule.getName()).andStubReturn(moduleName);
  expect(myIdeaModule.getGradleProject()).andStubReturn(gradleProject);
  expect(myOriginalDependency.getScope()).andStubReturn(scope);
  expect(myOriginalDependency.getTargetModuleName()).andReturn(moduleName);
  expect(myOriginalDependency.getExported()).andStubReturn(true);
  expect(scope.getScope()).andStubReturn("compile");
  DomainObjectSet listOfModules = ImmutableDomainObjectSet.of(ImmutableList.of(myIdeaModule));
  expect(myIdeaProject.getModules()).andReturn(listOfModules);
  replay(myOriginalDependency, myIdeaModule, myIdeaProject, scope);
  JavaModuleDependency copy = JavaModuleDependency.copy(myIdeaProject, myOriginalDependency);
  assertNotNull(copy);
  assertEquals(moduleName, copy.getModuleName());
  assertSame("compile", copy.getScope());
  assertEquals("mock" + File.separator + "project::lib", copy.getModuleId());
  assertTrue(copy.isExported());
  verify(myOriginalDependency, myIdeaModule, scope);
}