bastion-dev / Bastion

Java test library for HTTP APIs
http://bastion.rocks
GNU General Public License v3.0
13 stars 8 forks source link

Enforce the Bastion builder method call ordering #52

Closed KPull closed 7 years ago

KPull commented 7 years ago

The order in which methods are expected to be called on the Bastion builder are as follows:

Bastion.request(...)
       .bind(...)          
       .withAssertions(...)
       .thenDo(...)        
       .call()
       .getModel()

The problem is that the actual BastionBuilderImpl object does not enforce this order. A user can keep a reference to the object returned by Bastion.request() and call bind() twice in a row. We could figure out ways how to handle this, or we could save us all the trouble of supporting this and just restrict the user from calling it more than once.

Notice that a fix for this issue must also enforce that the user calls the above methods in the order listed. A user cannot first provide an Assertions<String> object using withAssertions(), for example, and then choose to call the bind() method with a different object.

KPull commented 7 years ago

Fixed in #85.