-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added playwright test for survey creation and issuance
- bonus: some extra unit tests #6071
- Loading branch information
1 parent
2be53c9
commit 726822f
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
waltz-common/src/test/java/org/finos/waltz/common/BatchProcessingCollectorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
waltz-common/src/test/java/org/finos/waltz/common/Columns_toOffsetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
waltz-common/src/test/java/org/finos/waltz/common/ListUtilities_getOrDefaultTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
|
||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
waltz-common/src/test/java/org/finos/waltz/common/StreamUtilities_siphonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
|
||
} | ||
} |