Skip to content

Commit

Permalink
Fix AbuseReport
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre POCHEAU committed Oct 13, 2016
1 parent 424eb7d commit bea5f41
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 85 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ dependencies {
compile 'joda-time:joda-time:2.9.4'

testCompile 'org.testng:testng:6.8.21'
testCompile 'org.powermock:powermock-mockito-release-full:1.5.4'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
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
5 changes: 5 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,9 @@ function splitJvmOpts() {
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
6 changes: 0 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ goto fail
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
Expand All @@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ecwid.maleorang.method.v3_0.lists

import com.ecwid.maleorang.MailchimpObject
import com.ecwid.maleorang.annotation.Field
import java.util.*

/**
* Created by apocheau on 27/08/16.
Expand Down Expand Up @@ -30,62 +31,17 @@ class AbuseReportInfo : MailchimpObject() {

@JvmField
@Field
var merge_fields: Object? = null
var merge_fields: MailchimpObject? = null

@JvmField
@Field
var vip: Boolean? = null

@JvmField
@Field
var date: String? = null
var date: Date? = null

@JvmField
@Field
var _links: List<LinkInfo>? = null

fun setId(id: String): AbuseReportInfo{
this.id = id
return this
}

fun setCampaign_id(campaign_id: String): AbuseReportInfo{
this.campaign_id = campaign_id
return this
}

fun setListId(list_id: String): AbuseReportInfo{
this.list_id = list_id
return this
}

fun setEmailId(email_id: String): AbuseReportInfo{
this.email_id = email_id
return this
}

fun setEmailAddress(email_address: String): AbuseReportInfo{
this.email_address = email_address
return this
}

fun setMergeFields(merge_fields: Object): AbuseReportInfo{
this.merge_fields = merge_fields
return this
}

fun setVip(vip: Boolean): AbuseReportInfo{
this.vip = vip
return this
}

fun setDate(date: String): AbuseReportInfo{
this.date = date
return this
}

fun setLinks(_links: List<LinkInfo>): AbuseReportInfo{
this._links = _links
return this
}
}
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() {
Expand All @@ -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)
// }
// }
// }
}
}
}
}
2 changes: 1 addition & 1 deletion test.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test {
}

doFirst {
['mailchimp.test.apikey', 'mailchimp.test.listid', 'mailchimp.test.abusereportid'].each { prop ->
['mailchimp.test.apikey', 'mailchimp.test.listid'].each { prop ->
systemProperty prop, project.getProperty(prop)
}
}
Expand Down

0 comments on commit bea5f41

Please sign in to comment.