Skip to content

Commit

Permalink
little helper to create/validate testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
codingPF committed May 2, 2024
1 parent 807fc64 commit 4ab49ce
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/java/de/mediathekview/mserver/testhelper/AssertFilm.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,33 @@ public static void assertUrl(final String aExpectedUrl, final FilmUrl aActualUrl
equalTo(cleanupWireMockUrlForCheck(aExpectedUrl)));
}
}

// generate a test case constructor from a film
public static String toTestCase(final String fileNameAndPath, final Film f) {
String x = ("" +
"/*jsonFile*/ \""+fileNameAndPath+"\"" + ",\n" +
"/*topic*/ \""+ f.getThema()+"\"" + ",\n" +
"/*title*/ \""+ f.getTitel()+"\"" + ",\n" +
"/*description*/ \""+ f.getBeschreibung()+"\"" + ",\n" +
"/*date*/ LocalDateTime.parse(\""+ f.getTime().toString()+"\")" + ",\n" +
"/*duration*/ Duration.parse(\""+ f.getDuration().toString()+"\")" + ",\n" +
"/*small*/ \""+ f.getUrl(Resolution.SMALL)+"\"" + ",\n" +
"/*normal*/ \""+ f.getUrl(Resolution.NORMAL)+"\"" + ",\n" +
"/*hd*/ \""+ f.getUrl(Resolution.HD)+"\"" + ",\n" +
"/*ADsmall*/ \""+ (f.getAudioDescription(Resolution.SMALL) != null ? f.getAudioDescription(Resolution.SMALL) : "") +"\"" + ",\n" +
"/*ADnormal*/ \""+ (f.getAudioDescription(Resolution.NORMAL) != null ? f.getAudioDescription(Resolution.NORMAL) : "")+"\"" + ",\n" +
"/*ADhd*/ \""+ (f.getAudioDescription(Resolution.HD) != null ? f.getAudioDescription(Resolution.HD) : "")+"\"" + ",\n" +
"/*DGSsmall*/ \""+ (f.getSignLanguage(Resolution.SMALL) != null ? f.getSignLanguage(Resolution.SMALL) : "") +"\"" + ",\n" +
"/*DGSnormal*/ \""+ (f.getSignLanguage(Resolution.NORMAL) != null ? f.getSignLanguage(Resolution.NORMAL) : "")+"\"" + ",\n" +
"/*DGShd*/ \""+ (f.getSignLanguage(Resolution.HD) != null ? f.getSignLanguage(Resolution.HD) : "")+"\"" + ",\n" +
"/*sub*/ \""+ (f.getSubtitles().parallelStream().findFirst().isPresent() ? f.getSubtitles().parallelStream().findFirst().get().toString(): "")+"\"" + ",\n" +
"/*website*/ \""+ (f.getWebsite().isPresent() ? f.getWebsite().get().toString() : "")+"\"" + ",\n" +
"/*hd*/ GeoLocations."+ f.getGeoLocations().toString() + ",\n" +
"/*related*/ new ArdFilmInfoDto[0]" + ",\n" +
"/*sender*/ Optional.of(Sender."+f.getSender()+")" + ",\n" +
"");
return x;
}

private static String cleanupWireMockUrlForCheck(final String urlToCleanUp) {
return urlToCleanUp.replaceAll("localhost:\\d+", "localhost:8589");
Expand Down Expand Up @@ -167,4 +194,5 @@ private static void assertSignLanguages(
assertUrl(aExpectedUrlSignLanguageNormal, aActualFilm.getSignLanguage(Resolution.NORMAL));
assertUrl(aExpectedUrlSignLanguageHd, aActualFilm.getSignLanguage(Resolution.HD));
}

}

0 comments on commit 4ab49ce

Please sign in to comment.