Skip to content

Commit

Permalink
failling to test getAbuseReport
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre POCHEAU committed Oct 5, 2016
1 parent cceb5c1 commit fb0eada
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
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
Expand All @@ -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() {
Expand All @@ -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)
// }
// }
// }
}
2 changes: 1 addition & 1 deletion wrapper.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
wrapper {
gradleVersion '2.14.1'
gradleVersion '3.1'
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"

if (gradle.gradleVersion != gradleVersion) {
Expand Down

0 comments on commit fb0eada

Please sign in to comment.