forked from Ecwid/maleorang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexandre POCHEAU
committed
Oct 5, 2016
1 parent
cceb5c1
commit fb0eada
Showing
2 changed files
with
29 additions
and
33 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,12 +1,7 @@ | ||
package com.ecwid.maleorang.method.v3_0.lists.members | ||
|
||
import com.ecwid.maleorang.MailchimpClient | ||
import com.ecwid.maleorang.connector.Connector | ||
import com.ecwid.maleorang.connector.HttpClientConnector | ||
import com.ecwid.maleorang.method.v3_0.lists.GetAbuseReportMethod | ||
import com.ecwid.maleorang.method.v3_0.lists.GetAbuseReportsMethod | ||
import org.mockito.Mockito.`when` | ||
import org.mockito.Mockito.spy | ||
import org.testng.Assert | ||
import org.testng.annotations.Parameters | ||
import org.testng.annotations.Test | ||
|
@@ -15,9 +10,11 @@ class AbuseReportsTest | |
@Parameters("mailchimp.test.apikey", "mailchimp.test.listid", "mailchimp.test.abusereportid") | ||
constructor(private val apiKey: String, private val listId: String, private val abuseReportId: String) { | ||
|
||
var json = "{\"id\": 42,\"campaign_id\": \"839488a60b\",\"list_id\": \"1a2df69511\",\"email_id\": \"62eeb292278cc15f5817cb78f7790b08\",\"email_address\": \"[email protected]\",\"date\": \"2015-07-15T19:19:31+00:00\",\"links\": [{\"rel\": \"self\",\"href\": \"https://usX.api.mailchimp.com/3.0/lists/1a2df69511/abuse-reports/42\",\"method\": \"GET\",\"targetSchema\": \"https://api.mailchimp.com/schema/3.0/Lists/Abuse/Instance.json\" },{ \"rel\": \"parent\",\"href\": \"https://usX.api.mailchimp.com/3.0/lists/1a2df69511/abuse-reports\",\"method\": \"GET\",\"targetSchema\": \"https://api.mailchimp.com/schema/3.0/Lists/Abuse/Collection.json\",\"schema\": \"https://api.mailchimp.com/schema/3.0/CollectionLinks/Lists/Abuse.json\" }]}" | ||
var request = Connector.Request("", "", "", "", "") | ||
var response = Connector.Response(200, "", json) | ||
// inline fun <reified T : Any> mock(): T = mock(T::class.java) | ||
|
||
// var json = "{\"id\": 42,\"campaign_id\": \"839488a60b\",\"list_id\": \"1a2df69511\",\"email_id\": \"62eeb292278cc15f5817cb78f7790b08\",\"email_address\": \"[email protected]\",\"date\": \"2015-07-15T19:19:31+00:00\",\"links\": [{\"rel\": \"self\",\"href\": \"https://usX.api.mailchimp.com/3.0/lists/1a2df69511/abuse-reports/42\",\"method\": \"GET\",\"targetSchema\": \"https://api.mailchimp.com/schema/3.0/Lists/Abuse/Instance.json\" },{ \"rel\": \"parent\",\"href\": \"https://usX.api.mailchimp.com/3.0/lists/1a2df69511/abuse-reports\",\"method\": \"GET\",\"targetSchema\": \"https://api.mailchimp.com/schema/3.0/Lists/Abuse/Collection.json\",\"schema\": \"https://api.mailchimp.com/schema/3.0/CollectionLinks/Lists/Abuse.json\" }]}" | ||
// var request = Connector.Request(HttpMethod.GET.name, "", "", "", "") | ||
// var response = Connector.Response(200, "", json) | ||
|
||
@Test | ||
fun testGetAbuseReports() { | ||
|
@@ -31,28 +28,27 @@ constructor(private val apiKey: String, private val listId: String, private val | |
} | ||
} | ||
|
||
@Test | ||
fun testGetAbuseReport() { | ||
|
||
var connector = HttpClientConnector() | ||
var spiedConnector = spy(connector) | ||
// when(spiedConnector.call()).thenReturn(response); | ||
|
||
// val connector = `mock`(HttpClientConnector::class.java) | ||
`when`(spiedConnector.call(request)).thenReturn(response) | ||
|
||
MailchimpClient(apiKey).use { client -> | ||
client.execute(GetAbuseReportMethod(listId, abuseReportId)).apply { | ||
Assert.assertNotNull(id) | ||
Assert.assertNotNull(campaign_id) | ||
Assert.assertNotNull(listId) | ||
Assert.assertNotNull(email_id) | ||
Assert.assertNotNull(email_address) | ||
Assert.assertNotNull(merge_fields) | ||
Assert.assertNotNull(vip) | ||
Assert.assertNotNull(date) | ||
Assert.assertNotNull(_links) | ||
} | ||
} | ||
} | ||
// @Test | ||
// fun testGetAbuseReport() { | ||
// | ||
// var connector = HttpClientConnector() | ||
// var spiedConnector = spy(connector) | ||
// | ||
// var callMock = mock<HttpClientConnector>() | ||
// `when`(spiedConnector.call()).thenReturn(response) | ||
// | ||
// MailchimpClient(apiKey).use { client -> | ||
// client.execute(GetAbuseReportMethod(listId, abuseReportId)).apply { | ||
// Assert.assertNotNull(id) | ||
// Assert.assertNotNull(campaign_id) | ||
// Assert.assertNotNull(listId) | ||
// Assert.assertNotNull(email_id) | ||
// Assert.assertNotNull(email_address) | ||
// Assert.assertNotNull(merge_fields) | ||
// Assert.assertNotNull(vip) | ||
// Assert.assertNotNull(date) | ||
// Assert.assertNotNull(_links) | ||
// } | ||
// } | ||
// } | ||
} |
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