Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.rostelecom.eip2.steps.cms.service.type;
- import io.qameta.allure.Allure;
- import io.qameta.allure.Step;
- import io.restassured.response.ExtractableResponse;
- import io.restassured.response.Response;
- import org.assertj.core.api.SoftAssertions;
- import ru.rostelecom.database.entities.dto.cmsdwh.CmsServiceDb;
- import ru.rostelecom.model.CmsService;
- import static ru.rostelecom.execution.jira.Watcher.TEST_STEP_MARKER;
- public class CmsServiceTypeAssertionStep {
- @Step("Сверка ответа метода с данными полученными из БД" + TEST_STEP_MARKER)
- public static void checkCmsServiceStep(String testCaseKey, Integer stepNumber, CmsService r, CmsServiceDb db) {
- SoftAssertions softy = new SoftAssertions();
- softy.assertThat(r.getId().getLocalSystemId()).as("ID.LOCALSYSTEMID").isEqualTo(db.getLocalSystemId());
- softy.assertThat(r.getId().getAppPkid()).as("ID.APP_PKID").isEqualTo(db.getAppPkid());
- softy.assertThat(r.getId().getVersion()).as("ID.VERSION").isEqualTo(db.getVersion());
- softy.assertThat(r.getApplicationName()).as("APPLICATIONNAME").isEqualTo(db.getApplicationName());
- softy.assertThat(r.getDeleted().compareTo(false)).as("DELETED").isEqualTo(db.getDeleted());
- softy.assertThat(r.getForm()).as("FORM").isEqualTo(db.getForm());
- softy.assertThat(r.getOrderId().getLocalSystemId()).as("ORDERCMS.LOCALSYSTEMID").isEqualTo(db.getOrderCmsLocalsystemid());
- softy.assertThat(r.getOrderId().getAppPkid()).as("ORDERCMS.APP_PKID").isEqualTo(db.getOrderCmsAppPkid());
- softy.assertThat(r.getOrderId().getVersion()).as("ORDERCMS.VERSION").isEqualTo(db.getOrderCmsVersion());
- softy.assertThat(r.getStatusId().getLocalSystemId()).as("STATUS.LOCALSYSTEMID").isEqualTo(db.getStatusLocalSystemId());
- softy.assertThat(r.getStatusId().getAppPkid()).as("STATUS.APP_PKID").isEqualTo(db.getStatusAppPkid());
- softy.assertThat(r.getStatusId().getVersion()).as("STATUS.VERSION").isEqualTo(db.getStatusVersion());
- softy.assertThat(r.getSaveOptions()).as("SAVEOPTIONS").isEqualTo(db.getSaveOptions());
- softy.assertThat(r.getFldFields().getFldservicetype()).as("FLD.SERVICETYPE").isEqualTo(db.getFldServiceType());
- softy.assertThat(r.getFldFields().getFldwfstatusalias()).as("FLD.STATUSALIAS").isEqualTo(db.getFldWfStatusAlias());
- softy.assertAll();
- }
- @Step("Проверка корректности сообщения об ошибке (невалидный localsystemid)"+ TEST_STEP_MARKER)
- public static void checkErrorDataNotFound(String testCaseKey, Integer stepNumber, ExtractableResponse<Response> resp) {
- Allure.addAttachment("ответ", "text/json", resp.body().asString());
- SoftAssertions softy = new SoftAssertions();
- softy.assertThat(resp.response().statusCode())
- .as("статус код при ошибке DATA NOT FOUND должен быть 474")
- .isEqualTo(474);
- softy.assertThat(resp.response().getBody().jsonPath().getString("code"))
- .as("сообщение в блоке \"code\" ошибки должно быть - DATA_NOT_FOUND")
- .isEqualTo("DATA_NOT_FOUND");
- softy.assertThat(resp.response().getBody().jsonPath().getString("message"))
- .as("блок \"message\" должен быть вида:\n" +
- "\"DATA_NOT_FOUND: ServicePort for localSystemId = <localsystemid>, type = <servicetype> not found\"")
- .isEqualTo("DATA_NOT_FOUND: ServicePort for localSystemId = 'bla-bla-bla', type = 'LAST_MILE' not found");
- softy.assertThat(resp.response().getBody().jsonPath().getString("source"))
- .as("блок \"source\" должен указывать на модуль к которому обращается метод")
- .isEqualTo("dwh-cms-adapter-2.14.0");
- softy.assertAll();
- }
- @Step("Проверка корректности сообщения об ошибке (невалидный serviceType)"+ TEST_STEP_MARKER)
- public static void checkErrorBadRequest(String testCaseKey, Integer stepNumber, ExtractableResponse<Response> resp) {
- Allure.addAttachment("ответ", "text/json", resp.body().asString());
- SoftAssertions softy = new SoftAssertions();
- softy.assertThat(resp.response().statusCode())
- .as("статус код при ошибке Bad Request должен быть 400")
- .isEqualTo(400);
- softy.assertThat(resp.response().getBody().jsonPath().getString("status")).isEqualTo("400");
- softy.assertThat(resp.response().getBody().jsonPath().getString("error")).isEqualTo("Bad Request");
- softy.assertThat(resp.response().getBody().jsonPath().getString("path")).isEqualTo("/FWS/eip-canonical-service-rest/service/cms/VERY_LAST_MILE/0000A62178A292EB432582F200371B8C");
- softy.assertThat(resp.response().getBody().jsonPath().getString("message"))
- .as("в блоке \"message\" описывается что переданный сервис тайп не найден в enum обработчика")
- .isEqualTo("Failed to convert value of type 'java.lang.String' to required type 'ru.rt.eip.customerservice.domain.enums.ServiceType'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.PathVariable ru.rt.eip.customerservice.domain.enums.ServiceType] for value 'VERY_LAST_MILE'; nested exception is java.lang.IllegalArgumentException: No enum constant ru.rt.eip.customerservice.domain.enums.ServiceType.VERY_LAST_MILE");
- softy.assertAll();
- }
- @Step("Проверка корректности сообщения об ошибке (не переданы параметры)" + TEST_STEP_MARKER)
- public static void checkErrorNotFound(String testCaseKey, Integer stepNumber, ExtractableResponse<Response> resp) {
- Allure.addAttachment("ответ", "text/json", resp.body().asString());
- SoftAssertions softy = new SoftAssertions();
- softy.assertThat(resp.response().statusCode()).isEqualTo(404);
- softy.assertThat(resp.response().getBody().jsonPath().getString("status")).isEqualTo("404");
- softy.assertThat(resp.response().getBody().jsonPath().getString("error")).isEqualTo("Not Found");
- softy.assertThat(resp.response().getBody().jsonPath().getString("message")).isEqualTo("No message available");
- softy.assertThat(resp.response().getBody().jsonPath().getString("path")).isEqualTo("/FWS/eip-canonical-service-rest/service/cms/");
- softy.assertAll();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement