Skip to content

Commit b3d6c84

Browse files
API:7197: Parameterize flag content event test with reason enum
1 parent 10c5c9d commit b3d6c84

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/test/java/com/siftscience/FlagContentEventTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.siftscience;
22

33
import static java.net.HttpURLConnection.HTTP_OK;
4+
import java.util.ArrayList;
5+
import java.util.Collection;
6+
import java.util.List;
47

58
import com.siftscience.model.EventResponseBody;
69
import com.siftscience.model.FlagContentFieldSet;
@@ -10,9 +13,28 @@
1013
import okhttp3.mockwebserver.RecordedRequest;
1114
import org.junit.Assert;
1215
import org.junit.Test;
16+
import org.junit.runner.RunWith;
17+
import org.junit.runners.Parameterized;
1318
import org.skyscreamer.jsonassert.JSONAssert;
1419

20+
@RunWith(Parameterized.class)
1521
public class FlagContentEventTest {
22+
23+
@Parameterized.Parameters
24+
public static Collection<Object[]> data() {
25+
FlagContentFieldSet.FlagContentReason[] values = FlagContentFieldSet.FlagContentReason.values();
26+
List<Object[]> data = new ArrayList<>(values.length);
27+
for (FlagContentFieldSet.FlagContentReason reason : values) {
28+
data.add(new Object[] { reason });
29+
}
30+
return data;
31+
}
32+
33+
private final FlagContentFieldSet.FlagContentReason reason;
34+
35+
public FlagContentEventTest(FlagContentFieldSet.FlagContentReason reason) {
36+
this.reason = reason;
37+
}
1638
@Test
1739
public void testFlagContent() throws Exception {
1840
String expectedRequestBody = "{\n" +
@@ -22,7 +44,7 @@ public void testFlagContent() throws Exception {
2244
" \"$content_id\" : \"9671500641\",\n" +
2345
"\n" +
2446
" \"$flagged_by\" : \"jamieli89\",\n" +
25-
" \"$reason\" : \"$toxic\",\n" +
47+
" \"$reason\" : \"" + this.reason.value + "\",\n" +
2648
" \"$user_email\" : \"billy_jones_301@email.com\",\n" +
2749
" \"$verification_phone_number\" : \"+12345678901\"\n" +
2850
"}";
@@ -52,7 +74,7 @@ public void testFlagContent() throws Exception {
5274
.setUserId("billy_jones_301")
5375
.setContentId("9671500641")
5476
.setFlaggedBy("jamieli89")
55-
.setReason(FlagContentFieldSet.FlagContentReason.TOXIC)
77+
.setReason(this.reason)
5678
.setUserEmail("billy_jones_301@email.com")
5779
.setVerificationPhoneNumber("+12345678901"));
5880

0 commit comments

Comments
 (0)