Bean { public static void register(Class<?> beanClass) { CONTEXT.compute(beanClass, (key, value) -> { if (value != null) throw new Error("bean class is already registered, beanClass=" + key.getCanonicalName()); new JSONClassValidator(key).validate(); return new Context<>(beanClass); }); }  static void register(Class<?> beanClass); static T fromJSON(Class<T> beanClass, String json); static String toJSON(T bean);  }
@Test void registerDuplicateBean() { assertThatThrownBy(() -> Bean.register(TestBean.class)) .isInstanceOf(Error.class) .hasMessageContaining("bean class is already registered"); }