Introduce the application, show its current form and run the integration test
-
Explain that this is a Boot 1.3 application
-
Show main
Application
class -
Show the
domain
package-
Point out
VehicleIdentificationNumber
and the relatedVehicleIdentificationNumberAttributeConverter
-
-
Show the
service
package-
Start with
VehicleDetailsService
then look atRemoteVehicleDetailsService
-
-
Show the
web
package-
Start with
UserVehicleController
-
Explain the
UserVehicleService
facade
-
-
Show the single
ApplicationIntegrationTest
-
Start MySQL and Show the database
-
Start
mvn -Pwiremock
-
Run
curl -v http://localhost:8081/vs/vehicle/01234567890123456/details
(three times) -
Run the test in the IDE
-
Show the POM.xml change
-
Show that
@GetMapping
is now used instead of@RequestMapping
-
Point out the more readable name for SpringJUnit4ClassRunner
-
Show how
@SpringBootTest
replaces@WebIntegrationTest
and@SpringApplicationConfiguration
-
Initially use the
classes
attribute to loadApplication.class
-
Show how an autowired
TestRestTemplate
removes the need for@LocalServerPort
-
Show the new
assertThat
call -
Explain the benefits of AssertJ
-
Explain that it’s imported by
spring-boot-starter-test
-
Show how
UserVehicleServiceTest
is a standard JUnit test -
Explain why these are generally the best type of tests to write
-
Briefly cover
-
How the
ExpectedException
@Rule
works -
How
@Mock
and BDD Mockito works -
Why tests are commented like they are
-
-
Show how
VehicleIdentificationNumberTest
is another simple JUnit test -
Show
UserEntityTest
-
Explain slices
-
Explain about
@AutoConfigure…
meta-annotations -
Explain use of in-memory database and
@AutoConfigureTestDatabase
-
Explain
TestEntityManager
-
-
Show
UserRepositoryTest
-
Show that basic queries are working as expected
-
-
Shutdown MySQL
-
Show how
ApplicationIntegrationTest
now fails
-
Show how
@AutoConfigureTestDatabase
can be mixed into existing tests -
Talk about pros and cons of this approach
-
Show the
RemoteVehicleDetailsServiceTest
-
Explain how
MockRestServiceServer
is used -
Show the
protected
method trick to attach the mock -
Show how SpringRunner is not needed
-
-
Show
VehicleDetailsJsonTest
-
Explain
@JsonTest
-
Explain
JacksonTester
(and how it can also be used directly) -
Show the
json
asserts
-
-
Shutdown wiremock
-
Explain how
ApplicationIntegrationTest
would fails -
Show @MockBean annotation
-
Show
UserVehicleControllerTest
-
Explain how
MockMvc
can be autowired -
Show
@AutoConfigureMockMvc
meta-annotation -
Show use of
@MockBean
again and explain benefit for exceptions
-
-
Show
UserVehicleControllerApplicationTest
-
Explain that this one also needs the database because it loads the full config
-