Support updates of imports

To be able to write tests with imports we need a test API to write code
owner configs with imports. This follows the example of the API that
allows to update code owner sets.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I38d97a7d79ec3559ce52fca86b863ce2b853b7f0
diff --git a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImpl.java b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImpl.java
index cd91dda..fba2512 100644
--- a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImpl.java
+++ b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImpl.java
@@ -17,6 +17,7 @@
 import static com.google.common.base.Preconditions.checkState;
 
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfig;
+import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigImportModification;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigUpdate;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerSetModification;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwners;
@@ -74,6 +75,8 @@
                 .setIgnoreParentCodeOwners(codeOwnerConfigCreation.ignoreParentCodeOwners())
                 .setCodeOwnerSetsModification(
                     CodeOwnerSetModification.set(codeOwnerConfigCreation.computeCodeOwnerSets()))
+                .setImportsModification(
+                    CodeOwnerConfigImportModification.set(codeOwnerConfigCreation.imports()))
                 .build())
         .orElseThrow(
             () ->
@@ -129,6 +132,7 @@
                   .setIgnoreParentCodeOwners(codeOwnerConfigUpdate.ignoreParentCodeOwners())
                   .setCodeOwnerSetsModification(
                       codeOwnerConfigUpdate.codeOwnerSetsModification()::apply)
+                  .setImportsModification(codeOwnerConfigUpdate.importsModification()::apply)
                   .build());
     }
   }
diff --git a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigCreation.java b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigCreation.java
index 557f477..c5ee2cd 100644
--- a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigCreation.java
+++ b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigCreation.java
@@ -23,6 +23,7 @@
 import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.Project;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfig;
+import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigReference;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerReference;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerSet;
 import java.nio.file.Path;
@@ -90,6 +91,13 @@
   abstract ImmutableList<CodeOwnerSet> codeOwnerSets();
 
   /**
+   * Gets the imports that have been set for the new code owner config.
+   *
+   * @return the imports that have been set for the new code owner config
+   */
+  abstract ImmutableList<CodeOwnerConfigReference> imports();
+
+  /**
    * Gets the code owner sets that should be set in the newly created code owner config.
    *
    * <p>Includes the global code owners that are defined by {@link #globalCodeOwners()}.
@@ -132,7 +140,7 @@
 
   /** Returns whether the code owner config would be empty. */
   public boolean isEmpty() {
-    return !ignoreParentCodeOwners() && computeCodeOwnerSets().isEmpty();
+    return !ignoreParentCodeOwners() && computeCodeOwnerSets().isEmpty() && imports().isEmpty();
   }
 
   /**
@@ -269,6 +277,24 @@
     }
 
     /**
+     * Gets a builder to add imports.
+     *
+     * @return builder to add imports
+     */
+    abstract ImmutableList.Builder<CodeOwnerConfigReference> importsBuilder();
+
+    /**
+     * Adds an import.
+     *
+     * @param codeOwnerConfigReference reference to the code owner config that should be imported
+     * @return the Builder instance for chaining calls
+     */
+    public Builder addImport(CodeOwnerConfigReference codeOwnerConfigReference) {
+      importsBuilder().add(requireNonNull(codeOwnerConfigReference, "codeOwnerConfigReference"));
+      return this;
+    }
+
+    /**
      * Sets the function that creates the code owner config.
      *
      * @param codeOwnerConfigCreator the function that creates the code owner config
diff --git a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigUpdate.java b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigUpdate.java
index be15ea9..49e0004 100644
--- a/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigUpdate.java
+++ b/java/com/google/gerrit/plugins/codeowners/acceptance/testsuite/TestCodeOwnerConfigUpdate.java
@@ -17,6 +17,8 @@
 import com.google.auto.value.AutoValue;
 import com.google.common.collect.ImmutableList;
 import com.google.gerrit.acceptance.testsuite.ThrowingConsumer;
+import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigImportModification;
+import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigReference;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerSet;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerSetModification;
 import java.util.Optional;
@@ -47,6 +49,16 @@
   public abstract CodeOwnerSetModification codeOwnerSetsModification();
 
   /**
+   * Defines how the imports of the code owner config should be modified. By default (that is if
+   * nothing is specified), the imports remain unchanged.
+   *
+   * @return a function that modifies the imports of the code owner config, the input to the
+   *     function are the current imports of the code owner config, the output of the function are
+   *     the desired imports
+   */
+  public abstract CodeOwnerConfigImportModification importsModification();
+
+  /**
    * Gets the function that updates the code owner config.
    *
    * @return the function that updates the code owner config
@@ -63,7 +75,8 @@
       ThrowingConsumer<TestCodeOwnerConfigUpdate> codeOwnerConfigUpdater) {
     return new AutoValue_TestCodeOwnerConfigUpdate.Builder()
         .codeOwnerConfigUpdater(codeOwnerConfigUpdater)
-        .codeOwnerSetsModification(CodeOwnerSetModification.keep());
+        .codeOwnerSetsModification(CodeOwnerSetModification.keep())
+        .importsModification(CodeOwnerConfigImportModification.keep());
   }
 
   /** Builder for a {@link TestCodeOwnerConfigUpdate}. */
@@ -115,6 +128,48 @@
     }
 
     /**
+     * Adds an import.
+     *
+     * @param codeOwnerConfigReference reference to the code owner config that should be imported
+     * @return the Builder instance for chaining calls
+     */
+    public Builder addImport(CodeOwnerConfigReference codeOwnerConfigReference) {
+      CodeOwnerConfigImportModification previousModification = importsModification();
+      importsModification(
+          originalImports ->
+              new ImmutableList.Builder<CodeOwnerConfigReference>()
+                  .addAll(previousModification.apply(originalImports))
+                  .add(codeOwnerConfigReference)
+                  .build());
+      return this;
+    }
+
+    /**
+     * Sets the import modification.
+     *
+     * @return the Builder instance for chaining calls
+     * @see TestCodeOwnerConfigUpdate#importsModification()
+     */
+    public abstract Builder importsModification(
+        CodeOwnerConfigImportModification importsModification);
+
+    /**
+     * Gets the import modification.
+     *
+     * @see TestCodeOwnerConfigUpdate#importsModification()
+     */
+    abstract CodeOwnerConfigImportModification importsModification();
+
+    /**
+     * Removes all imports.
+     *
+     * @return the Builder instance for chaining calls
+     */
+    public Builder clearImports() {
+      return importsModification(CodeOwnerConfigImportModification.clear());
+    }
+
+    /**
      * Adds a code owner set.
      *
      * @param codeOwnerSet code owner set that should be added
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java
index 57fcb6b..647f1e0 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java
@@ -81,6 +81,23 @@
   }
 
   /**
+   * Gets the imports of this code owner config as list.
+   *
+   * <p>For some callers it's better to retrieve the imports as list since lists have a defined
+   * order, e.g. for:
+   *
+   * <ul>
+   *   <li>updating imports where the updater must be aware that the order matters
+   *   <li>doing test assertions where the order should be verified
+   * </ul>
+   *
+   * @return the imports of this code owner config as list
+   */
+  public ImmutableList<CodeOwnerConfigReference> importsAsList() {
+    return imports().asList();
+  }
+
+  /**
    * Relativizes the given path in relation to the folder path of this code owner config.
    *
    * @param path the path that should be relativized
@@ -140,6 +157,24 @@
      */
     public abstract Builder setIgnoreParentCodeOwners(boolean ignoreParentCodeOwners);
 
+    /**
+     * Sets the imports of this code owner config.
+     *
+     * @param imports the imports of this code owner config
+     * @return the Builder instance for chaining calls
+     */
+    public Builder setImports(ImmutableList<CodeOwnerConfigReference> imports) {
+      return setImports(ImmutableSet.copyOf(imports));
+    }
+
+    /**
+     * Sets the imports of this code owner config.
+     *
+     * @param imports the imports of this code owner config
+     * @return the Builder instance for chaining calls
+     */
+    abstract Builder setImports(ImmutableSet<CodeOwnerConfigReference> imports);
+
     /** Gets a builder to add references to code owner configs that should be imported. */
     abstract ImmutableSet.Builder<CodeOwnerConfigReference> importsBuilder();
 
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFile.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFile.java
index 9d9ca55..79a4b68 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFile.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFile.java
@@ -249,6 +249,8 @@
         codeOwnerConfigUpdate
             .codeOwnerSetsModification()
             .apply(codeOwnerConfig.codeOwnerSetsAsList()));
+    codeOwnerConfigBuilder.setImports(
+        codeOwnerConfigUpdate.importsModification().apply(codeOwnerConfig.importsAsList()));
     return codeOwnerConfigBuilder.build();
   }
 
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigImportModification.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigImportModification.java
new file mode 100644
index 0000000..08693ec
--- /dev/null
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigImportModification.java
@@ -0,0 +1,102 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.plugins.codeowners.backend;
+
+import static com.google.common.collect.ImmutableList.toImmutableList;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Representation of a code owner import modification as defined by {@link #apply(ImmutableList)}.
+ *
+ * <p>Used by {@link CodeOwnerConfigUpdate} to describe how the imports (aka {@link
+ * CodeOwnerConfigReference}s) in a {@link CodeOwnerConfig} should be changed on updated or be
+ * populated on creation.
+ *
+ * <p>This class provides a couple of static helper methods to modify imports that make changes to
+ * imports easier for callers.
+ */
+@FunctionalInterface
+public interface CodeOwnerConfigImportModification {
+  /**
+   * Create a {@link CodeOwnerConfigImportModification} instance that keeps the imports as they are.
+   *
+   * @return the created {@link CodeOwnerConfigImportModification} instance
+   */
+  public static CodeOwnerConfigImportModification keep() {
+    return originalImports -> originalImports;
+  }
+
+  /**
+   * Create a {@link CodeOwnerConfigImportModification} instance that clears the imports.
+   *
+   * <p>All imports are removed.
+   *
+   * @return the created {@link CodeOwnerConfigImportModification} instance
+   */
+  public static CodeOwnerConfigImportModification clear() {
+    return originalImports -> ImmutableList.of();
+  }
+
+  /**
+   * Create a {@link CodeOwnerConfigImportModification} instance that sets the given import.
+   *
+   * <p>This overrides all imports which have been set before.
+   *
+   * @param newImport the import that should be set
+   * @return the created {@link CodeOwnerConfigImportModification} instance
+   */
+  public static CodeOwnerConfigImportModification set(CodeOwnerConfigReference newImport) {
+    return set(ImmutableList.of(newImport));
+  }
+
+  /**
+   * Create a {@link CodeOwnerConfigImportModification} instance that sets the given imports.
+   *
+   * <p>This overrides imports which have been set before.
+   *
+   * @param newImports the imports that should be set
+   * @return the created {@link CodeOwnerConfigImportModification} instance
+   */
+  public static CodeOwnerConfigImportModification set(
+      ImmutableList<CodeOwnerConfigReference> newImports) {
+    return originalImports -> newImports;
+  }
+
+  /**
+   * Create a {@link CodeOwnerConfigImportModification} instance that removes the given import.
+   *
+   * <p>No-op if the given import doesn't exist.
+   *
+   * @param importToRemove the import that should be removed
+   * @return the created {@link CodeOwnerConfigImportModification} instance
+   */
+  public static CodeOwnerConfigImportModification remove(CodeOwnerConfigReference importToRemove) {
+    return originalImports ->
+        originalImports.stream()
+            .filter(codeOwnerConfigReference -> !codeOwnerConfigReference.equals(importToRemove))
+            .collect(toImmutableList());
+  }
+
+  /**
+   * Applies the modification to the given imports.
+   *
+   * @param originalImports the current imports of the code owner config that is being updated. If
+   *     used for a code owner config creation, this set is empty.
+   * @return the desired resulting imports (not the diff of the imports!)
+   */
+  ImmutableList<CodeOwnerConfigReference> apply(
+      ImmutableList<CodeOwnerConfigReference> originalImports);
+}
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReference.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReference.java
index d2b966c..5adc53b 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReference.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReference.java
@@ -66,6 +66,19 @@
   }
 
   /**
+   * Creates a code owner config reference.
+   *
+   * @param importMode the import mode
+   * @param filePath the path of the code owner config, may be absolute or relative to the path of
+   *     the importing code owner config
+   * @return the created code owner reference
+   */
+  public static CodeOwnerConfigReference create(
+      CodeOwnerConfigImportMode importMode, String filePath) {
+    return builder(importMode, filePath).build();
+  }
+
+  /**
    * Creates a builder for a code owner config reference.
    *
    * @param importMode the import mode
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigUpdate.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigUpdate.java
index 4ea94b7..48078b3 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigUpdate.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigUpdate.java
@@ -42,13 +42,23 @@
   public abstract CodeOwnerSetModification codeOwnerSetsModification();
 
   /**
+   * Defines how the imports of the code owner config should be modified. By default (that is if
+   * nothing is specified), the imports remain unchanged.
+   *
+   * @return a {@link CodeOwnerConfigImportModification} which gets the current imports of the code
+   *     owner config as input and outputs the desired resulting imports
+   */
+  public abstract CodeOwnerConfigImportModification importsModification();
+
+  /**
    * Creates a builder for a {@link CodeOwnerConfigUpdate}.
    *
    * @return builder for a {@link CodeOwnerConfigUpdate}
    */
   public static Builder builder() {
     return new AutoValue_CodeOwnerConfigUpdate.Builder()
-        .setCodeOwnerSetsModification(CodeOwnerSetModification.keep());
+        .setCodeOwnerSetsModification(CodeOwnerSetModification.keep())
+        .setImportsModification(CodeOwnerConfigImportModification.keep());
   }
 
   @AutoValue.Builder
@@ -82,6 +92,14 @@
         CodeOwnerSetModification codeOwnerSetsModification);
 
     /**
+     * Sets the imports modification.
+     *
+     * @see #importsModification()
+     */
+    public abstract Builder setImportsModification(
+        CodeOwnerConfigImportModification codeOwnerImportModification);
+
+    /**
      * Builds the {@link CodeOwnerConfigUpdate} instance.
      *
      * @return the {@link CodeOwnerConfigUpdate} instance
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java
index 7546bc0..bc4d247 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java
@@ -26,6 +26,9 @@
 import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;
 import com.google.gerrit.plugins.codeowners.acceptance.testsuite.CodeOwnerConfigOperations.PerCodeOwnerConfigOperations;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfig;
+import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigImportMode;
+import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigImportModification;
+import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigReference;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfigUpdate;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerSet;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerSetModification;
@@ -252,6 +255,30 @@
   }
 
   @Test
+  public void specifiedImportsAreRespectedForCodeOwnerConfigCreation() throws Exception {
+    CodeOwnerConfigReference import1 =
+        CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "/foo/OWNERS");
+    CodeOwnerConfigReference import2 =
+        CodeOwnerConfigReference.builder(
+                CodeOwnerConfigImportMode.GLOBAL_CODE_OWNER_SETS_ONLY, "/bar/OWNERS")
+            .setProject(allProjects)
+            .build();
+
+    CodeOwnerConfig.Key codeOwnerConfigKey =
+        codeOwnerConfigOperations
+            .newCodeOwnerConfig()
+            .project(project)
+            .addImport(import1)
+            .addImport(import2)
+            .create();
+
+    assertThat(getCodeOwnerConfigFromServer(codeOwnerConfigKey))
+        .hasImportsThat()
+        .containsExactly(import1, import2)
+        .inOrder();
+  }
+
+  @Test
   public void cannotCreateEmptyCodeOwnerConfig() throws Exception {
     IllegalStateException exception =
         assertThrows(
@@ -459,6 +486,69 @@
   }
 
   @Test
+  public void addImport() throws Exception {
+    CodeOwnerConfigReference oldImport =
+        CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "/foo/OWNERS");
+    CodeOwnerConfig codeOwnerConfig =
+        createCodeOwnerConfig(
+            false,
+            CodeOwnerSetModification.keep(),
+            CodeOwnerConfigImportModification.set(ImmutableList.of(oldImport)));
+    CodeOwnerConfigReference newImport =
+        CodeOwnerConfigReference.create(
+            CodeOwnerConfigImportMode.GLOBAL_CODE_OWNER_SETS_ONLY, "/bar/OWNERS");
+    codeOwnerConfigOperations
+        .codeOwnerConfig(codeOwnerConfig.key())
+        .forUpdate()
+        .addImport(newImport)
+        .update();
+    assertThat(getCodeOwnerConfigFromServer(codeOwnerConfig.key()))
+        .hasImportsThat()
+        .containsExactly(oldImport, newImport)
+        .inOrder();
+  }
+
+  @Test
+  public void removeImport() throws Exception {
+    CodeOwnerConfigReference import1 =
+        CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "/foo/OWNERS");
+    CodeOwnerConfigReference import2 =
+        CodeOwnerConfigReference.create(
+            CodeOwnerConfigImportMode.GLOBAL_CODE_OWNER_SETS_ONLY, "/bar/OWNERS");
+    CodeOwnerConfig codeOwnerConfig =
+        createCodeOwnerConfig(
+            false,
+            CodeOwnerSetModification.keep(),
+            CodeOwnerConfigImportModification.set(ImmutableList.of(import1, import2)));
+    codeOwnerConfigOperations
+        .codeOwnerConfig(codeOwnerConfig.key())
+        .forUpdate()
+        .importsModification(CodeOwnerConfigImportModification.remove(import1))
+        .update();
+    assertThat(getCodeOwnerConfigFromServer(codeOwnerConfig.key()))
+        .hasImportsThat()
+        .containsExactly(import2);
+  }
+
+  @Test
+  public void clearImports() throws Exception {
+    CodeOwnerConfig codeOwnerConfig =
+        createCodeOwnerConfig(
+            false,
+            CodeOwnerSetModification.keep(),
+            CodeOwnerConfigImportModification.set(
+                CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "/foo/OWNERS")));
+    codeOwnerConfigOperations
+        .codeOwnerConfig(codeOwnerConfig.key())
+        .forUpdate()
+        .clearImports()
+        .update();
+
+    // Removing all code owner sets leads to a deletion of the code owner config file.
+    assertThat(codeOwners.getFromCurrentRevision(codeOwnerConfig.key())).isEmpty();
+  }
+
+  @Test
   public void cannotUpdateNonExistingCodeOwnerConfig() throws Exception {
     CodeOwnerConfig.Key codeOwnerConfigKey = CodeOwnerConfig.Key.create(project, "master", "/");
     IllegalStateException exception =
@@ -495,11 +585,22 @@
 
   private CodeOwnerConfig createCodeOwnerConfig(
       boolean ignoreParentCodeOwners, CodeOwnerSetModification codeOwnerSetsModification) {
+    return createCodeOwnerConfig(
+        ignoreParentCodeOwners,
+        codeOwnerSetsModification,
+        CodeOwnerConfigImportModification.keep());
+  }
+
+  private CodeOwnerConfig createCodeOwnerConfig(
+      boolean ignoreParentCodeOwners,
+      CodeOwnerSetModification codeOwnerSetsModification,
+      CodeOwnerConfigImportModification codeOwnerImportModification) {
     CodeOwnerConfig.Key codeOwnerConfigKey = CodeOwnerConfig.Key.create(project, "master", "/");
     CodeOwnerConfigUpdate codeOwnerConfigUpdate =
         CodeOwnerConfigUpdate.builder()
             .setIgnoreParentCodeOwners(ignoreParentCodeOwners)
             .setCodeOwnerSetsModification(codeOwnerSetsModification)
+            .setImportsModification(codeOwnerImportModification)
             .build();
     return codeOwnersUpdate
         .get()