import static java.time.LocalDateTime.of;
import static java.util.Optional.empty;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.*;
import static org.jsoup.Jsoup.parse;
/**
public void moviesAreLocated() throws IOException {
assertThat(movies, containsInAnyOrder(
movie("All of Us Strangers", "https://cdn.premiumkino.de/movie/2809/db0e5c3ed02ba7fe4afa3b12aabb611f.jpg",
+ allOf(startsWith("Sich neu verlieben, durch eine Zeitschleife"), endsWith("Quelle: disney-content.de")),
performance(of(2024, 2, 9, 16, 15), "2D OV", "https://savoy.premiumkino.de/vorstellung/all-of-us-strangers/20240209/1615/HkKdhlHMvtfSMy1fqYYtYuVdgGIKtnT7i7ddY5jzRfY~"),
performance(of(2024, 2, 10, 22, 15), "2D OV", "https://savoy.premiumkino.de/vorstellung/all-of-us-strangers/20240210/2215/znWqm8FQUNSbrODY_A0jw8Au2nW6uSqbFE7Co8UgQv0~"),
performance(of(2024, 2, 11, 20, 15), "2D OV", "https://savoy.premiumkino.de/vorstellung/all-of-us-strangers/20240211/2015/I642oTHBKpy7sz2RULHIQK6cykSCPi57_c0TApiKbUk~"),
performance(of(2024, 2, 14, 14, 30), "2D OV", "https://savoy.premiumkino.de/vorstellung/all-of-us-strangers/20240214/1430/VZhgxh4PZutWWlLPEAe9dfOUJkB3sLnXzWoduICJYTk~")
),
movie("Dune", "https://cdn.premiumkino.de/movie/3261/bcc70cb1cc4559731b6fd547d0f5cee1.jpg",
+ allOf(startsWith(""Dune" erzählt die packende Geschichte"), endsWith("Quelle: mediapass.warnerbros.com")),
performance(of(2024, 2, 9, 19, 0), "2D OV", "https://savoy.premiumkino.de/vorstellung/dune/20240209/1900/o9jDuan4yyxaW7-Jg3hCJpiAM4CLZei8J2IX-O5-hA0~"),
performance(of(2024, 2, 10, 15, 30), "2D OV", "https://savoy.premiumkino.de/vorstellung/dune/20240210/1530/jXbZnYD8R5djVnj3Ojjcsc9qdSJ0JBMVhn7PeP88HyY~"),
performance(of(2024, 2, 11, 13, 30), "2D OV", "https://savoy.premiumkino.de/vorstellung/dune/20240211/1330/aJmlM8wOaGl_jtuWDvWG9TF7RR1zRpNrSZeArCBhn90~"),
performance(of(2024, 2, 13, 17, 0), "2D OV", "https://savoy.premiumkino.de/vorstellung/dune/20240213/1700/QCphOtH-WrZ2tRbENwaxXPskrN2gH3I8dHR0Y5L3l0Y~")
),
movie("SAVOY Sneak-Preview", "https://cdn.premiumkino.de/movie/5617/33dc4c74b4cca5cf4585b4cadfc38ec4.png",
+ allOf(startsWith("Wir zeigen unsere OV-Sneak freitagabends"), endsWith("Logenpreis 1,- Euro Ermäßigung. ")),
performance(of(2024, 2, 9, 22, 30), "2D OV", "https://savoy.premiumkino.de/vorstellung/sneak-preview/20240209/2230/GtYBcOR_Jy7a8xDxwwPHI0wfY_v_Ep2P6rV0w4wJ7SM~"),
performance(of(2024, 2, 16, 22, 0), "2D OV", "https://savoy.premiumkino.de/vorstellung/sneak-preview/20240216/2200/ZRC7iir9Hu8nIpH1PsiA_UDvckcj7yGqgMEYXHAs9Qw~")
),
@SafeVarargs
private Matcher<Movie> movie(String name, String imageUrl, Triple<LocalDateTime, String, String>... presentationTimesTypesAndLinks) {
+ return movie(name, imageUrl, anything(), presentationTimesTypesAndLinks);
+ }
+
+ @SafeVarargs
+ private Matcher<Movie> movie(String name, String imageUrl, Matcher<? super String> descriptionMatcher, Triple<LocalDateTime, String, String>... presentationTimesTypesAndLinks) {
return new TypeSafeDiagnosingMatcher<Movie>() {
@Override
protected boolean matchesSafely(Movie movie, Description mismatchDescription) {
mismatchDescription.appendText("image URL is ").appendValue(movie.getImageUrl());
return false;
}
+ if (!descriptionMatcher.matches(movie.getDescription())) {
+ descriptionMatcher.describeMismatch(movie.getDescription(), mismatchDescription);
+ return false;
+ }
List<Performance> performances = new ArrayList<>(movie.getPerformances());
if (performances.size() != presentationTimesTypesAndLinks.length) {
mismatchDescription.appendText("has ").appendValue(performances.size()).appendText(" presentations");
@Override
public void describeTo(Description description) {
description.appendText("movie with name ").appendValue(name);
+ description.appendText(", description ").appendDescriptionOf(descriptionMatcher);
description.appendText(" and ").appendValue(presentationTimesTypesAndLinks.length).appendText(" presentations");
}
};