### Question:
PublisherContract extends AggregateRoot<PublisherContractId> { public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) { assertHasNotBeenRegistered(); applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit)); }  void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit); void registerPurchase(ProductId productId, long unitPrice, int quantity);  }### Answer:
@Test public void testRegisterPublisher() { PublisherContract contract = new PublisherContract(); PublisherContractId publisherContractId = PublisherContractId.randomId(); double feePercentage = 5.0; contract.register(publisherContractId, "Addison Wesley", feePercentage, LIMIT); PublisherContractRegisteredEvent event = getOnlyElement(filter(contract.getUncommittedEvents(), PublisherContractRegisteredEvent.class)); assertThat(event.feePercentage, is(5.0)); assertThat(event.publisherName, is("Addison Wesley")); }
@Test(expected = IllegalStateException.class) public void testCannotRegisterTwice() { PublisherContract contract = new PublisherContract(); PublisherContractId publisherContractId = PublisherContractId.randomId(); contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT); contract.register(publisherContractId, "Addison Wesley", 5.0, LIMIT); }