Cake { @JsonIgnore public <T> T getOrGetContext(String... key) { try { return get(key); } catch (RuntimeException e) { return getContext(); } } Cake();  Cake(Cake other); static String key(String... subKeys); @SuppressWarnings("unchecked") T get(String... key); @SuppressWarnings("unchecked") T get(Class<T> clazz, String... key); void publish(String key, Object value); void inNamespace(String key, Runnable runnable); String getPublishedKeyForValue(Object value, boolean fullyQualified); @JsonIgnore String getNamespace(); boolean hasContext(); @JsonIgnore T getContext(); @JsonIgnore @SuppressWarnings("unchecked") T getContext(Class<T> clazz); @JsonIgnore T getOrGetContext(String... key); @JsonIgnore T getOrGetContext(Class<T> clazz, String... key); static final String SEPARATOR; }
@Test(expected = RuntimeException.class) public void testGetOrGetContext_throwsOnNonExistentKeyNoContext() { cake.getOrGetContext("foo"); }