@Test(expected = FileNotFoundException.class) public void shouldThrowFileNotFoundExceptionWhenConfigFileIsNotFound() throws FileNotFoundException { JobConfig.readConfig("someWorkingDir", "nonexisting.json"); //assert that FileNotFoundException is thrown (see expected above) }
@Test public void shouldReadMinimalConfigAndInsertDefaults() throws FileNotFoundException { JobConfig jobConfig = JobConfig.readConfig("src/test/resources/", "lineup_minimal_test.json"); assertThat(jobConfig.browser.isPhantomJS(), is(true)); assertThat(jobConfig.windowHeight, is(800)); assertThat(jobConfig.urls.get("https://www.otto.de").windowWidths, is(ImmutableList.of(800))); assertThat(jobConfig.urls.get("https://www.otto.de").paths, is(ImmutableList.of(""))); assertThat(jobConfig.globalWaitAfterPageLoad, is(0F)); assertThat(jobConfig.pageLoadTimeout, is(120)); assertThat(jobConfig.screenshotRetries, is(0)); }
@Test public void shouldReadConfigAndParsedWithJackson() throws IOException { JobConfig jobConfigGson = JobConfig.readConfig("src/test/resources/", "lineup_test.json"); JobConfig jobConfigJackson = new ObjectMapper() .readValue(new File("src/test/resources/lineup_test.json"), JobConfig.class); Assert.assertEquals(jobConfigGson, jobConfigJackson); }
@Test public void shouldReadConfigFromDifferentPathThanWorkingDir() throws FileNotFoundException { JobConfig jobConfig = JobConfig.readConfig("someWorkingDir", "src/test/resources/lineup_test.json"); assertThatConfigContentsAreCorrect(jobConfig); }
@Test public void shouldReadConfig() throws FileNotFoundException { JobConfig jobConfig = JobConfig.readConfig("src/test/resources/", "lineup_test.json"); assertThatConfigContentsAreCorrect(jobConfig); }
@Test public void shouldGenerateScreenshotsParameters() throws FileNotFoundException, JLineupException { //given JobConfig jobConfig = JobConfig.readConfig(".", "src/test/resources/lineup_test.json"); RunStepConfig runStepConfig = jLineupRunConfigurationBuilder() .withWorkingDirectory("some/working/dir") .withScreenshotsDirectory("screenshots") .withUrlReplacements(ImmutableMap.of("google", "doodle")) .withStep(Step.before) .build(); UrlConfig expectedUrlConfigForOttoDe = getExpectedUrlConfigForOttoDe(); UrlConfig expectedUrlConfigForGoogleDe = getExpectedUrlConfigForGoogleDe(); final List<ScreenshotContext> expectedScreenshotContextList = ImmutableList.of( ScreenshotContext.of("https://www.otto.de", "/", 600, true, expectedUrlConfigForOttoDe), ScreenshotContext.of("https://www.otto.de", "/", 800, true, expectedUrlConfigForOttoDe), ScreenshotContext.of("https://www.otto.de", "/", 1200, true, expectedUrlConfigForOttoDe), ScreenshotContext.of("https://www.otto.de", "multimedia", 600, true, expectedUrlConfigForOttoDe), ScreenshotContext.of("https://www.otto.de", "multimedia", 800, true, expectedUrlConfigForOttoDe), ScreenshotContext.of("https://www.otto.de", "multimedia", 1200, true, expectedUrlConfigForOttoDe), ScreenshotContext.of("http://www.doodle.de", "/", 1200, true, expectedUrlConfigForGoogleDe) ); //when final List<ScreenshotContext> screenshotContextList = BrowserUtils.buildScreenshotContextListFromConfigAndState(runStepConfig, jobConfig); //then assertThat(screenshotContextList, containsInAnyOrder(expectedScreenshotContextList.toArray())); }