-
-
\ No newline at end of file
diff --git a/spring-rest-angular/src/main/webapp/view/app.js b/spring-rest-angular/src/main/webapp/view/app.js
index 9f78d5adf7..b56497807c 100644
--- a/spring-rest-angular/src/main/webapp/view/app.js
+++ b/spring-rest-angular/src/main/webapp/view/app.js
@@ -5,8 +5,8 @@ app.controller('StudentCtrl', ['$scope','StudentService', function ($scope,Stude
pageNumber: 1,
pageSize: 5,
sort: null
- };
-
+ };
+
StudentService.getStudents(paginationOptions.pageNumber,
paginationOptions.pageSize).success(function(data){
$scope.gridOptions.data = data.content;
@@ -54,145 +54,3 @@ app.service('StudentService',['$http', function ($http) {
};
}]);
-
-app.controller('EmployeeCRUDCtrl', ['$scope','EmployeeCRUDService', function ($scope,EmployeeCRUDService) {
-
- $scope.updateEmployee = function () {
- EmployeeCRUDService.updateEmployee($scope.employee.id,$scope.employee.name,$scope.employee.age)
- .then(function success(response){
- $scope.message = 'Employee data updated!';
- $scope.errorMessage = '';
- },
- function error(response){
- $scope.errorMessage = 'Error updating Employee!';
- $scope.message = '';
- });
- }
-
- $scope.getEmployee = function () {
- var id = $scope.employee.id;
- EmployeeCRUDService.getEmployee($scope.employee.id)
- .then(function success(response){
- $scope.employee = response.data;
- $scope.employee.id = id;
- $scope.message='';
- $scope.errorMessage = '';
- },
- function error (response ){
- $scope.message = '';
- if (response.status === 404){
- $scope.errorMessage = 'Employee not found!';
- }
- else {
- $scope.errorMessage = "Error getting Employee!";
- }
- });
- }
-
- $scope.addEmployee = function () {
- if ($scope.employee != null && $scope.employee.id) {
- EmployeeCRUDService.addEmployee($scope.employee.id, $scope.employee.name, $scope.employee.age)
- .then (function success(response){
- $scope.message = 'Employee added!';
- $scope.errorMessage = '';
- },
- function error(response){
- $scope.errorMessage = 'Error adding Employee!';
- $scope.message = '';
- });
- }
- else {
- $scope.errorMessage = 'Please enter an id!';
- $scope.message = '';
- }
- }
-
- $scope.deleteEmployee = function () {
- EmployeeCRUDService.deleteEmployee($scope.employee.id)
- .then (function success(response){
- $scope.message = 'Employee deleted!';
- $scope.employee = null;
- $scope.errorMessage='';
- },
- function error(response){
- $scope.errorMessage = 'Error deleting Employee!';
- $scope.message='';
- })
- }
-
- $scope.getAllEmployees = function () {
- EmployeeCRUDService.getAllEmployees()
- .then(function success(response){
- $scope.employees = response.data._embedded.employee;
- $scope.message='';
- $scope.errorMessage = '';
- },
- function error (response ){
- $scope.message='';
- $scope.errorMessage = 'Error getting Employees!';
- });
- }
-
- $scope.getEmployeesByName = function () {
- EmployeeCRUDService.getEmployeesByName($scope.name)
- .then(function success(response){
- $scope.employees = response.data._embedded.employee;
- $scope.message='';
- $scope.errorMessage = '';
- },
- function error (response ){
- $scope.message='';
- $scope.errorMessage = 'Error getting Employees!';
- });
- }
-
-}]);
-
-app.service('EmployeeCRUDService',['$http', function ($http) {
-
- this.getEmployee = function getEmployee(employeeId){
- return $http({
- method: 'GET',
- url:'employees/'+employeeId
- });
- }
-
- this.addEmployee = function addEmployee(id, name, age, gender){
- return $http({
- method: 'POST',
- url:'employees',
- data: {id:id, name:name, age:age}
- });
- }
-
- this.deleteEmployee = function deleteEmployee(id){
- return $http({
- method: 'DELETE',
- url: 'employees/'+id
- })
- }
-
- this.updateEmployee = function updateEmployee(id,name,age){
- return $http({
- method: 'PATCH',
- url: 'employees/'+id,
- data: {name:name, age:age}
- })
- }
-
- this.getAllEmployees = function getAllEmployees(){
- return $http({
- method: 'GET',
- url:'employees'
- });
- }
-
- this.getEmployeesByName = function getEmployeesByName(name){
- return $http({
- method: 'GET',
- url:'employees/search/findByName',
- params:{name:name}
- });
- }
-
-}]);
\ No newline at end of file
diff --git a/spring-rest-angular/src/test/java/org/baeldung/web/service/EmployeeCRUDRepositoryIntegrationTest.java b/spring-rest-angular/src/test/java/org/baeldung/web/service/EmployeeCRUDRepositoryIntegrationTest.java
deleted file mode 100644
index 57fe793596..0000000000
--- a/spring-rest-angular/src/test/java/org/baeldung/web/service/EmployeeCRUDRepositoryIntegrationTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.baeldung.web.service;
-
-import static org.junit.Assert.*;
-
-import org.baeldung.web.entity.Employee;
-import org.baeldung.web.main.Application;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT)
-public class EmployeeCRUDRepositoryIntegrationTest {
-
- @Autowired
- private TestRestTemplate template;
-
- private static final String EMPLOYEE_ENDPOINT = "http://localhost:8080/employees/";
- private static int EMPLOYEE_ID = 1;
- private static int EMPLOYEE_AGE = 25;
-
- @Test
- public void whenEmployeeCRUDOperations_thenCorrect() {
- Employee Employee = new Employee(EMPLOYEE_ID, "Bryan", 20);
- ResponseEntity