Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Feb 8, 2024
1 parent c19f354 commit 005511e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions example-cucumber/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
<dependency>
<groupId>com.epam.reportportal</groupId>
<artifactId>agent-java-cucumber</artifactId>
<version>5.2.0</version>
<version>5.2.1</version>
</dependency>

<dependency>
<groupId>com.epam.reportportal</groupId>
<artifactId>logger-java-logback</artifactId>
<version>5.2.0</version>
<version>5.2.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.epam.reportportal.example.cucumber.util;

import com.google.common.io.Files;
import com.google.common.io.Resources;
import com.epam.reportportal.utils.files.Utils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class AttachmentHelper {

Expand All @@ -14,7 +14,10 @@ public static File getFileFromResources(String name, String extension) {
File file = null;
try {
file = File.createTempFile("rp-test", extension);
Resources.asByteSource(Resources.getResource(String.format("files/%s%s", name, extension))).copyTo(Files.asByteSink(file));
Utils.copyStreams(
Utils.getFile(new File(String.format("files/%s%s", name, extension))).openStream(),
Files.newOutputStream(file.toPath())
);
} catch (IOException ignored) {
}
return file;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import com.google.common.collect.Range;

import java.util.Random;

Expand All @@ -16,9 +14,8 @@ public class MagicRandomizer {

private static final Logger LOGGER = LoggerFactory.getLogger(MagicRandomizer.class);

private static final Range<Integer> PROBABILITY_RANGE = Range.openClosed(0, 100);

private static final Random RANDOM = new Random();
private static final int UPPER_LIMIT = 100;

private MagicRandomizer() {
//statics only
Expand All @@ -35,10 +32,7 @@ public static int luckyInt(int bound) {
* @return TRUE if you are really lucky!
*/
public static boolean checkYourLucky(int probability) {
Preconditions.checkArgument(PROBABILITY_RANGE.contains(probability), "%s is not in range [%s]", probability, PROBABILITY_RANGE);

boolean lucky = Range.closedOpen(PROBABILITY_RANGE.lowerEndpoint(), probability)
.contains(luckyInt(PROBABILITY_RANGE.upperEndpoint()));
boolean lucky = luckyInt(UPPER_LIMIT + 1) <= probability;
LOGGER.debug("Generating [TRUE/FALSE] with probability {}%. Result {}", probability, lucky);
return lucky;
}
Expand Down

0 comments on commit 005511e

Please sign in to comment.