assertj / assertj/assertj-generator

switch the property/field templates over to use the 'navigation' approach by default?

オープン
#69 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
72
フォーク
47
平均マージ
1日 16時間
マージ済み PR(30日)
2

説明

Once this PR is merged and issue fixed https://github.com/joel-costigliola/assertj-assertions-generator/issues/67 along with the NavigationListAssert class in assertj-core: https://github.com/joel-costigliola/assertj-core/issues/641 it would be easy to switch the OOTB templates in the generator to use the 'navigation' model approach.

So that for every property of an object we generate exactly one navigation method that lets users chain assertions together; reusing all the methods from ListAssert and NavigationListAssert for iterable properties or the custom typed assertions for other properties.

This would result in much smaller code generated for the assertion classes and much more power. The only downside is some of the current methods would be a tad more verbose.

e.g. for a generated assertion class with a name property the current generated code would be:

``` java
// current generated code
assertThat(person).hasName("James");

// new minimal code
assertThat(person).name().isEqualTo("James");
assertThat(person).name().contains("m");
...
```

Ditto for iterable properties right now we generate a few methods which are mostly already included in ListAssert. e.g. all these assertion methods are available on any generated iterable property method:
https://github.com/jstrachan/assertj-core/blob/7b1d079edeb5ac984cebbed77a65025718ee7673/src/test/java/org/assertj/core/navigation/ListNavigation_Test.java#L56-L62

Removing the old generated methods would break folks code I guess; so maybe we should add a flag to switch to the new more concise model?

If you are interested; here are the 2 new templates (which need minor tweaks to reuse the https://github.com/joel-costigliola/assertj-core/issues/641 code):
- for general properties/fields: https://github.com/jstrachan/fabric8/blob/5f99b82696856e9c5614ff5a728adfbeaab96751/components/kubernetes-assertions/src/main/assertj-templates/navigation_template.txt
- for iterable properties/fields: https://github.com/jstrachan/fabric8/blob/6e333451afceec3308e6869f39a14c3e569d837b/components/kubernetes-assertions/src/main/assertj-templates/has_elements_assertion_template_for_iterable.txt

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず issue 67 と assertj-core issue 641 を確認し、次に、リンクされている2つのナビゲーションテンプレートと、generator の現在の property テンプレートおよび iterable テンプレートを比較します。NavigationListAssert のサポートと互換性フラグが生成される API にどのような影響を与えるかを判断し、生成された assertions が既存のメソッドを壊すことなくナビゲーションメソッドを提供していることを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。