-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API:7197: Parameterize flag content event test with reason enum
- Loading branch information
1 parent
10c5c9d
commit b3d6c84
Showing
1 changed file
with
24 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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; | ||
|
@@ -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" + | ||
|
@@ -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" + | ||
"}"; | ||
|
@@ -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")); | ||
|
||
|