@Test public void should_create_product() { Product product = Product.create("name", "desc", BigDecimal.valueOf(12.0), "123456"); assertNotNull(product); }
public static Product create(String name, String description, BigDecimal price, String categoryId) { Product product = Product.builder() .id(newUuid()) .name(name) .description(description) .price(price) .createdAt(Instant.now()) .inventory(0) .categoryId(categoryId) .build(); product.raiseEvent(new ProductCreatedEvent(product.getId(), name, description, price, product.getCreatedAt())); return product; }
Product extends BaseAggregate { public static Product create(String name, String description, BigDecimal price, String categoryId) { Product product = Product.builder() .id(newUuid()) .name(name) .description(description) .price(price) .createdAt(Instant.now()) .inventory(0) .categoryId(categoryId) .build(); product.raiseEvent(new ProductCreatedEvent(product.getId(), name, description, price, product.getCreatedAt())); return product; } }
Product extends BaseAggregate { public static Product create(String name, String description, BigDecimal price, String categoryId) { Product product = Product.builder() .id(newUuid()) .name(name) .description(description) .price(price) .createdAt(Instant.now()) .inventory(0) .categoryId(categoryId) .build(); product.raiseEvent(new ProductCreatedEvent(product.getId(), name, description, price, product.getCreatedAt())); return product; }  }
Product extends BaseAggregate { public static Product create(String name, String description, BigDecimal price, String categoryId) { Product product = Product.builder() .id(newUuid()) .name(name) .description(description) .price(price) .createdAt(Instant.now()) .inventory(0) .categoryId(categoryId) .build(); product.raiseEvent(new ProductCreatedEvent(product.getId(), name, description, price, product.getCreatedAt())); return product; }  static Product create(String name, String description, BigDecimal price, String categoryId); void updateName(String newName); void updateInventory(int inventory); ProductRepresentation toRepresentation(); }
Product extends BaseAggregate { public static Product create(String name, String description, BigDecimal price, String categoryId) { Product product = Product.builder() .id(newUuid()) .name(name) .description(description) .price(price) .createdAt(Instant.now()) .inventory(0) .categoryId(categoryId) .build(); product.raiseEvent(new ProductCreatedEvent(product.getId(), name, description, price, product.getCreatedAt())); return product; }  static Product create(String name, String description, BigDecimal price, String categoryId); void updateName(String newName); void updateInventory(int inventory); ProductRepresentation toRepresentation();  }