Reputation: 16992
I have the below lines in one of the projects that I am working on in one of the test classes. I went over mocoServer documentation but wasn't able to understand the below lines. Please can you explain the code listed below?
mocoServer.
request(by(uri("/as/token.oauth2"))).response(contentFromFile(DIR, "token.json"));
mocoServer.request(and(contain(text("Account")))).response(
with(contentFromFile(TEST_COMMON_DIR, ACCOUNT_RESPONSE)));
Upvotes: 2
Views: 93
Reputation: 7058
It's just a clever way of naming methods for building objects. It tries to make the code more readable and compact.
I have no idea what this mocoServer
of yours is or does, but the lines do these things:
Line 1: When the mocoServer gets a request on uri "/as/token.oauth2" it will return a response with the contents of the file "token.json" from the directory DIR.
Line 2: When the mocoServer gets a request which contains the string "Account", it will return the contents of the file ACCOUNT_RESPONSE from the directory TEST_COMMON_DIR.
Upvotes: 3