From 4ab49ce2f9bc0a026b449bffc9aa2a6c8b848a36 Mon Sep 17 00:00:00 2001 From: CodingPF Date: Thu, 2 May 2024 23:43:55 +0200 Subject: [PATCH] little helper to create/validate testcases --- .../mserver/testhelper/AssertFilm.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/de/mediathekview/mserver/testhelper/AssertFilm.java b/src/test/java/de/mediathekview/mserver/testhelper/AssertFilm.java index 95cac0e12..e285fb246 100644 --- a/src/test/java/de/mediathekview/mserver/testhelper/AssertFilm.java +++ b/src/test/java/de/mediathekview/mserver/testhelper/AssertFilm.java @@ -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"); @@ -167,4 +194,5 @@ private static void assertSignLanguages( assertUrl(aExpectedUrlSignLanguageNormal, aActualFilm.getSignLanguage(Resolution.NORMAL)); assertUrl(aExpectedUrlSignLanguageHd, aActualFilm.getSignLanguage(Resolution.HD)); } + }