@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); }
public void register(PublisherContractId publisherContractId, String name, double feePercentage, long limit) { assertHasNotBeenRegistered(); applyChange(new PublisherContractRegisteredEvent(publisherContractId, nextVersion(), now(), name, feePercentage, limit)); }
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)); } }
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)); }  }
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); }
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);  }