Title: [Proposal] Enable Lombok.toBuilder annotation flag in ResourceModel template · Issue #331 · aws-cloudformation/cloudformation-cli-java-plugin · GitHub
Open Graph Title: [Proposal] Enable Lombok.toBuilder annotation flag in ResourceModel template · Issue #331 · aws-cloudformation/cloudformation-cli-java-plugin
X Title: [Proposal] Enable Lombok.toBuilder annotation flag in ResourceModel template · Issue #331 · aws-cloudformation/cloudformation-cli-java-plugin
Description: 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: http...
Open Graph Description: 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 g...
X Description: 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 g...
Opengraph URL: https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/issues/331
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Proposal] Enable Lombok.toBuilder annotation flag in ResourceModel template","articleBody":"Dear team,\r\n\r\nI wonder if you folks would have any concerns about enabling `toBuilder` attribute for Lombok @\u003c!-- -->Builder by default or with an additional schema flag?\r\n\r\nAt the moment, `ResourceModel` template generates non-parametrized @\u003c!-- -->Builder: https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/blob/master/python/rpdk/java/templates/init/guided_aws/ResourceModel.java#L20\r\n\r\nOne 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`.\r\n\r\nHere is an example:\r\n\r\n```java\r\npublic class AbstractTestBase {\r\n protected static final ResourceModel MODEL_BEFORE;\r\n protected static final ResourceModel MODEL_AFTER;\r\n\r\n static {\r\n MODEL_BEFORE = ResourceModel.builder()\r\n .foo(\"foo-before\")\r\n .bar(\"bar-before\")\r\n .baz(\"baz-before\")\r\n .build();\r\n MODEL_AFTER = ResourceModel.builder()\r\n .foo(\"foo-before\")\r\n .bar(\"bar-before\")\r\n .baz(\"totally-different-baz\")\r\n .build();\r\n }\r\n}\r\n```\r\n\r\nAssume 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.\r\n\r\nHaving `toBuilder = true` enabled in `ResourceModel` definition would let one define models like\r\n```java\r\npublic class AbstractTestBase {\r\n protected static final ResourceModel MODEL_BEFORE;\r\n protected static final ResourceModel MODEL_AFTER;\r\n\r\n static {\r\n MODEL_BEFORE = ResourceModel.builder()\r\n .foo(\"foo-before\")\r\n .bar(\"bar-before\")\r\n .baz(\"baz-before\")\r\n .build();\r\n MODEL_AFTER = MODEL_BEFORE.toBuilder()\r\n .baz(\"totally-different-baz\")\r\n .build();\r\n }\r\n}\r\n```\r\n\r\nIn fact, being able to override a static model locally within the current test case scope is even better, it could look like:\r\n```java\r\npublic class UpdateHandlerTest extends AbstractTestBase {\r\n //...\r\n public void handleRequest_SimpleSuccess() {\r\n final ResourceModel modelWithUpdatedBaz = MODEL_BEFORE.toBuilder()\r\n .baz(\"totally-different-baz\")\r\n .build();\r\n //...\r\n }\r\n}\r\n```","author":{"url":"https://github.com/osdrv","@type":"Person","name":"osdrv"},"datePublished":"2020-11-23T14:28:52Z","url":"https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/issues/331"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7be0332e-da5c-ac89-41dd-5ff3b40c14eb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8358:20702:5D3082:8618B2:6AFD8AAB |
| html-safe-nonce | 519368b6783d996a6d3a300085d7ad0aac9c8de6fadc2074552ec3de47afac8e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzU4OjIwNzAyOjVEMzA4Mjo4NjE4QjI6NkFGRDhBQUIiLCJ2aXNpdG9yX2lkIjoiMjQyNjQxNTAzOTQ5ODc4MzQwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 93cb6cac686d4dd7184c33df431b0cb0f7c43483b0402422577bd24fd7772698 |
| hovercard-subject-tag | issue:748849165 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/aws-cloudformation/cloudformation-cli-java-plugin/331/issue_layout |
| twitter:image | https://opengraph.githubassets.com/715af84b1c68b133d79bd52737a679ef8fc48021e76f55987201daa8f82a2464/aws-cloudformation/cloudformation-cli-java-plugin/issues/331 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/715af84b1c68b133d79bd52737a679ef8fc48021e76f55987201daa8f82a2464/aws-cloudformation/cloudformation-cli-java-plugin/issues/331 |
| og:image:alt | 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 g... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | osdrv |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-preview |
| go-import | github.com/aws-cloudformation/cloudformation-cli-java-plugin git https://github.com/aws-cloudformation/cloudformation-cli-java-plugin.git |
| octolytics-dimension-user_id | 19900777 |
| octolytics-dimension-user_login | aws-cloudformation |
| octolytics-dimension-repository_id | 152624998 |
| octolytics-dimension-repository_nwo | aws-cloudformation/cloudformation-cli-java-plugin |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 152624998 |
| octolytics-dimension-repository_network_root_nwo | aws-cloudformation/cloudformation-cli-java-plugin |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width