Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Abuse reports getters#6

Open
apocheau wants to merge 7 commits intoEcwid:masterfrom
apocheau:master
Open

Abuse reports getters#6
apocheau wants to merge 7 commits intoEcwid:masterfrom
apocheau:master

Conversation

@apocheau
Copy link
Contributor

@apocheau apocheau commented Oct 5, 2016

Hey,

I added getters for abuse reports.
As we cannot add an abuse report, i tried to mock the call method to retreive a fake json (found in the doc) but i didn't make it work.
So, i commented the test for the getAbuseReportMethod with hope you can help.

I also updated gradle version to last one.

@basiliscus
Copy link

Hi @apocheau ,

It seems that you have not applied the new gradle version by calling './gradlew wrapper' since gradle/wrapper/gradle-wrapper.properties still refers to the old version.

Haven't had a look at the other changes, will do it later.

#Tue Oct 04 22:38:57 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that the line below still refers to the old gradle version. You should run ./gradlew wrapper to complete Gradle upgrade


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These "links" are included with every response and I find them useless. Do they really needed? If not, I'd prefer this field be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main goal of the connector is to give access to the data offered by the API.
As we are working on an opensource connector to MailChimp API, we shouldn't filter data.
Everyone using this connector would be able to choose whether to use this field or not.

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

fun setId(id: String): AbuseReportInfo{
Copy link

@basiliscus basiliscus Oct 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that you've added a kind of "builder" methods. This is not a Kotlin-way to build objects. In Kotlin you build objects as follows:

val abuseReport = AbuseReportInfo().apply {
    id = "1234"
    ...
}

Please remove these methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it was made for chaining methods and build object in test method more easily. For example:
AbuseReportInfo().setId("2345").setCampaign_id("6789");
The "Kotlin way" is also nice and i didn't know it, thanks. I will follow it.


@JvmField
@Field
var date: String? = null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should be of type Date


@JvmField
@Field
var merge_fields: Object? = null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should be of type MailchimpObject (so that the info could be taken from mapping).

// var spiedConnector = spy(connector)
//
// var callMock = mock<HttpClientConnector>()
// `when`(spiedConnector.call()).thenReturn(response)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response could be mocked this way:

        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\": \"urist.mcvankab@freddiesjokes.com\",\"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() { }
        })

build.gradle Outdated
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'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a way to mock the response without this lib (see below), so please remove it

@apocheau apocheau closed this Oct 13, 2016
@apocheau
Copy link
Contributor Author

Thanks for your review and your help !
I fixed my code, so here is a new version for this pull request.

@apocheau apocheau reopened this Oct 13, 2016
@Field
var schema: String? = null

fun setRel(rel: String): LinkInfo{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these chain methods as well


@JvmField
@QueryStringParam
var offset: Int? = null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The count/offset params seem to be useless, as this method returns a single item. Perhaps, there is an error in the documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants