Cake { public void publish(String key, Object value) { getSubKeysAndValidateFullKey(key); String newKey = getPrefixWithSeparator(prefixStack) + key; entries.put(newKey, value); } 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 = IllegalArgumentException.class) public void testPublish_throwsOnNullKey() { cake.publish(null, "value"); }
@Test(expected = IllegalArgumentException.class) public void testPublish_throwsOnEmptyStringKey() { cake.publish("", "value"); }
@Test(expected = IllegalArgumentException.class) public void testPublish_throwsOnEmptyStringSubkey() { cake.publish("a" + Cake.SEPARATOR + "", "bar"); }