Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Jan 30, 2024
1 parent ba6d665 commit 1eaf3f0
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ public class ExamplesCodeRefTest extends BaseTest {

public static final int STEPS_QUANTITY = 4;
private final String storyId = CommonUtils.namedId("story_");
private final String scenarioId = CommonUtils.namedId("scenario_");
private final List<String> exampleIds = Stream.generate(() -> CommonUtils.namedId("example_")).limit(2).collect(Collectors.toList());

private final List<Pair<String, String>> stepIds = exampleIds.stream()
.flatMap(e -> Stream.generate(() -> Pair.of(e, CommonUtils.namedId("step_"))).limit(3))
private final List<String> scenarioIds = Stream.generate(() -> CommonUtils.namedId("scenario_")).limit(2).collect(Collectors.toList());
private final List<Pair<String, List<String>>> stepIds = scenarioIds.stream()
.map(e -> Pair.of(e, Stream.generate(() -> CommonUtils.namedId("step_")).limit(3).collect(Collectors.toList())))
.collect(Collectors.toList());

private final ReportPortalClient client = mock(ReportPortalClient.class);
Expand All @@ -57,8 +55,7 @@ public class ExamplesCodeRefTest extends BaseTest {

@BeforeEach
public void setupMock() {
mockLaunch(client, null, storyId, scenarioId, exampleIds);
mockNestedSteps(client, stepIds);
mockLaunch(client, null, storyId, stepIds);
mockBatchLogging(client);
}

Expand All @@ -79,12 +76,11 @@ public void verify_story_with_examples() {
run(format, EXAMPLES_STORY, new StockSteps());

verify(client, times(1)).startTestItem(any());
verify(client, times(1)).startTestItem(same(storyId), any());
verify(client, times(2)).startTestItem(same(storyId), any());
ArgumentCaptor<StartTestItemRQ> exampleCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
verify(client, times(2)).startTestItem(same(scenarioId), exampleCaptor.capture());
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
verify(client, times(STEPS_QUANTITY)).startTestItem(same(exampleIds.get(0)), startCaptor.capture());
verify(client, times(STEPS_QUANTITY)).startTestItem(same(exampleIds.get(1)), startCaptor.capture());
verify(client, times(STEPS_QUANTITY)).startTestItem(same(scenarioIds.get(0)), startCaptor.capture());
verify(client, times(STEPS_QUANTITY)).startTestItem(same(scenarioIds.get(1)), startCaptor.capture());

String scenarioCodeRef = EXAMPLES_STORY + "/[SCENARIO:Stock trade alert]";

Expand Down

0 comments on commit 1eaf3f0

Please sign in to comment.