joel-costigliola/assertj-core — pull request #285 by liefke (2014-12-04 11:11:08+00:00)
Title: Added AssertProvider for linking objects to their Assert

Currently if I have an additional Assert class, I have to create (or generate) a new Assertions class to allow the fluent form MyAssertions.assertThat(MyObject).condition().

This is ok if the tested object (MyObject) is a real application object, because it can't know anything about the Assert class (which is usually only available during test time).

But if MyObject is an object just for testing as well, e.g. because it is a page object ([see here for an introduction to page objects](https://code.google.com/p/selenium/wiki/PageObjects)), this extra Assertions class is not really necessary and the disadvantage dominates:
You have either more than one custom Assertions class (where you can't use a static import for assertThat in the same test class), or you have to combine all different Assert from different packages into one big Assertions class - what may lead to dependency cycles and other architectural problems.

I know that there is the concept of a AssertDelegateTarget, but if you use that you have to create (and know) the Asserts by yourself. And Assertions.assertThat(new MyDelegateAssert(testObject)).containsText("...") is not as fluent as Assertions.assertThat(testObject).containsText("...").

So I have created a small patch of Assertions, to support the definition of the associated Assert in the tested object.

Here a short example of the usage:
```java
public class Button implements AssertProvider {
public String getText() {
return ...;
}
public ButtonAssert assertThat() {
return new ButtonAssert(this);
}
}

public class ButtonAssert extends Assert {
...
public ButtonAssert containsText(String text) {
...
}
}

void testMethod() {
Button button = ...;
Assertions.assertThat(button).containsText("Test");
}
```

I hope you see the advantages of this usecase and add it to AssertJ as well.