From 114571e3a34fa1e0916b9239339471777321cc1a Mon Sep 17 00:00:00 2001 From: jesus-dayo Date: Thu, 11 Aug 2016 09:44:32 +0800 Subject: [PATCH 1/3] Fix pagination --- .../StudentDirectory/src/main/resources/application.properties | 2 +- .../StudentDirectory/src/main/webapp/view/app.js | 1 + .../test/java/org/baeldung/web/service/StudentServiceTest.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-rest-angular-pagination/StudentDirectory/src/main/resources/application.properties b/spring-rest-angular-pagination/StudentDirectory/src/main/resources/application.properties index a9bf6ca218..e42588cee0 100644 --- a/spring-rest-angular-pagination/StudentDirectory/src/main/resources/application.properties +++ b/spring-rest-angular-pagination/StudentDirectory/src/main/resources/application.properties @@ -1 +1 @@ -server.contextPath=/StudentDirectory \ No newline at end of file +server.contextPath=/ \ No newline at end of file diff --git a/spring-rest-angular-pagination/StudentDirectory/src/main/webapp/view/app.js b/spring-rest-angular-pagination/StudentDirectory/src/main/webapp/view/app.js index 522c49c8cb..715b667cc9 100644 --- a/spring-rest-angular-pagination/StudentDirectory/src/main/webapp/view/app.js +++ b/spring-rest-angular-pagination/StudentDirectory/src/main/webapp/view/app.js @@ -17,6 +17,7 @@ app.controller('StudentCtrl', ['$scope','StudentService', function ($scope,Stude paginationPageSizes: [5, 10, 20], paginationPageSize: paginationOptions.pageSize, enableColumnMenus:false, + useExternalPagination: true, columnDefs: [ { name: 'studentId' }, { name: 'name' }, diff --git a/spring-rest-angular-pagination/StudentDirectory/src/test/java/org/baeldung/web/service/StudentServiceTest.java b/spring-rest-angular-pagination/StudentDirectory/src/test/java/org/baeldung/web/service/StudentServiceTest.java index 3e476bf0d0..c6c9539abd 100644 --- a/spring-rest-angular-pagination/StudentDirectory/src/test/java/org/baeldung/web/service/StudentServiceTest.java +++ b/spring-rest-angular-pagination/StudentDirectory/src/test/java/org/baeldung/web/service/StudentServiceTest.java @@ -22,7 +22,7 @@ import io.restassured.response.Response; public class StudentServiceTest{ private String getURL() { - return "/StudentDirectory/student/get"; + return "/student/get"; } @Test From 19b65ea960bae4a0140b1b7f6bcf93d271781813 Mon Sep 17 00:00:00 2001 From: jesus-dayo Date: Thu, 11 Aug 2016 09:53:49 +0800 Subject: [PATCH 2/3] merge test conflicts --- .../src/main/resources/application.properties | 2 +- spring-rest-angular-pagination/src/main/webapp/view/app.js | 1 + .../test/java/org/baeldung/web/service/StudentServiceTest.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-rest-angular-pagination/src/main/resources/application.properties b/spring-rest-angular-pagination/src/main/resources/application.properties index a9bf6ca218..e42588cee0 100644 --- a/spring-rest-angular-pagination/src/main/resources/application.properties +++ b/spring-rest-angular-pagination/src/main/resources/application.properties @@ -1 +1 @@ -server.contextPath=/StudentDirectory \ No newline at end of file +server.contextPath=/ \ No newline at end of file diff --git a/spring-rest-angular-pagination/src/main/webapp/view/app.js b/spring-rest-angular-pagination/src/main/webapp/view/app.js index 522c49c8cb..715b667cc9 100644 --- a/spring-rest-angular-pagination/src/main/webapp/view/app.js +++ b/spring-rest-angular-pagination/src/main/webapp/view/app.js @@ -17,6 +17,7 @@ app.controller('StudentCtrl', ['$scope','StudentService', function ($scope,Stude paginationPageSizes: [5, 10, 20], paginationPageSize: paginationOptions.pageSize, enableColumnMenus:false, + useExternalPagination: true, columnDefs: [ { name: 'studentId' }, { name: 'name' }, diff --git a/spring-rest-angular-pagination/src/test/java/org/baeldung/web/service/StudentServiceTest.java b/spring-rest-angular-pagination/src/test/java/org/baeldung/web/service/StudentServiceTest.java index da3a36cf7a..19fe77a1fd 100644 --- a/spring-rest-angular-pagination/src/test/java/org/baeldung/web/service/StudentServiceTest.java +++ b/spring-rest-angular-pagination/src/test/java/org/baeldung/web/service/StudentServiceTest.java @@ -19,7 +19,7 @@ import static org.hamcrest.core.IsEqual.equalTo; @IntegrationTest("server.port:8888") public class StudentServiceTest { - private static final String ENDPOINT = "http://localhost:8888/StudentDirectory/student/get"; + private static final String ENDPOINT = "http://localhost:8888/student/get"; @Test public void givenRequestForStudents_whenPageIsOne_expectContainsNames() { From 74509557a6a47f07b9751bc9a2f7b466d765eb59 Mon Sep 17 00:00:00 2001 From: jesus-dayo Date: Thu, 11 Aug 2016 10:04:27 +0800 Subject: [PATCH 3/3] remove StudentDirectory --- .../src/main/resources/application.properties | 1 - .../web/service/StudentServiceTest.java | 49 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 spring-rest-angular-pagination/StudentDirectory/src/main/resources/application.properties delete mode 100644 spring-rest-angular-pagination/StudentDirectory/src/test/java/org/baeldung/web/service/StudentServiceTest.java diff --git a/spring-rest-angular-pagination/StudentDirectory/src/main/resources/application.properties b/spring-rest-angular-pagination/StudentDirectory/src/main/resources/application.properties deleted file mode 100644 index e42588cee0..0000000000 --- a/spring-rest-angular-pagination/StudentDirectory/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.contextPath=/ \ No newline at end of file diff --git a/spring-rest-angular-pagination/StudentDirectory/src/test/java/org/baeldung/web/service/StudentServiceTest.java b/spring-rest-angular-pagination/StudentDirectory/src/test/java/org/baeldung/web/service/StudentServiceTest.java deleted file mode 100644 index c6c9539abd..0000000000 --- a/spring-rest-angular-pagination/StudentDirectory/src/test/java/org/baeldung/web/service/StudentServiceTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.baeldung.web.service; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.apache.commons.lang3.RandomStringUtils; -import org.baeldung.web.main.Application; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.IntegrationTest; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; - -import io.restassured.RestAssured; -import io.restassured.response.Response; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = Application.class) -@WebAppConfiguration -@IntegrationTest("server.port:8080") -public class StudentServiceTest{ - - private String getURL() { - return "/student/get"; - } - - @Test - public void whenResourcesAreRetrievedPaged_then200IsReceived(){ - Response response = RestAssured.given().get(getURL()+ "?page=0&size=2").andReturn(); - - assertTrue(response.getStatusCode() == 200 ); - } - - @Test - public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived(){ - String url = getURL()+ "?page=" + RandomStringUtils.randomNumeric(5) + "&size=2"; - Response response = RestAssured.given().get(url); - - assertTrue(response.getStatusCode() == 500 ); - } - - @Test - public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources(){ - Response response = RestAssured.given().get(getURL() + "?page=1&size=2" ); - assertFalse(response.getBody().jsonPath().getList("content").isEmpty() ); - } - -}