Skip to content

Commit

Permalink
additional tests for codecov check failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjames committed Jul 21, 2021
1 parent 03a4605 commit e425ba0
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.auth0.json.JsonTest;
import org.junit.Test;

import java.util.ArrayList;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

Expand Down Expand Up @@ -100,5 +102,16 @@ public void shouldDeserializeWithNextItemPointer() throws Exception {
assertThat(page.getItems(), is(notNullValue()));
assertThat(page.getItems().size(), is(2));
}

@Test
public void shouldBeCreatedWithoutNextField() {
MembersPage page = new MembersPageDeserializer().createPage(0, 5, 20, 50, new ArrayList<>());

assertThat(page.getStart(), is(0));
assertThat(page.getLength(), is(5));
assertThat(page.getTotal(), is(20));
assertThat(page.getLimit(), is(50));
assertThat(page.getItems(), is(notNullValue()));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.auth0.json.JsonTest;
import org.junit.Test;

import java.util.ArrayList;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

Expand Down Expand Up @@ -85,6 +87,35 @@ public class OrganizationsPageTest extends JsonTest<OrganizationsPage> {
" \"next\": \"MjAyMS0wMy0yOSAxNjo1MDo09s44NDYxODcrMDAsb3JnX2Y0VXZUbG1iSWd2005zTGw\"\n" +
"}";

private static final String jsonWithNulls = "{\n" +
" \"organizations\": [\n" +
" {\n" +
" \"id\": \"org_2\",\n" +
" \"name\": \"org-1\",\n" +
" \"display_name\": \"org 1\",\n" +
" \"branding\": {\n" +
" \"logo_url\": \"https://some-url.com/\",\n" +
" \"colors\": {\n" +
" \"primary\": \"#FF0000\",\n" +
" \"page_background\": \"#FF0000\"\n" +
" }\n" +
" },\n" +
" \"metadata\": {\n" +
" \"key1\": \"val1\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"id\": \"org_2\",\n" +
" \"name\": \"org-2\",\n" +
" \"display_name\": \"org 2\"\n" +
" }\n" +
" ],\n" +
" \"start\": null,\n" +
" \"limit\": 20,\n" +
" \"total\": 2,\n" +
" \"next\": null" +
"}";

@Test
public void shouldDeserializeWithoutTotals() throws Exception {
OrganizationsPage page = fromJSON(jsonWithoutTotals, OrganizationsPage.class);
Expand Down Expand Up @@ -124,4 +155,28 @@ public void shouldDeserializeWithCheckpointResponse() throws Exception {
assertThat(page.getItems(), is(notNullValue()));
assertThat(page.getItems().size(), is(2));
}

@Test
public void shouldBeCreatedWithoutNextField() {
OrganizationsPage page = new OrganizationsPageDeserializer().createPage(0, 5, 20, 50, new ArrayList<>());

assertThat(page.getStart(), is(0));
assertThat(page.getLength(), is(5));
assertThat(page.getTotal(), is(20));
assertThat(page.getLimit(), is(50));
assertThat(page.getItems(), is(notNullValue()));
}

@Test
public void shouldHandleNullFields() throws Exception {
OrganizationsPage page = fromJSON(jsonWithNulls, OrganizationsPage.class);

assertThat(page, is(notNullValue()));
assertThat(page.getNext(), is(nullValue()));
assertThat(page.getStart(), is(nullValue()));
assertThat(page.getTotal(), is(2));
assertThat(page.getLimit(), is(20));
assertThat(page.getItems(), is(notNullValue()));
assertThat(page.getItems().size(), is(2));
}
}
13 changes: 13 additions & 0 deletions src/test/java/com/auth0/json/mgmt/users/UsersPageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.auth0.json.JsonTest;
import org.junit.Test;

import java.util.ArrayList;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

Expand Down Expand Up @@ -51,4 +53,15 @@ public void shouldDeserializeWithCheckpointResponse() throws Exception {
assertThat(page.getNext(), is("MjAyMS0wMy0yOSAxNjo1MDo09s44NDYxODcrMDAsb3JnX2Y0VXZUbG1iSWd2005zTGw"));
assertThat(page.getItems().size(), is(1));
}

@Test
public void shouldBeCreatedWithoutNextField() {
UsersPage page = new UsersPageDeserializer().createPage(0, 5, 20, 50, new ArrayList<>());

assertThat(page.getStart(), is(0));
assertThat(page.getLength(), is(5));
assertThat(page.getTotal(), is(20));
assertThat(page.getLimit(), is(50));
assertThat(page.getItems(), is(notNullValue()));
}
}

0 comments on commit e425ba0

Please sign in to comment.