Skip to content

Commit dbef3c1

Browse files
committed
Fix violations
1 parent af002a6 commit dbef3c1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

jdi-light-mobile/src/main/java/com/epam/jdi/light/mobile/MobileUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
*/
3535
public final class MobileUtils {
3636
private MobileUtils() {
37-
throw new IllegalStateException("Utility class");
3837
}
3938

4039
public static <I> void executeDriverMethod(Class<I> clazz, Consumer<I> consumer) {

jdi-light-mobile/src/main/java/com/epam/jdi/light/mobile/elements/common/app/android/RatingBar.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.epam.jdi.light.mobile.elements.common.app.android;
22

3+
import com.epam.jdi.light.common.JDIAction;
34
import com.epam.jdi.light.mobile.asserts.RatingBarAssert;
45
import com.epam.jdi.light.mobile.elements.base.MobileAppBaseElement;
56
import com.epam.jdi.light.mobile.interfaces.HasTouchActions;
@@ -8,21 +9,26 @@
89
import io.appium.java_client.touch.offset.PointOption;
910
import org.openqa.selenium.Rectangle;
1011

12+
import static com.epam.jdi.light.common.Exceptions.runtimeException;
13+
1114
public class RatingBar extends MobileAppBaseElement implements HasTouchActions {
1215

1316
public double getRating() {
1417
return Double.parseDouble(core().getText());
1518
}
1619

20+
// @todo Check if 1.0 is really the minimum, as typically 0 is minimum
21+
@JDIAction("Setup rating value to {0} with the max value as {1} (Value should not greater then max and not less then 1.0)")
1722
public void setRatingByClick(double value, double fullStars) {
1823
if (value > fullStars || value < 1.0) {
19-
throw new IllegalArgumentException("New value should be in the range [1.0, " + fullStars + "].");
24+
throw runtimeException("New value should be in the range [1.0, " + fullStars + "].");
2025
}
2126
Rectangle position = core().getRect();
2227
int stepLength = (int) (position.width / fullStars);
2328
int offset = (int) (stepLength * (value - 1));
2429
int newRatingPositionX = position.x + offset + (int) (stepLength * 0.6);
2530
int newRatingPositionY = position.y + position.height / 2;
31+
// @todo Change TouchAction in mobile project, as it is depricated
2632
TouchAction touchAction = new TouchAction((PerformsTouchActions) core().driver());
2733
touchAction.tap(PointOption.point(newRatingPositionX, newRatingPositionY)).perform();
2834
}

jdi-light-mobile/src/main/java/com/epam/jdi/light/mobile/elements/complex/Spinner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.List;
1515
import java.util.NoSuchElementException;
1616

17+
import static com.epam.jdi.light.common.Exceptions.exception;
1718
import static com.epam.jdi.light.driver.WebDriverFactory.getDriver;
1819

1920
public class Spinner extends MobileAppBaseElement<TextAssert>
@@ -44,7 +45,7 @@ public void hasItems(String[] items) {
4445
} catch (NoSuchElementException e) {
4546
StringBuilder builder = new StringBuilder();
4647
elements.forEach(el -> builder.append(el.getText()).append(", "));
47-
throw new NoSuchElementException("One of the expected items is missing in the spinner list. \nExpected:\n" +
48+
throw exception(e, "One of the expected items is missing in the spinner list. \nExpected:\n" +
4849
Arrays.asList(items) + "\nActual:\n" + builder);
4950
}
5051
}

0 commit comments

Comments
 (0)