Skip to content

Commit

Permalink
Migrate to latest Play version - addresses #92
Browse files Browse the repository at this point in the history
Fixes failing tests.
  • Loading branch information
resamsel committed Nov 9, 2020
1 parent 1e69072 commit 79ccf8d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/criterias/HasNextPagedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public int getPageSize() {

@Override
public int getPageIndex() {
return getOffset() / getPageSize();
return getPageSize() != 0 ? getOffset() / getPageSize() : 0;
}

public int getOffset() {
Expand Down
19 changes: 10 additions & 9 deletions src/it/java/controllers/ApiControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
22 changes: 0 additions & 22 deletions src/it/java/controllers/ControllerTest.java

This file was deleted.

10 changes: 3 additions & 7 deletions src/test/java/importers/JsonImporterTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package importers;

import com.fasterxml.jackson.databind.JsonMappingException;
import models.Locale;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -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 {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 79ccf8d

Please sign in to comment.