Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #52

Merged
merged 5 commits into from
May 26, 2017
Merged

Dev #52

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
=== 2.0.3 2016-02-26
* Fix get parameters in requestor.
=== 2.0.4 2016-08-24
* Fix loadFromObject: Cards where not being updated correctly.
* Fix loadFromObject: Cards where not being updated correctly.
=== 2.1.4 2016-08-24
* Fix ConektaListTest: add toString() method.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![alt tag](https://raw.github.com/conekta/conekta-java/master/readme_files/cover.png)

# Conekta Java 2.1.3
# Conekta Java 2.1.4

This is a java library that allows interaction with https://api.conekta.io API.

Expand All @@ -10,7 +10,7 @@ This is a java library that allows interaction with https://api.conekta.io API.
Add the compile line to your `build.gradle` inside the dependencies section.

```groovy
compile 'io.conekta:conekta-java:2.1.3'
compile 'io.conekta:conekta-java:2.1.4'
```

### Maven
Expand All @@ -20,7 +20,7 @@ Add the dependency to your `pom.xml`.
<dependency>
<groupId>io.conekta</groupId>
<artifactId>conekta-java</artifactId>
<version>2.1.3</version>
<version>2.1.4</version>
</dependency>
```

Expand Down
29 changes: 29 additions & 0 deletions src/io/conekta/ConektaList.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,33 @@ public ConektaList moveCursor(String url) throws JSONException, Error, ErrorList

return this;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("{elements_type=");
builder.append(elements_type);
builder.append(", next_page_url=");
builder.append(next_page_url != null && !next_page_url.isEmpty() ? next_page_url : "null");
builder.append(", previous_page_url=");
builder.append(previous_page_url != null && !previous_page_url.isEmpty() ? previous_page_url : "null");
builder.append(", has_more=");
builder.append(has_more);
builder.append(", total=");
builder.append(total);
builder.append(", data: [");
int size = this.size();
if (size > 0){
for(int i = 0; i < size; i++){
builder.append(super.get(i).toString());
if (i != size -1 )
builder.append(", ");
}
}
builder.append(" ]");
builder.append("}");
return builder.toString();
}


}
14 changes: 14 additions & 0 deletions test/io/conekta/ConektaListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,18 @@ public void testSuccsessfulPrevious() throws JSONException, Error, ErrorList{

assertTrue(id.equals(last.id));
}

// @Test
public void testToString() throws JSONException, Error, ErrorList{
JSONObject paginateParams = new JSONObject("{ 'limit': 10 }");
ConektaList lastWindow = Order.where(paginateParams);
String listAsString = lastWindow.toString();

assertTrue(listAsString.contains("elements_type"));
assertTrue(listAsString.contains("next_page_url"));
assertTrue(listAsString.contains("previous_page_url"));
assertTrue(listAsString.contains("has_more"));
assertTrue(listAsString.contains("total"));
assertTrue(listAsString.contains("data"));
}
}