public void register(String noteId, String className,
                       String event, String cmd) throws InvalidHookException {
    synchronized (registry) {
      if (!HookType.ValidEvents.contains(event)) {
        throw new InvalidHookException("event " + event + " is not valid hook event");
      }
      if (noteId == null) {
        noteId = GLOBAL_KEY;
      }
      addRepl(noteId, className);
      registry.get(noteId).get(className).put(event, cmd);
    }
  }
@Test
  void testValidEventCode() {
    assertThrows(InvalidHookException.class, () -> {
      InterpreterHookRegistry registry = new InterpreterHookRegistry();
      // Test that only valid event codes ("pre_exec", "post_exec") are accepted
      registry.register("foo", "bar", "baz", "whatever");
    });


  }