Skip to content

Commit

Permalink
Added playwright test for survey creation and issuance
Browse files Browse the repository at this point in the history
- bonus: some extra unit tests

#6071
  • Loading branch information
davidwatkins73 committed Aug 8, 2023
1 parent 2be53c9 commit 726822f
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class BatchProcessingCollectorTest {

@Test
public void batchingWorksAndReportsNumberOfItemsProcessed() {
ArrayList<String> data = ListUtilities.newArrayList("A", "B", "C", "D");
List<String> batched = new ArrayList<>();

BatchProcessingCollector<String> batchProcessor = new BatchProcessingCollector<>(
3,
xs -> {
batched.add(StringUtilities.join(xs, "!"));
});

Integer rc = data
.stream()
.collect(batchProcessor);

assertEquals(4, rc, "Should have processed all input items");
assertEquals(ListUtilities.asList("A!B!C", "D"), batched);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Columns_toOffsetTest {

@Test
public void toOffset() {
assertEquals(Columns.A, Columns.toOffset("A"));
assertEquals(Columns.BA, Columns.toOffset("BA"));
assertEquals(53, Columns.toOffset("BB"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import java.util.List;

import static org.finos.waltz.common.ListUtilities.getOrDefault;
import static org.finos.waltz.common.TestUtilities.assertLength;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ListUtilities_getOrDefaultTest {

@Test
public void getOrDefaultTests(){
List<String> arr = ListUtilities.newArrayList("a", "b");
assertEquals("a", getOrDefault(arr, 0, "z"));
assertEquals("b", getOrDefault(arr, 1, "z"));
assertEquals("z", getOrDefault(arr, 100, "z"));
assertEquals("z", getOrDefault(arr, -1, "z"));

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.finos.waltz.common.StreamUtilities.mkSiphon;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class StreamUtilities_siphonTest {

@Test
public void siphon(){
StreamUtilities.Siphon<String> siphon = mkSiphon(x -> x.startsWith("h"));

List<String> result = Stream
.of("hello", "world", "happy", "earth", "hip", "hip", "hooray")
.filter(siphon)
.collect(Collectors.toList());

assertEquals(ListUtilities.asList("world", "earth"), result);
assertTrue(siphon.hasResults());
assertEquals(ListUtilities.asList("hello", "happy", "hip", "hip", "hooray"), siphon.getResults());

}
}

0 comments on commit 726822f

Please sign in to comment.