This is the demo "script" that Eric uses on his machine using his IntelliJ Live Templates.
Follow all steps in the Pre-demo
prep in the demo-script.
Follow all the steps in The demo
in the demo-script.
-
Open
CarpetResourceTest
-
Remove the mocked
WookieService
and thesetUp
method -
Place cursor above
@QuarkusTest
-
Use the
pactConsumerAnnotations
live template to insert class annotations
-
-
Place cursor before the
testCarpetEndpointForBrownColor
-
Use the
requestingFurContract
live template to insert the contract
-
-
Place cursor above
@Test
on thetestCarpetEndpointForBrownColor
method-
Use the
pactTestForRequestingFurContract
live template to insert the@PactTestFor
annotation
-
-
Show tests pass
-
Publish the contract (in the
weaver
terminal, run./publish-contracts-to-broker.sh
) -
Show the broker (https://wookie-carpets.pactflow.io)
-
Create test class
FurResourceContractVerificationTests
-
Highlight the entire class
-
Use the
furResourceContractVerificationTests
live template to insert the class body -
May need to resolve some imports - use IntelliJ CMD+1 for quick fix help on each import
-
-
Tests should be red. Go to broker (https://wookie-carpets.pactflow.io) and show tests red
-
Open
Skein
record, highlightcolor
in record constructor-
SHIFT+F6
to refactor/rename tocolour
-
-
Tests should be green. Return to broker & see green there too
-
Write the contract
when I ask for pink I get 404
. Test should fail.-
In
CarpetResourceTest
:-
Use
requestingPinkFurContract
live template to insert the contract -
Use
testCarpetEndpointForPinkCarpet
live template to insert the test
-
-
-
Fix weaver to handle
404
. Test is green when done.-
In
CarpetResource
, add try/catch
-
catch (WebApplicationException ex) {
throw new NotFoundException(order.colour());
}
-
Publish contract (in the
weaver
terminal, run./publish-contracts-to-broker.sh 2.0
) -
Go to broker (https://wookie-carpets.pactflow.io) and show updated contract
-
CMD-S
to trigger continuous testing to find contract. Tests should be red. Show broker. -
Fix wookie tamer to return
null
which will send a204
-
Open
FurResource
& changewookieColor = WookieColor.BROWN;
toreturn null;
-
-
Congratulate on a job well-done, except…why are those tests red?! I’m doing error handling. Show broker.
-
Debate about
204
vs404
& which is better option. Making404
is more code,204
should be fine. Let’s just adjust mock to match reality.
-
In
CarpetResourceTest
, change.status(Status.NOT_FOUND.getStatusCode())
to.status(Status.NO_CONTENT.getStatusCode())
-
Publish contract (in the
weaver
terminal, run./publish-contracts-to-broker.sh 3.0
) -
Ok, my mock now matches reality, but now both weaver & tamer tests are red? WTH?!?!
-
Changing expectation to match reality doesn’t get things green because apparently weaver doesn’t properly handle
204
. -
Need to have a conversation about
204
/404
between us
-