diff --git a/build.gradle b/build.gradle index 81f5bb27..e1d8bd56 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,6 @@ apply plugin: 'nebula.source-jar' apply plugin: 'nebula.javadoc-jar' group = 'ru.alfabank.tests' -version = '3.5.2' description = """light testing framework Akita""" @@ -130,7 +129,7 @@ bintray { test { maxParallelForks = 1 - ignoreFailures = true + ignoreFailures = false jvmArgs += "-Dfile.encoding=UTF-8" jvmArgs += "-Dbrowser=chrome" diff --git a/src/main/java/ru/alfabank/alfatest/cucumber/api/Pages.java b/src/main/java/ru/alfabank/alfatest/cucumber/api/Pages.java index e2fc1755..4046259c 100644 --- a/src/main/java/ru/alfabank/alfatest/cucumber/api/Pages.java +++ b/src/main/java/ru/alfabank/alfatest/cucumber/api/Pages.java @@ -1,12 +1,12 @@ /** * Copyright 2017 Alfa Laboratory - *

+ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ * * http://www.apache.org/licenses/LICENSE-2.0 - *

+ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,7 +15,6 @@ */ package ru.alfabank.alfatest.cucumber.api; -import com.codeborne.selenide.ElementsContainer; import com.codeborne.selenide.Selenide; import com.google.common.collect.Maps; import lombok.SneakyThrows; @@ -74,18 +73,18 @@ public static void withPage(Class clazz, boolean checkI * Получение страницы из "pages" по имени */ public AkitaPage get(String pageName) { - return Selenide.page(getPageMapInstanceInternal().get(pageName)).initialize(); + return Selenide.page(getPageFromPagesByName(pageName)).initialize(); } /** * Получение страницы по классу */ @SuppressWarnings("unchecked") - public T get(Class clazz, String name) { - AkitaPage page = Selenide.page(getPageMapInstanceInternal().get(name)).initialize(); + public T get(Class clazz, String pageName) { + AkitaPage page = Selenide.page(Selenide.page(getPageFromPagesByName(pageName))).initialize(); if (!clazz.isInstance(page)) { - throw new IllegalStateException(name + " page is not a instance of " + clazz + ". Named page is a " + page); + throw new IllegalStateException(pageName + " page is not a instance of " + clazz + ". Named page is a " + page); } return (T) page; } @@ -94,6 +93,13 @@ private Map getPageMapInstanceInternal() { return pages; } + private AkitaPage getPageFromPagesByName(String pageName) throws IllegalArgumentException { + AkitaPage page = getPageMapInstanceInternal().get(pageName); + if (page == null) + throw new IllegalArgumentException(pageName + " page is not declared in a list of available pages"); + return page; + } + /** * Добавление инстанциированной страницы в "pages" с проверкой на NULL */ diff --git a/src/main/java/ru/alfabank/tests/core/helpers/PropertyLoader.java b/src/main/java/ru/alfabank/tests/core/helpers/PropertyLoader.java index edcdc8bd..e09f6036 100644 --- a/src/main/java/ru/alfabank/tests/core/helpers/PropertyLoader.java +++ b/src/main/java/ru/alfabank/tests/core/helpers/PropertyLoader.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package ru.alfabank.tests.core.helpers; import com.google.common.base.Strings; diff --git a/src/test/java/ru/alfabank/other/AkitaScenarioTest.java b/src/test/java/ru/alfabank/other/AkitaScenarioTest.java index 4c009ace..ac54c1b9 100644 --- a/src/test/java/ru/alfabank/other/AkitaScenarioTest.java +++ b/src/test/java/ru/alfabank/other/AkitaScenarioTest.java @@ -50,7 +50,6 @@ public void prepare() { Scenario scenario = new StubScenario(); AkitaPage akitaPageMock = mock(AkitaPage.class); akitaScenario.setEnvironment(new AkitaEnvironment(scenario)); - akitaScenario.getPages().put("Title", akitaPageMock); } @Test(expected = IllegalArgumentException.class) diff --git a/src/test/java/ru/alfabank/other/PagesTest.java b/src/test/java/ru/alfabank/other/PagesTest.java index 6f8e2d9f..060fdf21 100644 --- a/src/test/java/ru/alfabank/other/PagesTest.java +++ b/src/test/java/ru/alfabank/other/PagesTest.java @@ -74,8 +74,8 @@ public void putNegative() { pages.put("Test", nullPage); } - @Test + @Test(expected = IllegalArgumentException.class) public void getNegative() { - assertThat(pages.get("WRONG_KEY"), is(nullValue())); + pages.get("WRONG_KEY_TO_GET_PAGE"); } } diff --git a/src/test/java/ru/alfabank/steps/ApiStepsTest.java b/src/test/java/ru/alfabank/steps/ApiStepsTest.java index a079d8e8..8dcaf9d7 100644 --- a/src/test/java/ru/alfabank/steps/ApiStepsTest.java +++ b/src/test/java/ru/alfabank/steps/ApiStepsTest.java @@ -118,18 +118,18 @@ public void sendHttpRequestFromFileWithVarsPost() throws java.lang.Exception { String bodyFileName = "/src/test/resources/bodyWithParams.json"; stubFor(post(urlEqualTo("/post/resource")) - .withRequestBody(WireMock.equalTo(body)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBody("TEST_BODY"))); + .withRequestBody(WireMock.equalTo(body)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody("TEST_BODY"))); List params = Collections.singletonList( - RequestParam.builder() - .name("body") - .type(RequestParamType.BODY) - .value(bodyFileName) - .build()); + RequestParam.builder() + .name("body") + .type(RequestParamType.BODY) + .value(bodyFileName) + .build()); api.sendHttpRequestSaveResponse("POST", "/post/resource", "RESPONSE_POST_BODY", params); assertThat(akitaScenario.getVar("RESPONSE_POST_BODY"), equalTo("TEST_BODY")); }