@Test
  public void testOneOffAndCP() throws Exception {
    Module module =
        new Module.Builder("module-test")
            .miscFile(
                new ResourceItem(
                    "resource-test", ("module resource").getBytes(StandardCharsets.UTF_8)))
            .build();
    File moduleDir = module.writeToDisk(new File(MODULES_PATH));

    byte[] targetHash = HashUtils.hashFile(moduleDir);
    targetHash = applyOneOff("oneoff1", targetHash);
    targetHash = applyCP("cp1", targetHash);

    final ModelNode response = showHistory();

    assertTrue(response.has("outcome"));
    assertEquals("success", response.get("outcome").asString());
    assertTrue(response.has("result"));
    final List<ModelNode> list = response.get("result").asList();
    assertEquals(2, list.size());
    ModelNode entry = list.get(0);
    assertEquals("cp1", entry.get("patch-id").asString());
    assertEquals("cumulative", entry.get("type").asString());
    entry = list.get(1);
    assertEquals("oneoff1", entry.get("patch-id").asString());
    assertEquals("one-off", entry.get("type").asString());
  }
  @Test
  public void testMain() throws Exception {

    // create a module
    Module module =
        new Module.Builder("module-test")
            .miscFile(
                new ResourceItem(
                    "resource-test", ("module resource").getBytes(StandardCharsets.UTF_8)))
            .build();
    File moduleDir = module.writeToDisk(new File(MODULES_PATH));

    byte[] targetHash = HashUtils.hashFile(moduleDir);
    for (int i = 0; i < patchIds.length; ++i) {
      if (patchTypes[i]) {
        targetHash = applyCP(patchIds[i], targetHash);
      } else {
        targetHash = applyOneOff(patchIds[i], targetHash);
      }
    }

    final ModelNode response = showHistory();

    assertTrue(response.has("outcome"));
    assertEquals("success", response.get("outcome").asString());
    assertTrue(response.has("result"));
    final List<ModelNode> list = response.get("result").asList();
    assertEquals(patchIds.length, list.size());
    for (int i = 0; i < patchIds.length; ++i) {
      final ModelNode info = list.get(i);
      assertEquals(patchIds[patchIds.length - 1 - i], info.get("patch-id").asString());
      assertTrue(info.has("type"));
      final String type = patchTypes[patchTypes.length - 1 - i] ? "cumulative" : "one-off";
      assertEquals(type, info.get("type").asString());
      assertTrue(info.has("applied-at"));
    }
  }