From 63357214347e4dfbaf081543e35e9ad5ebf35a7c Mon Sep 17 00:00:00 2001 From: Augusto Date: Wed, 1 Jan 2025 20:33:59 +0100 Subject: [PATCH] Some typos and smells provided by Sonar --- .../FullTeachingLoggedVideoSessionTests.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingLoggedVideoSessionTests.java b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingLoggedVideoSessionTests.java index 2bcf989..3012ed2 100644 --- a/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingLoggedVideoSessionTests.java +++ b/src/test/java/com/fullteaching/e2e/no_elastest/functional/test/media/FullTeachingLoggedVideoSessionTests.java @@ -38,13 +38,11 @@ import static java.lang.invoke.MethodHandles.lookup; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.*; -import static org.openqa.selenium.logging.LogType.BROWSER; import static org.slf4j.LoggerFactory.getLogger; class FullTeachingLoggedVideoSessionTests extends BaseLoggedTest { - final static Logger log = getLogger(lookup().lookupClass()); + static final Logger log = getLogger(lookup().lookupClass()); public String courseName; protected List studentPassList; @@ -90,21 +88,21 @@ void sessionTest(String mail, String password, String role) throws ElementNotFou */ private void initializeStudents(String pathData) throws IOException, URISyntaxException, NotLoggedException, ElementNotFoundException, InterruptedException { log.info("Initializing students"); - String users_data = loadStudentsData(pathData); + String usersData = loadStudentsData(pathData); studentNameList = new ArrayList<>(); studentPassList = new ArrayList<>(); studentNamesList = new ArrayList<>(); studentBrowserUserList = new ArrayList<>(); - String[] students_data = users_data.split(";"); + String[] studentsData = usersData.split(";"); - for (int i = 0; i < students_data.length; i++) { - String userid = students_data[i].split(":")[0]; + for (int i = 0; i < studentsData.length; i++) { + String userid = studentsData[i].split(":")[0]; studentNameList.add(userid); - String user_password = students_data[i].split(":")[1]; - studentPassList.add(user_password); - String STUDENT_BROWSER = students_data[i].split(":")[2]; - BrowserUser studentD = setupBrowser(STUDENT_BROWSER, TJOB_NAME + "-" + TEST_NAME, userid, WAIT_SECONDS); - this.slowLogin(studentD, userid, user_password); + String userPassword = studentsData[i].split(":")[1]; + studentPassList.add(userPassword); + String studentBrowser = studentsData[i].split(":")[2]; + BrowserUser studentD = setupBrowser(studentBrowser, TJOB_NAME + "-" + TEST_NAME, userid, WAIT_SECONDS); + this.slowLogin(studentD, userid, userPassword); studentNamesList.add(userid); studentBrowserUserList.add(studentD); } @@ -133,8 +131,8 @@ private void createNewSession(String sessionName) throws ElementNotFoundExceptio // Verify session creation Wait.waitForPageLoaded(user.getDriver()); user.waitUntil(ExpectedConditions.numberOfElementsToBeMoreThan(SESSION_LIST_SESSION_ROW,3),"Incorrect number of sessions (never more than 2)"); - List session_titles = SessionNavigationUtilities.getFullSessionList(user.getDriver()); - assertTrue(session_titles.contains(sessionName), "Session has not been created"); + List sessionTitles = SessionNavigationUtilities.getFullSessionList(user.getDriver()); + assertTrue(sessionTitles.contains(sessionName), "Session has not been created"); } private void introduceSessionDate(BrowserUser user, WebElement element) { @@ -203,8 +201,8 @@ private String getCurrentTime() { * This method navigates and joins the session, checking that it exist */ private void joinSession(String sessionName, BrowserUser usr) throws ElementNotFoundException { - List session_titles = SessionNavigationUtilities.getFullSessionList(usr.getDriver()); - assertTrue(session_titles.contains(sessionName), "Session has not been created"); + List sessionTitles = SessionNavigationUtilities.getFullSessionList(usr.getDriver()); + assertTrue(sessionTitles.contains(sessionName), "Session has not been created"); WebElement session = SessionNavigationUtilities.getSession(usr.getDriver(), sessionName); Click.element(usr.getDriver(), session.findElement(SESSION_LIST_SESSION_ACCESS)); } @@ -254,7 +252,7 @@ private void leaveSession(BrowserUser usr) throws ElementNotFoundException { * @param sessionName string with the session name */ private void deleteSession(String sessionName) throws ElementNotFoundException { - List session_titles; + List sessionTitles; WebElement modal; WebElement session; session = SessionNavigationUtilities.getSession(user.getDriver(), sessionName); @@ -263,8 +261,8 @@ private void deleteSession(String sessionName) throws ElementNotFoundException { Click.element(user.getDriver(), modal.findElement(SESSION_LIST_EDIT_MODAL_DELETE_DIV).findElement(By.tagName("label"))); Click.element(user.getDriver(), modal.findElement(SESSION_LIST_EDIT_MODAL_DELETE_DIV).findElement(By.tagName("a"))); Wait.waitForPageLoaded(user.getDriver());//13 lines - session_titles = SessionNavigationUtilities.getFullSessionList(user.getDriver()); //7 lines - assertFalse(session_titles.contains(sessionName), "Session has not been deleted"); + sessionTitles = SessionNavigationUtilities.getFullSessionList(user.getDriver()); //7 lines + assertFalse(sessionTitles.contains(sessionName), "Session has not been deleted"); } public String loadStudentsData(String path) throws IOException { @@ -277,6 +275,7 @@ public String loadStudentsData(String path) throws IOException { key.append(line); line = reader.readLine(); } + reader.close(); System.out.println(key); return key.toString(); }