Oven extends AbstractOven { public void addDispatcher(String domain, Dispatcher dispatcher) { if (dispatchers.containsKey(domain)) { throw new RuntimeException("oven already has a dispatcher for domain '" + domain + "'"); } dispatchers.put(domain, dispatcher); }  Cake bake(Recipe recipe); void addDispatcher(String domain, Dispatcher dispatcher); void setDefaultDispatcher(Dispatcher dispatcher);  }
@Test(expected = RuntimeException.class) public void testAddDispatcher_alreadyExistsForDomain() { oven.addDispatcher("FooDomain", payload -> "{}"); oven.addDispatcher("FooDomain", payload -> "{}"); }
@Test(expected = RuntimeException.class) public void testBake_throwsOnAddTwoDispatchersForSameDomain() { oven.addDispatcher("A", (payload) -> "{}"); oven.addDispatcher("A", (payload) -> "{}"); }