@Test
  public void testRemoveDependencyTwiceWhenItExistsOnce() {
    // Set up
    when(mockFileManager.getInputStream(POM_PATH))
        .thenReturn(new ByteArrayInputStream(POM_BEFORE_DEPENDENCY_REMOVED.getBytes()));

    // -- Dependency to remove
    final Dependency mockDependency = mock(Dependency.class);
    when(mockDependency.getArtifactId()).thenReturn(ARTIFACT_ID);
    when(mockDependency.getClassifier()).thenReturn(CLASSIFIER);
    when(mockDependency.getGroupId()).thenReturn(GROUP_ID);
    when(mockDependency.getSimpleDescription()).thenReturn(SIMPLE_DESCRIPTION);
    when(mockDependency.getType()).thenReturn(DependencyType.JAR);
    when(mockDependency.getVersion()).thenReturn(VERSION);
    when(mockMetadataService.get(ProjectMetadata.getProjectIdentifier("")))
        .thenReturn(mockProjectMetadata);

    final Pom pom = mock(Pom.class);
    when(pom.getPath()).thenReturn(POM_PATH);
    when(mockProjectMetadata.getPom()).thenReturn(pom);

    final Collection<Dependency> dependencies = Arrays.asList(mockDependency, mockDependency);
    when(pom.isAnyDependenciesRegistered(dependencies)).thenReturn(true);
    when(pom.isDependencyRegistered(mockDependency)).thenReturn(true);

    // Invoke
    projectOperations.removeDependencies("", dependencies);

    // Check
    final String expectedPom = POM_AFTER_DEPENDENCY_REMOVED.replace("\n", LINE_SEPARATOR);
    verify(mockFileManager)
        .createOrUpdateTextFileIfRequired(eq(POM_PATH), eq(expectedPom), (String) any(), eq(false));
  }
  @Test
  public void testGetFocusedModuleWhenChildModuleHasFocus() {
    // Set up
    when(mockPomManagementService.getFocusedModuleName()).thenReturn("child");
    final Pom mockChildPom = mock(Pom.class);
    final ProjectMetadata mockChildMetadata = mock(ProjectMetadata.class);
    when(mockChildMetadata.getPom()).thenReturn(mockChildPom);
    when(mockMetadataService.get(ProjectMetadata.getProjectIdentifier("child")))
        .thenReturn(mockChildMetadata);

    // Invoke and check
    assertEquals(mockChildPom, projectOperations.getFocusedModule());
  }
  @Test
  public void testGetFocusedModuleWhenNoModulesExist() {
    // Set up
    when(mockPomManagementService.getFocusedModuleName()).thenReturn("");
    when(mockMetadataService.get(ProjectMetadata.getProjectIdentifier(""))).thenReturn(null);

    // Invoke and check
    assertNull(projectOperations.getFocusedModule());
  }