History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: UNI-175
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Tim Ducheyne
Reporter: Mariusz Smyku?a
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Unitils

Invalid syntax. assertMock.list() must be followed by a method invocation on the returned proxy. E.g. assertMock.list().myMethod()

Created: 06/Nov/09 07:32 AM   Updated: 12/Nov/09 09:42 AM
Component/s: mock
Affects Version/s: 3.0
Fix Version/s: 3.1

File Attachments: 1. GZip Archive unitils-issue.tar.gz (2 kb)

Environment: jdk1.6


 Description  « Hide
list() is my observed method, but unitils dont see that if after this I check something else:

sampleService.assertInvoked().list(100);
sampleService.assertInvoked().isValid("XXXX".getBytes());

sample project attached

 All   Comments   Change History      Sort Order:
Mariusz Smyku?a - 06/Nov/09 07:35 AM
Sample project illustrating problem with observated method

Tim Ducheyne - 08/Nov/09 11:46 AM
There was a problem with the chaining mechanism
The problem occurs when an assert is performed on a method has a return value:

For example:
public List<String> list(int value);

sampleService.assertInvoked().list(100);
sampleService.assertInvoked().list(100);

the second assertion will give the syntax error.
The reason for this is that unitils automatically creates a mock list instance and replaces the assertion with:

sampleService.assertInvoked().list(100).assertInvoked();

This makes it possible to do something like (i.e. method chaining):

sampleService.assertInvoked().list(100).iterator();
 

I've fixed the issue so that this no longer causes a syntax error.
 

Thanks for the report, I'll release a new version with the fix as soon as possible.

Grtz,
Tim

Mariusz Smyku?a - 12/Nov/09 09:42 AM
I think better is to close bug when new version is released. Now new users can be confused when are searching for open and new bugs...


As a workaround we can ommit this bug actually with resetBehavior();

Example:

sampleService.assertInvoked().list(100);
sampleService.resetBehavior();
sampleService.assertInvoked().list(100);