Skip to content

Commit

Permalink
API:7197: Parameterize flag content event test with reason enum
Browse files Browse the repository at this point in the history
  • Loading branch information
advornichenko-sift committed Jul 6, 2023
1 parent 10c5c9d commit b3d6c84
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/test/java/com/siftscience/FlagContentEventTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.siftscience;

import static java.net.HttpURLConnection.HTTP_OK;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.siftscience.model.EventResponseBody;
import com.siftscience.model.FlagContentFieldSet;
Expand All @@ -10,9 +13,28 @@
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.skyscreamer.jsonassert.JSONAssert;

@RunWith(Parameterized.class)
public class FlagContentEventTest {

@Parameterized.Parameters
public static Collection<Object[]> data() {
FlagContentFieldSet.FlagContentReason[] values = FlagContentFieldSet.FlagContentReason.values();
List<Object[]> data = new ArrayList<>(values.length);
for (FlagContentFieldSet.FlagContentReason reason : values) {
data.add(new Object[] { reason });
}
return data;
}

private final FlagContentFieldSet.FlagContentReason reason;

public FlagContentEventTest(FlagContentFieldSet.FlagContentReason reason) {
this.reason = reason;
}
@Test
public void testFlagContent() throws Exception {
String expectedRequestBody = "{\n" +
Expand All @@ -22,7 +44,7 @@ public void testFlagContent() throws Exception {
" \"$content_id\" : \"9671500641\",\n" +
"\n" +
" \"$flagged_by\" : \"jamieli89\",\n" +
" \"$reason\" : \"$toxic\",\n" +
" \"$reason\" : \"" + this.reason.value + "\",\n" +
" \"$user_email\" : \"[email protected]\",\n" +
" \"$verification_phone_number\" : \"+12345678901\"\n" +
"}";
Expand Down Expand Up @@ -52,7 +74,7 @@ public void testFlagContent() throws Exception {
.setUserId("billy_jones_301")
.setContentId("9671500641")
.setFlaggedBy("jamieli89")
.setReason(FlagContentFieldSet.FlagContentReason.TOXIC)
.setReason(this.reason)
.setUserEmail("[email protected]")
.setVerificationPhoneNumber("+12345678901"));

Expand Down

0 comments on commit b3d6c84

Please sign in to comment.