Repository: provectus/kafka-ui
Issue: [e2e] get rid of SheakyThrows annotation
Labels: scope/QA
type/refactoring
status/accepted

in the scope of this issue need to remove annotation from the high-level methods and implement exception handling on the lowest level

Issue comments:

Pull request review comments:
no need to place here Objects.requireNonNull because getResourceAsString() doesn't have return null option now
no need to place here Objects.requireNonNull because getResourceAsString() doesn't have return null option now
please use import static FileUtils.* to reduce mentions the same class many times per method
use import static pls
Reverted them 
Reverted
Done it 
Done it 

do we really need () here?
Done 

Patch that resolved the issue:
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/extensions/FileUtils.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/extensions/FileUtils.java
index 22926226403..bbe4dbf0b4d 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/extensions/FileUtils.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/extensions/FileUtils.java
@@ -5,11 +5,23 @@
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 
+import static org.apache.kafka.common.utils.Utils.readFileAsString;
 
 public class FileUtils {
 
-    public static String getResourceAsString(String resourceFileName) throws IOException {
-        return IOUtils.resourceToString("/" + resourceFileName, StandardCharsets.UTF_8);
+    public static String getResourceAsString(String resourceFileName) {
+        try {
+            return IOUtils.resourceToString("/" + resourceFileName, StandardCharsets.UTF_8);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
+    public static String fileToString(String path) {
+        try {
+            return readFileAsString(path);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
 }
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/MainPage.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/MainPage.java
index 515ab60ffee..cfc15f105ec 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/MainPage.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/MainPage.java
@@ -3,11 +3,10 @@
 import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.Selenide;
 import com.codeborne.selenide.SelenideElement;
-import com.provectus.kafka.ui.helpers.TestConfiguration;
 import com.provectus.kafka.ui.extensions.WaitUtils;
+import com.provectus.kafka.ui.helpers.TestConfiguration;
 import com.provectus.kafka.ui.pages.topic.TopicsList;
 import io.qameta.allure.Step;
-import lombok.SneakyThrows;
 import lombok.experimental.ExtensionMethod;
 import org.openqa.selenium.By;
 
@@ -32,7 +31,6 @@ public MainPage waitUntilScreenReady() {
         return this;
     }
 
-    @SneakyThrows
     @Step
     public void topicIsVisible(String topicName) {
         new TopicsList().isTopicVisible(topicName);
@@ -43,18 +41,18 @@ public void topicIsNotVisible(String topicName){
     }
 
 
-  public enum SideMenuOptions {
-    BROKERS("Brokers"),
-    TOPICS("Topics"),
-    CONSUMERS("Consumers"),
-    SCHEMA_REGISTRY("Schema Registry");
+    public enum SideMenuOptions {
+        BROKERS("Brokers"),
+        TOPICS("Topics"),
+        CONSUMERS("Consumers"),
+        SCHEMA_REGISTRY("Schema Registry");
 
-    final String value;
+        final String value;
 
-    SideMenuOptions(String value) {
-      this.value = value;
+        SideMenuOptions(String value) {
+            this.value = value;
+        }
     }
-  }
 
 
 
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorCreateView.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorCreateView.java
index 69f67a9a4af..a12aca59170 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorCreateView.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorCreateView.java
@@ -2,15 +2,15 @@
 
 import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.SelenideElement;
-import com.provectus.kafka.ui.utils.BrowserUtils;
 import com.provectus.kafka.ui.extensions.WaitUtils;
+import com.provectus.kafka.ui.utils.BrowserUtils;
 import io.qameta.allure.Step;
 import lombok.experimental.ExtensionMethod;
 import org.openqa.selenium.By;
 
 import static com.codeborne.selenide.Selenide.$;
+import static com.codeborne.selenide.Selenide.sleep;
 import static com.provectus.kafka.ui.screenshots.Screenshooter.log;
-import static java.lang.Thread.sleep;
 
 @ExtensionMethod(WaitUtils.class)
 public class ConnectorCreateView {
@@ -22,7 +22,7 @@ public class ConnectorCreateView {
     private static final String path = "/ui/clusters/secondLocal/connectors/create_new";
 
     @Step("Set connector config JSON")
-    public ConnectorsView setConnectorConfig(String connectName, String configJson) throws InterruptedException {
+    public ConnectorsView setConnectorConfig(String connectName, String configJson) {
         nameField.setValue(connectName);
         $("#config").click();
         contentTextArea.setValue("");
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorsList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorsList.java
index 659a87da2c8..f79f2327765 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorsList.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/connector/ConnectorsList.java
@@ -2,11 +2,10 @@
 
 import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.Selenide;
+import com.provectus.kafka.ui.extensions.WaitUtils;
 import com.provectus.kafka.ui.helpers.TestConfiguration;
 import com.provectus.kafka.ui.utils.BrowserUtils;
-import com.provectus.kafka.ui.extensions.WaitUtils;
 import io.qameta.allure.Step;
-import lombok.SneakyThrows;
 import lombok.experimental.ExtensionMethod;
 import org.openqa.selenium.By;
 
@@ -35,14 +34,14 @@ public ConnectorCreateView clickCreateConnectorButton() {
         return new ConnectorCreateView();
     }
 
-    @SneakyThrows
+
     @Step
     public ConnectorsList openConnector(String connectorName) {
         $(By.linkText(connectorName)).click();
         return this;
     }
 
-    @SneakyThrows
+
     @Step
     public ConnectorsList isNotVisible(String connectorName) {
         $(By.xpath("//table")).shouldBe(Condition.visible);
@@ -52,8 +51,8 @@ public ConnectorsList isNotVisible(String connectorName) {
 
     @Step("Verify that connector {connectorName} is visible in the list")
     public ConnectorsList connectorIsVisibleInList(String connectorName, String topicName) {
-        $x("//table//a[@href='/ui/clusters/local/connects/first/connectors/" + connectorName +"']").shouldBe(Condition.visible);
-       $$(By.linkText(topicName));
+        $x("//table//a[@href='/ui/clusters/local/connects/first/connectors/" + connectorName + "']").shouldBe(Condition.visible);
+        $$(By.linkText(topicName));
         return this;
     }
     @Step
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaRegistryList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaRegistryList.java
index 34ee71c7ffc..a9cc45d92c9 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaRegistryList.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/schema/SchemaRegistryList.java
@@ -4,7 +4,6 @@
 import com.codeborne.selenide.SelenideElement;
 import com.provectus.kafka.ui.utils.BrowserUtils;
 import io.qameta.allure.Step;
-import lombok.SneakyThrows;
 import org.openqa.selenium.By;
 
 import static com.codeborne.selenide.Selenide.*;
@@ -23,10 +22,9 @@ public SchemaView openSchema(String schemaName) {
         return new SchemaView();
     }
 
-    @SneakyThrows
     @Step
     public SchemaRegistryList isNotVisible(String schemaName) {
-        $x(String.format("//*[contains(text(),'%s')]",schemaName)).shouldNotBe(Condition.visible);
+        $x(String.format("//*[contains(text(),'%s')]", schemaName)).shouldNotBe(Condition.visible);
         return this;
     }
 
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicView.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicView.java
index c3607fceab4..7eccf23fe21 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicView.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicView.java
@@ -3,12 +3,11 @@
 import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.Selenide;
 import com.codeborne.selenide.SelenideElement;
-import com.provectus.kafka.ui.helpers.TestConfiguration;
 import com.provectus.kafka.ui.extensions.WaitUtils;
+import com.provectus.kafka.ui.helpers.TestConfiguration;
 import com.provectus.kafka.ui.pages.ProduceMessagePage;
 import com.provectus.kafka.ui.utils.BrowserUtils;
 import io.qameta.allure.Step;
-import lombok.SneakyThrows;
 import lombok.experimental.ExtensionMethod;
 import org.openqa.selenium.By;
 
@@ -34,7 +33,6 @@ public TopicView waitUntilScreenReady() {
         return this;
     }
 
-    @SneakyThrows
     @Step
     public TopicCreateEditSettingsView openEditSettings() {
         BrowserUtils.javaExecutorClick(dotMenuHeader);
@@ -48,7 +46,6 @@ public TopicView openTopicMenu(TopicMenu menu) {
         return this;
     }
 
-    @SneakyThrows
     @Step
     public TopicsList deleteTopic() {
         BrowserUtils.javaExecutorClick(dotMenuHeader);
@@ -57,7 +54,6 @@ public TopicsList deleteTopic() {
         return new TopicsList();
     }
 
-    @SneakyThrows
     @Step
     public ProduceMessagePage clickOnButton(String buttonName) {
         BrowserUtils.javaExecutorClick($(By.xpath(String.format("//div//button[text()='%s']", buttonName))));
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
index c39a3ca1b96..bbcb67effb0 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java
@@ -3,11 +3,10 @@
 import com.codeborne.selenide.CollectionCondition;
 import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.Selenide;
-import com.provectus.kafka.ui.helpers.TestConfiguration;
 import com.provectus.kafka.ui.extensions.WaitUtils;
+import com.provectus.kafka.ui.helpers.TestConfiguration;
 import com.provectus.kafka.ui.utils.BrowserUtils;
 import io.qameta.allure.Step;
-import lombok.SneakyThrows;
 import lombok.experimental.ExtensionMethod;
 import org.openqa.selenium.By;
 
@@ -32,7 +31,7 @@ public TopicsList waitUntilScreenReady() {
     }
 
     @Step
-    public TopicCreateEditSettingsView pressCreateNewTopic(){
+    public TopicCreateEditSettingsView pressCreateNewTopic() {
         BrowserUtils.javaExecutorClick($x("//button[normalize-space(text()) ='Add a Topic']"));
         return new TopicCreateEditSettingsView();
     }
@@ -46,14 +45,12 @@ public TopicsList isTopicVisible(String topicName) {
         return this;
     }
 
-    @SneakyThrows
     @Step
     public TopicView openTopic(String topicName) {
         $(By.linkText(topicName)).click();
         return new TopicView();
     }
 
-    @SneakyThrows
     @Step
     public TopicsList isTopicNotVisible(String topicName) {
         $$x("//table/tbody/tr/td[2]")
diff --git a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/screenshots/Screenshooter.java b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/screenshots/Screenshooter.java
index 66b016ba85e..d412050b299 100644
--- a/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/screenshots/Screenshooter.java
+++ b/kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/screenshots/Screenshooter.java
@@ -16,6 +16,7 @@
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
 import java.nio.file.FileSystems;
 import java.util.List;
 
@@ -23,131 +24,139 @@
 
 public class Screenshooter {
 
-  public static  Logger log = LoggerFactory.getLogger(Screenshooter.class);
-
-  private static final int PIXELS_THRESHOLD =
-      Integer.parseInt(System.getProperty("PIXELS_THRESHOLD", "200"));
-  private static final String SCREENSHOTS_FOLDER =
-      System.getProperty("SCREENSHOTS_FOLDER", "com/provectus/kafka/ui/screenshots/");
-  private static final String DIFF_SCREENSHOTS_FOLDER =
-      System.getProperty("DIFF_SCREENSHOTS_FOLDER", "build/__diff__/");
-  private static final String ACTUAL_SCREENSHOTS_FOLDER =
-      System.getProperty("ACTUAL_SCREENSHOTS_FOLDER", "build/__actual__/");
-  private static final boolean SHOULD_SAVE_SCREENSHOTS_IF_NOT_EXIST =
-      Boolean.parseBoolean(System.getProperty("SHOULD_SAVE_SCREENSHOTS_IF_NOT_EXIST", "true"));
-  private static final boolean TURN_OFF_SCREENSHOTS =
-      Boolean.parseBoolean(System.getProperty("TURN_OFF_SCREENSHOTS", "false"));
-  private static final boolean USE_LOCAL_BROWSER =
-          Boolean.parseBoolean(System.getProperty("USE_LOCAL_BROWSER", "false"));
-
-  private File newFile(String name) {
-    var file = new File(name);
-    if (!file.exists()) {
-      file.mkdirs();
+    public static Logger log = LoggerFactory.getLogger(Screenshooter.class);
+
+    private static final int PIXELS_THRESHOLD =
+            Integer.parseInt(System.getProperty("PIXELS_THRESHOLD", "200"));
+    private static final String SCREENSHOTS_FOLDER =
+            System.getProperty("SCREENSHOTS_FOLDER", "com/provectus/kafka/ui/screenshots/");
+    private static final String DIFF_SCREENSHOTS_FOLDER =
+            System.getProperty("DIFF_SCREENSHOTS_FOLDER", "build/__diff__/");
+    private static final String ACTUAL_SCREENSHOTS_FOLDER =
+            System.getProperty("ACTUAL_SCREENSHOTS_FOLDER", "build/__actual__/");
+    private static final boolean SHOULD_SAVE_SCREENSHOTS_IF_NOT_EXIST =
+            Boolean.parseBoolean(System.getProperty("SHOULD_SAVE_SCREENSHOTS_IF_NOT_EXIST", "true"));
+    private static final boolean TURN_OFF_SCREENSHOTS =
+            Boolean.parseBoolean(System.getProperty("TURN_OFF_SCREENSHOTS", "false"));
+    private static final boolean USE_LOCAL_BROWSER =
+            Boolean.parseBoolean(System.getProperty("USE_LOCAL_BROWSER", "false"));
+
+    private File newFile(String name) {
+        var file = new File(name);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        return file;
     }
-    return file;
-  }
-
-  public Screenshooter() {
-    List.of(SCREENSHOTS_FOLDER, DIFF_SCREENSHOTS_FOLDER, ACTUAL_SCREENSHOTS_FOLDER)
-        .forEach(this::newFile);
-  }
-
-  public void compareScreenshots(String name) {
-    compareScreenshots(name, false);
-  }
-
-  @SneakyThrows
-  public void compareScreenshots(String name, boolean shouldUpdateScreenshotIfDiffer) {
-    if (TURN_OFF_SCREENSHOTS || USE_LOCAL_BROWSER) {
-      log.warn(String.format("compareScreenshots turned off due TURN_OFF_SCREENSHOTS || USE_LOCAL_BROWSER: %b || %b"
-              , TURN_OFF_SCREENSHOTS,USE_LOCAL_BROWSER));
-      return;
+
+    public Screenshooter() {
+        List.of(SCREENSHOTS_FOLDER, DIFF_SCREENSHOTS_FOLDER, ACTUAL_SCREENSHOTS_FOLDER)
+                .forEach(this::newFile);
+    }
+
+    public void compareScreenshots(String name) {
+        compareScreenshots(name, false);
+    }
+
+
+    public void compareScreenshots(String name, boolean shouldUpdateScreenshotIfDiffer) {
+        if (TURN_OFF_SCREENSHOTS || USE_LOCAL_BROWSER) {
+            log.warn(String.format("compareScreenshots turned off due TURN_OFF_SCREENSHOTS || USE_LOCAL_BROWSER: %b || %b"
+                    , TURN_OFF_SCREENSHOTS, USE_LOCAL_BROWSER));
+            return;
+        }
+        if (!doesScreenshotExist(name)) {
+            if (SHOULD_SAVE_SCREENSHOTS_IF_NOT_EXIST) {
+                updateActualScreenshot(name);
+            } else {
+                try {
+                    throw new NoReferenceScreenshotFoundException(name);
+                } catch (NoReferenceScreenshotFoundException e) {
+                    e.printStackTrace();
+                }
+            }
+        } else {
+            makeImageDiff(name, shouldUpdateScreenshotIfDiffer);
+        }
+    }
+
+
+    private void updateActualScreenshot(String name) {
+        Screenshot actual =
+                new AShot().coordsProvider(new WebDriverCoordsProvider()).takeScreenshot(getWebDriver());
+        File file = newFile(SCREENSHOTS_FOLDER + name + ".png");
+        try {
+            ImageIO.write(actual.getImage(), "png", file);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        log.debug(String.format("created screenshot: %s \n at %s", name, file.getAbsolutePath()));
+    }
+
+    private static boolean doesScreenshotExist(String name) {
+        return new File(SCREENSHOTS_FOLDER + name + ".png").exists();
     }
-    if (!doesScreenshotExist(name)) {
-      if (SHOULD_SAVE_SCREENSHOTS_IF_NOT_EXIST) {
-        updateActualScreenshot(name);
-      } else {
-        throw new NoReferenceScreenshotFoundException(name);
-      }
-    } else {
-      makeImageDiff(name, shouldUpdateScreenshotIfDiffer);
+
+    @SneakyThrows
+    private void makeImageDiff(String expectedName, boolean shouldUpdateScreenshotIfDiffer) {
+        String fullPathNameExpected = SCREENSHOTS_FOLDER + expectedName + ".png";
+        String fullPathNameActual = ACTUAL_SCREENSHOTS_FOLDER + expectedName + ".png";
+        String fullPathNameDiff = DIFF_SCREENSHOTS_FOLDER + expectedName + ".png";
+
+        //  activating allure plugin for showing diffs in report
+        Allure.label("testType", "screenshotDiff");
+
+        Screenshot actual =
+                new AShot().coordsProvider(new WebDriverCoordsProvider()).takeScreenshot(getWebDriver());
+        ImageIO.write(actual.getImage(), "png", newFile(fullPathNameActual));
+
+        Screenshot expected = new Screenshot(ImageIO.read(newFile(fullPathNameExpected)));
+        ImageDiff diff = new ImageDiffer().makeDiff(actual, expected);
+        BufferedImage diffImage = diff.getMarkedImage();
+        ImageIO.write(diffImage, "png", newFile(fullPathNameDiff));
+        // adding to report
+        diff(fullPathNameDiff);
+        // adding to report
+        actual(fullPathNameActual);
+        // adding to report
+        expected(fullPathNameExpected);
+
+        if (shouldUpdateScreenshotIfDiffer) {
+            if (diff.getDiffSize() > PIXELS_THRESHOLD) {
+                updateActualScreenshot(expectedName);
+            }
+        } else {
+            Assertions.assertTrue(
+                    PIXELS_THRESHOLD >= diff.getDiffSize(),
+                    String.format("Amount of differing pixels should be less or equals than %s, actual %s\n" +
+                                    "diff file: %s",
+                            PIXELS_THRESHOLD, diff.getDiffSize(), FileSystems.getDefault().getPath(fullPathNameDiff).normalize().toAbsolutePath()));
+        }
+    }
+
+    @SneakyThrows
+    private byte[] imgToBytes(String filename) {
+        BufferedImage bImage2 = ImageIO.read(new File(filename));
+        var bos2 = new ByteArrayOutputStream();
+        ImageIO.write(bImage2, "png", bos2);
+        return bos2.toByteArray();
+    }
+
+
+    @Attachment
+    private byte[] actual(String actualFileName) {
+        return imgToBytes(actualFileName);
     }
-  }
-
-  @SneakyThrows
-  private void updateActualScreenshot(String name) {
-    Screenshot actual =
-        new AShot().coordsProvider(new WebDriverCoordsProvider()).takeScreenshot(getWebDriver());
-    File  file=  newFile(SCREENSHOTS_FOLDER + name + ".png");
-    ImageIO.write(actual.getImage(), "png", file);
-    log.debug(String.format("created screenshot: %s \n at %s", name, file.getAbsolutePath()));
-  }
-
-  private static boolean doesScreenshotExist(String name) {
-    return new File(SCREENSHOTS_FOLDER + name + ".png").exists();
-  }
-
-  @SneakyThrows
-  private void makeImageDiff(String expectedName, boolean shouldUpdateScreenshotIfDiffer) {
-    String fullPathNameExpected = SCREENSHOTS_FOLDER + expectedName + ".png";
-    String fullPathNameActual = ACTUAL_SCREENSHOTS_FOLDER + expectedName + ".png";
-    String fullPathNameDiff = DIFF_SCREENSHOTS_FOLDER + expectedName + ".png";
-
-    //  activating allure plugin for showing diffs in report
-    Allure.label("testType", "screenshotDiff");
-
-    Screenshot actual =
-        new AShot().coordsProvider(new WebDriverCoordsProvider()).takeScreenshot(getWebDriver());
-    ImageIO.write(actual.getImage(), "png", newFile(fullPathNameActual));
-
-    Screenshot expected = new Screenshot(ImageIO.read(newFile(fullPathNameExpected)));
-    ImageDiff diff = new ImageDiffer().makeDiff(actual, expected);
-    BufferedImage diffImage = diff.getMarkedImage();
-    ImageIO.write(diffImage, "png", newFile(fullPathNameDiff));
-    // adding to report
-    diff(fullPathNameDiff);
-    // adding to report
-    actual(fullPathNameActual);
-    // adding to report
-    expected(fullPathNameExpected);
-
-    if (shouldUpdateScreenshotIfDiffer) {
-      if (diff.getDiffSize() > PIXELS_THRESHOLD) {
-        updateActualScreenshot(expectedName);
-      }
-    } else {
-      Assertions.assertTrue(
-          PIXELS_THRESHOLD >= diff.getDiffSize(),
-              String.format("Amount of differing pixels should be less or equals than %s, actual %s\n"+
-                  "diff file: %s",
-              PIXELS_THRESHOLD, diff.getDiffSize(), FileSystems.getDefault().getPath(fullPathNameDiff).normalize().toAbsolutePath()));
+
+
+    @Attachment
+    private byte[] expected(String expectedFileName) {
+        return imgToBytes(expectedFileName);
+    }
+
+
+    @Attachment
+    private byte[] diff(String diffFileName) {
+        return imgToBytes(diffFileName);
     }
-  }
-
-  @SneakyThrows
-  private byte[] imgToBytes(String filename) {
-    BufferedImage bImage2 = ImageIO.read(new File(filename));
-    var bos2 = new ByteArrayOutputStream();
-    ImageIO.write(bImage2, "png", bos2);
-    return bos2.toByteArray();
-  }
-
-  @SneakyThrows
-  @Attachment
-  private byte[] actual(String actualFileName) {
-    return imgToBytes(actualFileName);
-  }
-
-  @SneakyThrows
-  @Attachment
-  private byte[] expected(String expectedFileName) {
-    return imgToBytes(expectedFileName);
-  }
-
-  @SneakyThrows
-  @Attachment
-  private byte[] diff(String diffFileName) {
-    return imgToBytes(diffFileName);
-  }
 }


Test patch:
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/SmokeTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/SmokeTests.java
index 149acf4aa56..fbfb0990eb9 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/SmokeTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/SmokeTests.java
@@ -4,7 +4,6 @@
 import com.provectus.kafka.ui.utils.qaseIO.Status;
 import com.provectus.kafka.ui.utils.qaseIO.annotation.AutomationStatus;
 import io.qase.api.annotation.CaseId;
-import lombok.SneakyThrows;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 
@@ -12,7 +11,6 @@ public class SmokeTests extends BaseTest {
     @Test
     @AutomationStatus(status = Status.AUTOMATED)
     @CaseId(198)
-    @SneakyThrows
     @DisplayName("main page should load")
     void mainPageLoads() {
         pages.open()
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/ConnectorsTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/ConnectorsTests.java
index fe0e468e45f..379114fdd84 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/ConnectorsTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/ConnectorsTests.java
@@ -1,18 +1,18 @@
 package com.provectus.kafka.ui.tests;
 
 import com.provectus.kafka.ui.base.BaseTest;
-import com.provectus.kafka.ui.extensions.FileUtils;
 import com.provectus.kafka.ui.helpers.ApiHelper;
 import com.provectus.kafka.ui.helpers.Helpers;
 import com.provectus.kafka.ui.utils.qaseIO.Status;
 import com.provectus.kafka.ui.utils.qaseIO.annotation.AutomationStatus;
+import com.provectus.kafka.ui.utils.qaseIO.annotation.Suite;
 import io.qase.api.annotation.CaseId;
-import lombok.SneakyThrows;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
-import com.provectus.kafka.ui.utils.qaseIO.annotation.Suite;
+
+import static com.provectus.kafka.ui.extensions.FileUtils.getResourceAsString;
 
 public class ConnectorsTests extends BaseTest {
 
@@ -28,13 +28,12 @@ public class ConnectorsTests extends BaseTest {
     public static final String CONNECTOR_FOR_UPDATE = "sink_postgres_activities_e2e_checks_for_update";
 
     @BeforeAll
-    @SneakyThrows
     public static void beforeAll() {
         ApiHelper apiHelper = Helpers.INSTANCE.apiHelper;
 
-        String connectorToDelete = FileUtils.getResourceAsString("delete_connector_config.json");
-        String connectorToUpdate = FileUtils.getResourceAsString("config_for_create_connector_via_api.json");
-        String message = FileUtils.getResourceAsString("message_content_create_topic.json");
+        String connectorToDelete = getResourceAsString("delete_connector_config.json");
+        String connectorToUpdate = getResourceAsString("config_for_create_connector_via_api.json");
+        String message = getResourceAsString("message_content_create_topic.json");
 
         apiHelper.deleteTopic(LOCAL_CLUSTER, CONNECTOR_FOR_DELETE);
 
@@ -52,7 +51,6 @@ public static void beforeAll() {
     }
 
     @AfterAll
-    @SneakyThrows
     public static void afterAll() {
         ApiHelper apiHelper = Helpers.INSTANCE.apiHelper;
         apiHelper.deleteConnector(LOCAL_CLUSTER, FIRST_CONNECTOR, SINK_CONNECTOR);
@@ -62,7 +60,6 @@ public static void afterAll() {
         apiHelper.deleteTopic(LOCAL_CLUSTER, TOPIC_FOR_UPDATE_CONNECTOR);
     }
 
-    @SneakyThrows
     @DisplayName("should create a connector")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
@@ -75,13 +72,12 @@ public void createConnector() {
                 .waitUntilScreenReady()
                 .setConnectorConfig(
                         SINK_CONNECTOR,
-                        FileUtils.getResourceAsString("config_for_create_connector.json"));
+                        getResourceAsString("config_for_create_connector.json"));
         pages.openConnectorsList(LOCAL_CLUSTER)
                 .waitUntilScreenReady()
                 .connectorIsVisibleInList(SINK_CONNECTOR, TOPIC_FOR_CONNECTOR);
     }
 
-    @SneakyThrows
     @DisplayName("should update a connector")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
@@ -93,12 +89,11 @@ public void updateConnector() {
                 .openConnector(CONNECTOR_FOR_UPDATE);
         pages.connectorsView.connectorIsVisibleOnOverview();
         pages.connectorsView.openEditConfig()
-                .updConnectorConfig(FileUtils.getResourceAsString("config_for_update_connector.json"));
+                .updConnectorConfig(getResourceAsString("config_for_update_connector.json"));
         pages.openConnectorsList(LOCAL_CLUSTER)
                 .connectorIsVisibleInList(CONNECTOR_FOR_UPDATE, TOPIC_FOR_UPDATE_CONNECTOR);
     }
 
-    @SneakyThrows
     @DisplayName("should delete connector")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/SchemasTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/SchemasTests.java
index af14f108198..239f66f5cf5 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/SchemasTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/SchemasTests.java
@@ -8,14 +8,11 @@
 import com.provectus.kafka.ui.pages.schema.SchemaCreateView;
 import com.provectus.kafka.ui.utils.qaseIO.Status;
 import com.provectus.kafka.ui.utils.qaseIO.annotation.AutomationStatus;
+import com.provectus.kafka.ui.utils.qaseIO.annotation.Suite;
 import io.qase.api.annotation.CaseId;
-import lombok.SneakyThrows;
 import org.junit.jupiter.api.*;
-import com.provectus.kafka.ui.utils.qaseIO.annotation.Suite;
-
-import java.io.IOException;
 
-import static org.apache.kafka.common.utils.Utils.readFileAsString;
+import static com.provectus.kafka.ui.extensions.FileUtils.fileToString;
 
 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 public class SchemasTests extends BaseTest {
@@ -36,16 +33,14 @@ public class SchemasTests extends BaseTest {
     private static final String PATH_JSON_VALUE = System.getProperty("user.dir") + "/src/test/resources/schema_Json_Value.json";
 
     @BeforeAll
-    @SneakyThrows
     public static void beforeAll() {
-        Helpers.INSTANCE.apiHelper.createSchema(SECOND_LOCAL, SCHEMA_AVRO_API_UPDATE, SchemaType.AVRO, readFileAsString(PATH_AVRO_VALUE));
-        Helpers.INSTANCE.apiHelper.createSchema(SECOND_LOCAL, SCHEMA_AVRO_API, SchemaType.AVRO, readFileAsString(PATH_AVRO_VALUE));
-        Helpers.INSTANCE.apiHelper.createSchema(SECOND_LOCAL, SCHEMA_JSON_API, SchemaType.JSON, readFileAsString(PATH_JSON_VALUE));
-        Helpers.INSTANCE.apiHelper.createSchema(SECOND_LOCAL, SCHEMA_PROTOBUF_API, SchemaType.PROTOBUF, readFileAsString(PATH_PROTOBUF_VALUE));
+        Helpers.INSTANCE.apiHelper.createSchema(SECOND_LOCAL, SCHEMA_AVRO_API_UPDATE, SchemaType.AVRO, fileToString(PATH_AVRO_VALUE));
+        Helpers.INSTANCE.apiHelper.createSchema(SECOND_LOCAL, SCHEMA_AVRO_API, SchemaType.AVRO, fileToString(PATH_AVRO_VALUE));
+        Helpers.INSTANCE.apiHelper.createSchema(SECOND_LOCAL, SCHEMA_JSON_API, SchemaType.JSON, fileToString(PATH_JSON_VALUE));
+        Helpers.INSTANCE.apiHelper.createSchema(SECOND_LOCAL, SCHEMA_PROTOBUF_API, SchemaType.PROTOBUF, fileToString(PATH_PROTOBUF_VALUE));
     }
 
     @AfterAll
-    @SneakyThrows
     public static void afterAll() {
         Helpers.INSTANCE.apiHelper.deleteSchema(SECOND_LOCAL, SCHEMA_AVRO_CREATE);
         Helpers.INSTANCE.apiHelper.deleteSchema(SECOND_LOCAL, SCHEMA_JSON_CREATE);
@@ -63,12 +58,12 @@ public static void afterAll() {
     @CaseId(43)
     @Test
     @Order(1)
-    void createSchemaAvro() throws IOException {
+    void createSchemaAvro() {
         pages.openMainPage()
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.clickCreateSchema()
                 .setSubjectName(SCHEMA_AVRO_CREATE)
-                .setSchemaField(readFileAsString(PATH_AVRO_VALUE))
+                .setSchemaField(fileToString(PATH_AVRO_VALUE))
                 .selectSchemaTypeFromDropdown(SchemaCreateView.SchemaType.AVRO)
                 .clickSubmit()
                 .waitUntilScreenReady();
@@ -77,7 +72,6 @@ void createSchemaAvro() throws IOException {
         pages.schemaRegistry.isSchemaVisible(SCHEMA_AVRO_CREATE);
     }
 
-    @SneakyThrows
     @DisplayName("should update AVRO schema")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
@@ -91,13 +85,12 @@ void updateSchemaAvro() {
                 .waitUntilScreenReady()
                 .openEditSchema()
                 .selectCompatibilityLevelFromDropdown(CompatibilityLevel.CompatibilityEnum.NONE)
-                .setNewSchemaValue(readFileAsString(PATH_AVRO_FOR_UPDATE))
+                .setNewSchemaValue(fileToString(PATH_AVRO_FOR_UPDATE))
                 .clickSubmit()
                 .waitUntilScreenReady()
                 .isCompatibility(CompatibilityLevel.CompatibilityEnum.NONE);
     }
 
-    @SneakyThrows
     @DisplayName("should delete AVRO schema")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
@@ -113,7 +106,6 @@ void deleteSchemaAvro() {
                 .isNotVisible(SCHEMA_AVRO_API);
     }
 
-    @SneakyThrows
     @DisplayName("should create JSON schema")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
@@ -125,7 +117,7 @@ void createSchemaJson() {
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.clickCreateSchema()
                 .setSubjectName(SCHEMA_JSON_CREATE)
-                .setSchemaField(readFileAsString(PATH_JSON_VALUE))
+                .setSchemaField(fileToString(PATH_JSON_VALUE))
                 .selectSchemaTypeFromDropdown(SchemaCreateView.SchemaType.JSON)
                 .clickSubmit()
                 .waitUntilScreenReady();
@@ -134,7 +126,6 @@ void createSchemaJson() {
         pages.schemaRegistry.isSchemaVisible(SCHEMA_JSON_CREATE);
     }
 
-    @SneakyThrows
     @DisplayName("should delete JSON schema")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
@@ -150,7 +141,6 @@ void deleteSchemaJson() {
                 .isNotVisible(SCHEMA_JSON_API);
     }
 
-    @SneakyThrows
     @DisplayName("should create PROTOBUF schema")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
@@ -162,7 +152,7 @@ void createSchemaProtobuf() {
                 .goToSideMenu(SECOND_LOCAL, MainPage.SideMenuOptions.SCHEMA_REGISTRY);
         pages.schemaRegistry.clickCreateSchema()
                 .setSubjectName(SCHEMA_PROTOBUF_CREATE)
-                .setSchemaField(readFileAsString(PATH_PROTOBUF_VALUE))
+                .setSchemaField(fileToString(PATH_PROTOBUF_VALUE))
                 .selectSchemaTypeFromDropdown(SchemaCreateView.SchemaType.PROTOBUF)
                 .clickSubmit()
                 .waitUntilScreenReady();
@@ -171,7 +161,6 @@ void createSchemaProtobuf() {
         pages.schemaRegistry.isSchemaVisible(SCHEMA_PROTOBUF_CREATE);
     }
 
-    @SneakyThrows
     @DisplayName("should delete PROTOBUF schema")
     @Suite(suiteId = suiteId, title = suiteTitle)
     @AutomationStatus(status = Status.AUTOMATED)
diff --git a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
index 0d6026e1edb..b799e6580bc 100644
--- a/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
+++ b/kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/tests/TopicTests.java
@@ -9,10 +9,9 @@
 import com.provectus.kafka.ui.utils.qaseIO.annotation.Suite;
 import io.qameta.allure.Issue;
 import io.qase.api.annotation.CaseId;
-import lombok.SneakyThrows;
 import org.junit.jupiter.api.*;
 
-import static org.apache.kafka.common.utils.Utils.readFileAsString;
+import static com.provectus.kafka.ui.extensions.FileUtils.fileToString;
 
 public class TopicTests extends BaseTest {
 
@@ -29,21 +28,18 @@ public class TopicTests extends BaseTest {
 
 
     @BeforeAll
-    @SneakyThrows
     public static void beforeAll() {
         Helpers.INSTANCE.apiHelper.createTopic(SECOND_LOCAL, TOPIC_TO_UPDATE);
         Helpers.INSTANCE.apiHelper.createTopic(SECOND_LOCAL, TOPIC_TO_DELETE);
     }
 
     @AfterAll
-    @SneakyThrows
     public static void afterAll() {
         Helpers.INSTANCE.apiHelper.deleteTopic(SECOND_LOCAL, TOPIC_TO_UPDATE);
         Helpers.INSTANCE.apiHelper.deleteTopic(SECOND_LOCAL, TOPIC_TO_DELETE);
         Helpers.INSTANCE.apiHelper.deleteTopic(SECOND_LOCAL, NEW_TOPIC);
     }
 
-    @SneakyThrows
     @DisplayName("should create a topic")
     @Suite(suiteId = 4, title = "Create new Topic")
     @AutomationStatus(status = Status.AUTOMATED)
@@ -65,7 +61,6 @@ public void createTopic() {
                 .topicIsNotVisible(NEW_TOPIC);
     }
     @Disabled("Due to issue https://github.com/provectus/kafka-ui/issues/1500 ignore this test")
-    @SneakyThrows
     @DisplayName("should update a topic")
     @Issue("1500")
     @Suite(suiteId = 2, title = "Topics")
@@ -97,7 +92,6 @@ public void updateTopic() {
                 .maxMessageBytesIs(UPDATED_MAX_MESSAGE_BYTES);
     }
 
-    @SneakyThrows
     @DisplayName("should delete topic")
     @Suite(suiteId = 2, title = "Topics")
     @AutomationStatus(status = Status.AUTOMATED)
@@ -113,7 +107,6 @@ public void deleteTopic() {
                 .isTopicNotVisible(TOPIC_TO_DELETE);
     }
 
-    @SneakyThrows
     @DisplayName("produce message")
     @Suite(suiteId = 2, title = "Topics")
     @AutomationStatus(status = Status.AUTOMATED)
@@ -126,10 +119,10 @@ void produceMessage() {
                 .waitUntilScreenReady()
                 .openTopicMenu(TopicView.TopicMenu.MESSAGES)
                 .clickOnButton("Produce Message")
-                .setContentFiled(readFileAsString(CONTENT_TO_PRODUCE_MESSAGE))
-                .setKeyField(readFileAsString(KEY_TO_PRODUCE_MESSAGE))
+                .setContentFiled(fileToString(CONTENT_TO_PRODUCE_MESSAGE))
+                .setKeyField(fileToString(KEY_TO_PRODUCE_MESSAGE))
                 .submitProduceMessage();
-        Assertions.assertTrue(pages.topicView.isKeyMessageVisible(readFileAsString(KEY_TO_PRODUCE_MESSAGE)));
-        Assertions.assertTrue(pages.topicView.isContentMessageVisible(readFileAsString(CONTENT_TO_PRODUCE_MESSAGE).trim()));
+        Assertions.assertTrue(pages.topicView.isKeyMessageVisible(fileToString(KEY_TO_PRODUCE_MESSAGE)));
+        Assertions.assertTrue(pages.topicView.isContentMessageVisible(fileToString(CONTENT_TO_PRODUCE_MESSAGE).trim()));
     }
 }