@Test
  public void testPostModifyNamespace() throws IOException {
    final Admin admin = UTIL.getAdmin();
    final String ns = "postmodifyns";

    NamespaceDescriptor nsDesc = NamespaceDescriptor.create(ns).build();
    admin.createNamespace(nsDesc);

    HMaster master = UTIL.getMiniHBaseCluster().getMaster();
    MasterObserverForTest observer =
      master.getMasterCoprocessorHost().findCoprocessor(MasterObserverForTest.class);
    int preCount = observer.postHookCalls.get();
    try {
      admin.modifyNamespace(NamespaceDescriptor.create("nonexistent").build());
      fail("Modifying a missing namespace should fail");
    } catch (IOException e) {
      // Pass
    }
    int postCount = observer.postHookCalls.get();
    assertEquals("Expected no invocations of postModifyNamespace when the operation fails",
      preCount, postCount);

    // Validate that the postDeletNS hook is invoked
    preCount = observer.postHookCalls.get();
    admin
      .modifyNamespace(NamespaceDescriptor.create(nsDesc).addConfiguration("foo", "bar").build());
    postCount = observer.postHookCalls.get();
    assertEquals("Expected 1 invocation of postModifyNamespace", preCount + 1, postCount);
  }
Tests class that validates that "post" observer hook methods are only invoked when the operation
was successful.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterObserverPostCalls.java