Created
July 30, 2020 01:21
-
-
Save gbzarelli/74573f10449f2a248aa36bbc0bd36d3a to your computer and use it in GitHub Desktop.
Used in Medium article about Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SpringBootTest | |
@DataJpaTest | |
class PersonRepositoryIntegrationTest { | |
@Autowired | |
private PersonRepository subject; | |
@AfterEach | |
void tearDown() throws Exception { | |
subject.deleteAll(); | |
} | |
@Test | |
void shouldSaveAndFetchPerson() throws Exception { | |
Person peter = new Person("Peter", "Pan"); | |
subject.save(peter); | |
Optional<Person> maybePeter = subject.findByLastName("Pan"); | |
assertThat(maybePeter, is(Optional.of(peter))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment