package de.springbootbuch.database_examples.springdata;

import java.util.Optional;
import java.util.stream.Stream;
import static org.hamcrest.CoreMatchers.is;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@DataJpaTest
public class FilmSimpleJpaRepositoryIT {
	
	private static final Logger LOG = LoggerFactory
		.getLogger(FilmSimpleJpaRepositoryIT.class);

	@Autowired
	private FilmSimpleJpaRepository filmRepository;

	@Test
	public void findOneShouldWork() {
		Optional<FilmEntity> film;
		
		film = filmRepository.findById(-1);
		assertThat(film.isPresent(), is(false));
		
		film = filmRepository.findById(1);
		assertThat(film.isPresent(), is(true));
	}
	
	@Test
	public void findAllShouldWork() {
		try (Stream<FilmEntity> stream = filmRepository.findAll()) {
			stream.map(FilmEntity::getTitle).forEach(LOG::debug);
		}
	}
	
	@Test
	public void countAllByTitleLikeShouldWork() {
		assertThat(
			filmRepository.countAllByTitleLike("A%"), is(46L));
	}
}

@@ -1032,16 +1032,20 @@
 %0A%09%09try (
+%0A%09%09%09
 Stream%3CF
@@ -1060,24 +1060,29 @@
 y%3E stream = 
+%0A%09%09%09%09
 filmReposito
@@ -1093,16 +1093,19 @@
 indAll()
+%0A%09%09
 ) %7B%0A%09%09%09s
@@ -1135,16 +1135,21 @@
 etTitle)
+%0A%09%09%09%09
 .forEach
@@ -1256,16 +1256,21 @@
 pository
+%0A%09%09%09%09
 .countAl
@@ -1289,16 +1289,20 @@
 (%22A%25%22), 
+%0A%09%09%09
 is(46L))

Improve formatting