View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2013-2025 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.jcabi.github.mock;
6   
7   import com.jcabi.xml.XML;
8   import jakarta.json.Json;
9   import java.io.IOException;
10  import org.hamcrest.MatcherAssert;
11  import org.hamcrest.Matchers;
12  import org.junit.jupiter.api.Test;
13  
14  /**
15   * Test case for {@link JsonPatch}.
16   * @since 0.5
17   */
18  final class JsonPatchTest {
19  
20      @Test
21      void patchesXml() throws IOException {
22          final MkStorage storage = new MkStorage.InFile();
23          new JsonPatch(storage).patch(
24              "/github",
25              Json.createObjectBuilder()
26                  .add("name", "hi you!")
27                  .add("number", 1)
28                  .build()
29          );
30          final XML xml = storage.xml();
31          MatcherAssert.assertThat(
32              "String does not end with expected value",
33              xml.xpath("/github/name/text()").get(0),
34              Matchers.describedAs(xml.toString(), Matchers.endsWith("you!"))
35          );
36      }
37  
38  }