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 13, 2016
1 parent
424eb7d
commit bea5f41
Showing
8 changed files
with
41 additions
and
85 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
Binary file not shown.
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,6 @@ | ||
#Tue Oct 04 22:38:57 CEST 2016 | ||
#Sun Oct 09 18:36:17 CEST 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.14.1-all.zip | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-3.1-all.zip |
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
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
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
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,20 +1,18 @@ | ||
package com.ecwid.maleorang.method.v3_0.lists.members | ||
|
||
import com.ecwid.maleorang.MailchimpClient | ||
import com.ecwid.maleorang.connector.Connector | ||
import com.ecwid.maleorang.method.v3_0.lists.GetAbuseReportMethod | ||
import com.ecwid.maleorang.method.v3_0.lists.GetAbuseReportsMethod | ||
import org.testng.Assert | ||
import org.testng.annotations.Parameters | ||
import org.testng.annotations.Test | ||
import java.util.logging.Logger | ||
|
||
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) { | ||
|
||
// 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) | ||
@Parameters("mailchimp.test.apikey", "mailchimp.test.listid") | ||
constructor(private val apiKey: String, private val listId: String) { | ||
private val log = Logger.getLogger(javaClass.getName()) | ||
|
||
@Test | ||
fun testGetAbuseReports() { | ||
|
@@ -28,27 +26,31 @@ constructor(private val apiKey: String, private val listId: String, private val | |
} | ||
} | ||
|
||
// @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) | ||
@Test | ||
fun testGetAbuseReport() { | ||
class MockMailchimpClient : MailchimpClient(apiKey, object : Connector { | ||
override fun call(request: Connector.Request): Connector.Response { | ||
val 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\" }]}" | ||
return Connector.Response(200, "", json) | ||
} | ||
|
||
override fun close() { | ||
} | ||
}) | ||
|
||
//TODO Improve test | ||
MockMailchimpClient().use { client -> | ||
client.execute(GetAbuseReportMethod(listId, "42")).apply { | ||
Assert.assertNotNull(id) | ||
Assert.assertNotNull(campaign_id) | ||
Assert.assertNotNull(list_id) | ||
Assert.assertNotNull(email_id) | ||
Assert.assertNotNull(email_address) | ||
// Assert.assertNotNull(merge_fields) | ||
// Assert.assertNotNull(vip) | ||
// Assert.assertNotNull(date) | ||
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