@@ -0,0 +1,2077 @@
+// Copyright (C) 2019 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.reviewdb.client;%0A%0Aimport static com.google.common.truth.Truth.assertThat;%0Aimport static com.google.common.truth.Truth.assert_;%0A%0Aimport com.google.gerrit.testing.GerritBaseTests;%0Aimport org.junit.Test;%0A%0Apublic class PatchTest extends GerritBaseTests %7B%0A  @Test%0A  public void isMagic() %7B%0A    assertThat(Patch.isMagic(%22/COMMIT_MSG%22)).isTrue();%0A    assertThat(Patch.isMagic(%22/MERGE_LIST%22)).isTrue();%0A%0A    assertThat(Patch.isMagic(%22/COMMIT_MSG/%22)).isFalse();%0A    assertThat(Patch.isMagic(%22COMMIT_MSG%22)).isFalse();%0A    assertThat(Patch.isMagic(%22/commit_msg%22)).isFalse();%0A  %7D%0A%0A  @Test%0A  public void parseKey() %7B%0A    assertThat(Patch.Key.parse(%221,2,foo.txt%22))%0A        .isEqualTo(new Patch.Key(new PatchSet.Id(new Change.Id(1), 2), %22foo.txt%22));%0A    assertThat(Patch.Key.parse(%2201,02,foo.txt%22))%0A        .isEqualTo(new Patch.Key(new PatchSet.Id(new Change.Id(1), 2), %22foo.txt%22));%0A    assertInvalidKey(null);%0A    assertInvalidKey(%22%22);%0A    assertInvalidKey(%221,2%22);%0A    assertInvalidKey(%221, 2, foo.txt%22);%0A    assertInvalidKey(%221,foo.txt%22);%0A    assertInvalidKey(%221,foo.txt,2%22);%0A    assertInvalidKey(%22foo.txt,1,2%22);%0A%0A    String hexComma = %22%25%22 + String.format(%22%2502x%22, (int) ',');%0A    assertInvalidKey(%221%22 + hexComma + %222%22 + hexComma + %22foo.txt%22);%0A  %7D%0A%0A  private static void assertInvalidKey(String str) %7B%0A    try %7B%0A      Patch.Key.parse(str);%0A      assert_().fail(%22expected RuntimeException%22);%0A    %7D catch (RuntimeException e) %7B%0A      // Expected.%0A    %7D%0A  %7D%0A%7D%0A

Add test for Patch