diff --git a/app/criterias/HasNextPagedList.java b/app/criterias/HasNextPagedList.java index 7f3636bf..f10fbc88 100644 --- a/app/criterias/HasNextPagedList.java +++ b/app/criterias/HasNextPagedList.java @@ -113,7 +113,7 @@ public int getPageSize() { @Override public int getPageIndex() { - return getOffset() / getPageSize(); + return getPageSize() != 0 ? getOffset() / getPageSize() : 0; } public int getOffset() { diff --git a/src/it/java/controllers/ApiControllerTest.java b/src/it/java/controllers/ApiControllerTest.java index d7c6568e..1e716e2f 100644 --- a/src/it/java/controllers/ApiControllerTest.java +++ b/src/it/java/controllers/ApiControllerTest.java @@ -3,26 +3,27 @@ import org.apache.http.client.utils.URIBuilder; import play.mvc.Call; import play.mvc.Http.RequestBuilder; +import tests.AbstractTest; import java.net.URISyntaxException; import static assertions.CustomAssertions.assertThat; import static play.test.Helpers.route; -abstract class ApiControllerTest extends ControllerTest { +abstract class ApiControllerTest extends AbstractTest { void assertAccessDenied(Call call, String accessToken, String description) { try { assertThat(route( - app, - new RequestBuilder().uri( - new URIBuilder(call.url()) - .addParameter("access_token", accessToken) - .build() - ) + app, + new RequestBuilder().uri( + new URIBuilder(call.url()) + .addParameter("access_token", accessToken) + .build() + ) )) - .as(description) - .statusIsEqualTo(Projects.FORBIDDEN); + .as(description) + .statusIsEqualTo(403); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } diff --git a/src/it/java/controllers/ControllerTest.java b/src/it/java/controllers/ControllerTest.java deleted file mode 100644 index 20e6335b..00000000 --- a/src/it/java/controllers/ControllerTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package controllers; - -import play.mvc.Call; -import play.mvc.Http.RequestBuilder; -import tests.AbstractTest; - -import static assertions.CustomAssertions.assertThat; -import static play.test.Helpers.route; - -/** - * Created by resamsel on 24/07/2017. - */ -abstract class ControllerTest extends AbstractTest { - - void assertAccessDenied(Call call, String description) { - assertThat(route(app, call)).as(description).statusIsEqualTo(Projects.SEE_OTHER); - } - - void assertAccessDenied(RequestBuilder requestBuilder, String description) { - assertThat(route(app, requestBuilder)).as(description).statusIsEqualTo(Projects.SEE_OTHER); - } -} diff --git a/src/test/java/importers/JsonImporterTest.java b/src/test/java/importers/JsonImporterTest.java index 2e44e329..2d42645e 100644 --- a/src/test/java/importers/JsonImporterTest.java +++ b/src/test/java/importers/JsonImporterTest.java @@ -1,6 +1,5 @@ package importers; -import com.fasterxml.jackson.databind.JsonMappingException; import models.Locale; import org.junit.Before; import org.junit.Test; @@ -15,7 +14,6 @@ import java.util.Properties; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; @RunWith(MockitoJUnitRunner.class) public class JsonImporterTest { @@ -33,18 +31,16 @@ public void setUp() { } @Test - public void retrievePropertiesWithNoJsonObject() { + public void retrievePropertiesWithNoJsonObject() throws Exception { // given InputStream inputStream = new ByteArrayInputStream("".getBytes()); Locale locale = new Locale(); // when - Throwable thrown = catchThrowable(() -> target.retrieveProperties(inputStream, locale)); + Properties actual = target.retrieveProperties(inputStream, locale); // then - assertThat(thrown) - .isInstanceOf(JsonMappingException.class) - .hasMessageContaining("end-of-input"); + assertThat(actual).isEmpty(); } @Test diff --git a/src/test/java/repositories/impl/ProjectUserRepositoryImplTest.java b/src/test/java/repositories/impl/ProjectUserRepositoryImplTest.java index 6486f93e..2da40436 100644 --- a/src/test/java/repositories/impl/ProjectUserRepositoryImplTest.java +++ b/src/test/java/repositories/impl/ProjectUserRepositoryImplTest.java @@ -59,6 +59,7 @@ public class ProjectUserRepositoryImplTest { @Before public void setUp() { + when(persistence.find(eq(ProjectUser.class))).thenReturn(query); when(query.where()).thenReturn(where); when(where.idEq(any())).thenReturn(expressionList); when(where.query()).thenReturn(query);