@@ -0,0 +1,3214 @@
+// Copyright (C) 2021 The Android Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.gerrit.plugins.codeowners.backend;%0A%0Aimport static com.google.common.truth.Truth.assertThat;%0Aimport static com.google.gerrit.testing.GerritJUnit.assertThrows;%0A%0Aimport com.google.gerrit.common.Nullable;%0Aimport com.google.gerrit.entities.Project.NameKey;%0Aimport com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;%0Aimport com.google.gerrit.plugins.codeowners.backend.findowners.FindOwnersBackend;%0Aimport com.google.gerrit.plugins.codeowners.backend.proto.ProtoBackend;%0Aimport com.google.gerrit.server.IdentifiedUser;%0Aimport java.nio.file.Path;%0Aimport java.util.Optional;%0Aimport org.eclipse.jgit.lib.ObjectId;%0Aimport org.eclipse.jgit.revwalk.RevWalk;%0Aimport org.junit.Test;%0A%0A/** Tests for %7B@link com.google.gerrit.plugins.codeowners.backend.CodeOwnerBackendId%7D. */%0Apublic class CodeOwnerBackendIdTest extends AbstractCodeOwnersTest %7B%0A  @Test%0A  public void getBackendIdForCodeOwnersBackendClass() throws Exception %7B%0A    assertThat(CodeOwnerBackendId.getBackendId(FindOwnersBackend.class))%0A        .isEqualTo(FindOwnersBackend.ID);%0A    assertThat(CodeOwnerBackendId.getBackendId(ProtoBackend.class)).isEqualTo(ProtoBackend.ID);%0A%0A    IllegalStateException exception =%0A        assertThrows(%0A            IllegalStateException.class,%0A            () -%3E CodeOwnerBackendId.getBackendId(TestCodeOwnerBackend.class));%0A    assertThat(exception)%0A        .hasMessageThat()%0A        .isEqualTo(%0A            String.format(%22unknown code owner backend: %25s%22, TestCodeOwnerBackend.class.getName()));%0A  %7D%0A%0A  private static class TestCodeOwnerBackend implements CodeOwnerBackend %7B%0A    @Override%0A    public Optional%3CCodeOwnerConfig%3E getCodeOwnerConfig(%0A        CodeOwnerConfig.Key codeOwnerConfigKey,%0A        @Nullable RevWalk revWalk,%0A        @Nullable ObjectId revision) %7B%0A      throw new UnsupportedOperationException(%22not implemented%22);%0A    %7D%0A%0A    @Override%0A    public Optional%3CCodeOwnerConfig%3E upsertCodeOwnerConfig(%0A        CodeOwnerConfig.Key codeOwnerConfigKey,%0A        CodeOwnerConfigUpdate codeOwnerConfigUpdate,%0A        @Nullable IdentifiedUser currentUser) %7B%0A      throw new UnsupportedOperationException(%22not implemented%22);%0A    %7D%0A%0A    @Override%0A    public boolean isCodeOwnerConfigFile(NameKey project, String fileName) %7B%0A      throw new UnsupportedOperationException(%22not implemented%22);%0A    %7D%0A%0A    @Override%0A    public Path getFilePath(CodeOwnerConfig.Key codeOwnerConfigKey) %7B%0A      throw new UnsupportedOperationException(%22not implemented%22);%0A    %7D%0A%0A    @Override%0A    public Optional%3CPathExpressionMatcher%3E getPathExpressionMatcher() %7B%0A      return Optional.empty();%0A    %7D%0A  %7D%0A%7D%0A

Add test for CodeOwnerBackendId.getBackendId(Class) method