[Proposal] Enable Lombok.toBuilder annotation flag in ResourceModel template
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu với python/rpdk/java/templates/init/guided_aws/ResourceModel.java, được liên kết trong issue, và kiểm tra cách các annotation của ResourceModel được tạo ra được lắp ghép. Xác định xem toBuilder nên được bật theo mặc định hay được cung cấp dưới dạng schema flag, sau đó xác minh rằng các model Java được tạo ra hỗ trợ builder-copy workflow được yêu cầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Dear team,
I wonder if you folks would have any concerns about enabling toBuilder attribute for Lombok @Builder by default or with an additional schema flag?
At the moment, ResourceModel template generates non-parametrized @Builder: https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/blob/master/python/rpdk/java/templates/init/guided_aws/ResourceModel.java#L20
One of the reasons I would like to see this flag enabled is a significant simplification of overriding massive resource model definitions in testing, especially in testing an UpdateHandler.
Here is an example:
public class AbstractTestBase {
protected static final ResourceModel MODEL_BEFORE;
protected static final ResourceModel MODEL_AFTER;
static {
MODEL_BEFORE = ResourceModel.builder()
.foo("foo-before")
.bar("bar-before")
.baz("baz-before")
.build();
MODEL_AFTER = ResourceModel.builder()
.foo("foo-before")
.bar("bar-before")
.baz("totally-different-baz")
.build();
}
}
Assume I'm using these models in UpdateHandler test suite. If the update flow has a broad branching based on model attribute invariants, one has to initiate separate model instances for each branch case. It's completely fine for a 5-10 attribute models, but the burden of carrying things around grows once one has to deal with a 30-50 attribute model.
Having toBuilder = true enabled in ResourceModel definition would let one define models like
public class AbstractTestBase {
protected static final ResourceModel MODEL_BEFORE;
protected static final ResourceModel MODEL_AFTER;
static {
MODEL_BEFORE = ResourceModel.builder()
.foo("foo-before")
.bar("bar-before")
.baz("baz-before")
.build();
MODEL_AFTER = MODEL_BEFORE.toBuilder()
.baz("totally-different-baz")
.build();
}
}
In fact, being able to override a static model locally within the current test case scope is even better, it could look like:
public class UpdateHandlerTest extends AbstractTestBase {
//...
public void handleRequest_SimpleSuccess() {
final ResourceModel modelWithUpdatedBaz = MODEL_BEFORE.toBuilder()
.baz("totally-different-baz")
.build();
//...
}
}
- Ngôn ngữ chính
- Java
- Star
- 30
- Fork
- 48
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws-cloudformation/cloudformation-cli-java-plugin
-
Runtime compatibility issue Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
aws-cloudformation/cloudformation-cli-java-plugin#415 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
-
injectCredentialsAndInvokeV2 method in proxy class doesn't support API's like PutObject from S3. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Tất cả issue của aws-cloudformation/cloudformation-cli-java-plugin
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
checkstyle/test-configs#263 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Cannot differ own consent and managed consents in My Consents view and detailed consent view. Đang mở1.0.0-alpha2 Type/Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
wso2/dpdp-accelerator#272 ·