From b2c7eb0644062f8b44297d563c2fc5f1bdb666af Mon Sep 17 00:00:00 2001
From: "DESKTOP-HM1TM18\\RBTSB" <raghavendra@rbtsb.com>
Date: Sun, 28 May 2023 14:09:03 +0800
Subject: [PATCH 1/8] test

---
 .../codingtest/springbootcodingtest/controller/package-info.java  | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/controller/package-info.java

diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/package-info.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/package-info.java
deleted file mode 100644
index e69de29..0000000

From aca21403c899cefe8e091fc14eb369cd10441b8e Mon Sep 17 00:00:00 2001
From: "DESKTOP-HM1TM18\\RBTSB" <raghavendra@rbtsb.com>
Date: Sun, 28 May 2023 14:13:58 +0800
Subject: [PATCH 2/8] Create entities

---
 pom.xml                                       | 21 ++++-
 .../springbootcodingtest/entity/Project.java  | 47 ++++++++++
 .../springbootcodingtest/entity/Task.java     | 87 +++++++++++++++++++
 .../springbootcodingtest/entity/User.java     | 60 +++++++++++++
 4 files changed, 214 insertions(+), 1 deletion(-)
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Project.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Task.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/entity/User.java

diff --git a/pom.xml b/pom.xml
index b0a6389..4365294 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,8 +27,27 @@
 			<artifactId>spring-boot-starter-test</artifactId>
 			<scope>test</scope>
 		</dependency>
-	</dependencies>
 
+		<dependency>
+			<groupId>org.projectlombok</groupId>
+			<artifactId>lombok</artifactId>
+			<version>1.18.24</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+		</dependency>
+	</dependencies>
 	<build>
 		<plugins>
 			<plugin>
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Project.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Project.java
new file mode 100644
index 0000000..1fb7065
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Project.java
@@ -0,0 +1,47 @@
+package com.accenture.codingtest.springbootcodingtest.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "Project")
+public class Project {
+
+	@Id
+	private String id;
+	private String name;
+
+	public Project() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Project(String id, String name) {
+		super();
+		this.id = id;
+		this.name = name;
+	}
+
+	@Override
+	public String toString() {
+		return "Project [id=" + id + ", name=" + name + "]";
+	}
+
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Task.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Task.java
new file mode 100644
index 0000000..a45c8a2
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Task.java
@@ -0,0 +1,87 @@
+package com.accenture.codingtest.springbootcodingtest.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "Task")
+public class Task {
+	@Id
+	private String id;
+	private String title;
+	private String description;
+	private String status;
+	private String project_id;
+	private String user_id;
+
+	public Task() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	public Task(String id, String title, String description, String status, String project_id, String user_id) {
+		super();
+		this.id = id;
+		this.title = title;
+		this.description = description;
+		this.status = status;
+		this.project_id = project_id;
+		this.user_id = user_id;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	public String getProject_id() {
+		return project_id;
+	}
+
+	public void setProject_id(String project_id) {
+		this.project_id = project_id;
+	}
+
+	public String getUser_id() {
+		return user_id;
+	}
+
+	public void setUser_id(String user_id) {
+		this.user_id = user_id;
+	}
+
+	@Override
+	public String toString() {
+		return "Task [id=" + id + ", title=" + title + ", description=" + description + ", status=" + status
+				+ ", project_id=" + project_id + ", user_id=" + user_id + "]";
+	}
+
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/User.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/User.java
new file mode 100644
index 0000000..cea7fd5
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/User.java
@@ -0,0 +1,60 @@
+package com.accenture.codingtest.springbootcodingtest.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@Entity
+@Table(name = "User")
+@JsonSerialize
+public class User {
+
+	@Id
+	private String id;
+	private String username;
+	private String password;
+
+	public User() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	public User(String id, String username, String password) {
+		super();
+		this.id = id;
+		this.username = username;
+		this.password = password;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	@Override
+	public String toString() {
+		return "User [id=" + id + ", username=" + username + ", password=" + password + "]";
+	}
+
+}

From 2f46db10ee225f6217d69a2ee8429a772df93515 Mon Sep 17 00:00:00 2001
From: "DESKTOP-HM1TM18\\RBTSB" <raghavendra@rbtsb.com>
Date: Sun, 28 May 2023 21:57:09 +0800
Subject: [PATCH 3/8] Create REST APIs

---
 .../constants/Status.java                     |  5 ++
 .../controller/ProjectController.java         | 44 ++++++++++
 .../controller/TaskController.java            | 36 ++++++++
 .../controller/UserController.java            | 16 ++++
 .../repository/ProjectRepository.java         |  7 ++
 .../repository/TaskRepository.java            |  7 ++
 .../repository/UserRepository.java            |  7 ++
 .../service/ProjectService.java               | 65 +++++++++++++++
 .../service/TaskService.java                  | 83 +++++++++++++++++++
 .../service/UserService.java                  | 67 +++++++++++++++
 src/main/resources/application.properties     | 10 +++
 11 files changed, 347 insertions(+)
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/constants/Status.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/controller/TaskController.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/repository/ProjectRepository.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/repository/TaskRepository.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/repository/UserRepository.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/service/ProjectService.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/service/TaskService.java
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/service/UserService.java

diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/constants/Status.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/constants/Status.java
new file mode 100644
index 0000000..f26a4db
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/constants/Status.java
@@ -0,0 +1,5 @@
+package com.accenture.codingtest.springbootcodingtest.constants;
+
+public enum Status {
+    NOT_STARTED, IN_PROGRESS, READY_FOR_TEST, COMPLETED
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
new file mode 100644
index 0000000..12dc41d
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
@@ -0,0 +1,44 @@
+package com.accenture.codingtest.springbootcodingtest.controller;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.accenture.codingtest.springbootcodingtest.entity.Project;
+import com.accenture.codingtest.springbootcodingtest.service.ProjectService;
+
+@RestController
+@RequestMapping("/api")
+public class ProjectController {
+	@Autowired
+	private ProjectService projectService;
+
+	@GetMapping("/v1/projects")
+	public ResponseEntity<List<Project>> getAllProjects() {
+		return projectService.getAllProjects();
+	}
+
+	@GetMapping("/v1/projects/{project_id}")
+	public ResponseEntity<Project> getProjectById(@PathVariable("project_id") String project_id) {
+		return projectService.getProjectById(project_id);
+	}
+
+	@PutMapping("/v1/projects")
+	public ResponseEntity<Project> updateProject(@RequestBody Project project) {
+		return projectService.updateProject(project);
+	}
+
+	@DeleteMapping("/v1/projects/{project_id}")
+	public ResponseEntity<Void> deleteProjectById(@PathVariable("project_id") String project_id) {
+		return projectService.deleteProject(project_id);
+	}
+
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/TaskController.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/TaskController.java
new file mode 100644
index 0000000..bcab6b7
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/TaskController.java
@@ -0,0 +1,36 @@
+package com.accenture.codingtest.springbootcodingtest.controller;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.accenture.codingtest.springbootcodingtest.entity.Task;
+import com.accenture.codingtest.springbootcodingtest.service.TaskService;
+
+@RestController
+@RequestMapping("/api")
+public class TaskController {
+	@Autowired
+	private TaskService taskService;
+
+	@GetMapping("/v1/tasks")
+	public ResponseEntity<List<Task>> getAllTasks() {
+		return taskService.getAllTasks();
+	}
+
+	@GetMapping("/v1/tasks/{task_id}")
+	public ResponseEntity<Task> getTaskById(@PathVariable("task_id") String task_id) {
+		return taskService.getTaskById(task_id);
+	}
+
+	@DeleteMapping("/v1/tasks/{task_id}")
+	public ResponseEntity<Void> deleteTaskById(@PathVariable("task_id") String task_id) {
+		return taskService.deleteTask(task_id);
+	}
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
new file mode 100644
index 0000000..7b3d2d8
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
@@ -0,0 +1,16 @@
+package com.accenture.codingtest.springbootcodingtest.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.accenture.codingtest.springbootcodingtest.service.UserService;
+
+@RestController
+@RequestMapping("/api")
+public class UserController {
+
+	@Autowired
+	private UserService userService;
+
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/ProjectRepository.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/ProjectRepository.java
new file mode 100644
index 0000000..b1a9458
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/ProjectRepository.java
@@ -0,0 +1,7 @@
+package com.accenture.codingtest.springbootcodingtest.repository;
+
+import com.accenture.codingtest.springbootcodingtest.entity.Project;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface ProjectRepository extends JpaRepository<Project, String> {
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/TaskRepository.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/TaskRepository.java
new file mode 100644
index 0000000..2cba613
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/TaskRepository.java
@@ -0,0 +1,7 @@
+package com.accenture.codingtest.springbootcodingtest.repository;
+
+import com.accenture.codingtest.springbootcodingtest.entity.Task;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface TaskRepository extends JpaRepository<Task, String> {
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/UserRepository.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/UserRepository.java
new file mode 100644
index 0000000..046e205
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/UserRepository.java
@@ -0,0 +1,7 @@
+package com.accenture.codingtest.springbootcodingtest.repository;
+
+import com.accenture.codingtest.springbootcodingtest.entity.User;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface UserRepository extends JpaRepository<User, String> {
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/service/ProjectService.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/service/ProjectService.java
new file mode 100644
index 0000000..d0deef1
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/service/ProjectService.java
@@ -0,0 +1,65 @@
+package com.accenture.codingtest.springbootcodingtest.service;
+
+import java.util.List;
+import java.util.Optional;
+
+import com.accenture.codingtest.springbootcodingtest.entity.Project;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import com.accenture.codingtest.springbootcodingtest.repository.ProjectRepository;
+
+@Service
+public class ProjectService {
+	@Autowired
+    private ProjectRepository projectRepository;
+
+    public ResponseEntity<Project> saveProject(Project project) {
+        ResponseEntity<Project> response = null;
+        if (project != null) {
+           response = new ResponseEntity<>(projectRepository.save(project), HttpStatus.OK);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+      return response;
+    }
+    public ResponseEntity<List<Project>> getAllProjects() {
+        return new ResponseEntity<>(projectRepository.findAll(), HttpStatus.OK);
+    }
+
+    public ResponseEntity<Project> getProjectById(String id) {
+        return new ResponseEntity<>(projectRepository.findById(id).get(), HttpStatus.OK);
+    }
+
+    public ResponseEntity<Project> updateProject(Project project) {
+        ResponseEntity<Project> updatedProject = null;
+        String id = project.getId();
+        Optional<Project> oldProjectOp = projectRepository.findById(id);
+
+        if(oldProjectOp.isPresent()) {
+            Project oldProject = oldProjectOp.get();
+
+            oldProject.setName(project.getName());
+            // oldProject.setProject_id(project.getProject_id());
+
+            updatedProject = new ResponseEntity<>(projectRepository.save(oldProject), HttpStatus.OK);
+        } else {
+            updatedProject = new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+
+        return updatedProject;
+    }
+
+    public ResponseEntity<Void> deleteProject(String id) {
+        ResponseEntity<Void> response = null;
+        if (projectRepository.existsById(id)) {
+            projectRepository.deleteById(id);
+            response = new ResponseEntity<>(HttpStatus.OK);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        return response;
+    }
+    
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/service/TaskService.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/service/TaskService.java
new file mode 100644
index 0000000..ab0747e
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/service/TaskService.java
@@ -0,0 +1,83 @@
+package com.accenture.codingtest.springbootcodingtest.service;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import com.accenture.codingtest.springbootcodingtest.constants.Status;
+import com.accenture.codingtest.springbootcodingtest.entity.Task;
+import com.accenture.codingtest.springbootcodingtest.repository.TaskRepository;
+
+@Service
+public class TaskService {
+
+    @Autowired
+    private TaskRepository taskRepository;
+
+    public ResponseEntity<Task> saveTask(Task task) {
+        ResponseEntity<Task> response = null;
+        if (task != null) {
+            //initial status
+            task.setStatus(Status.NOT_STARTED.toString());
+           response = new ResponseEntity<>(taskRepository.save(task), HttpStatus.OK);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+      return response;
+    }
+    public ResponseEntity<List<Task>> getAllTasks() {
+        return new ResponseEntity<>(taskRepository.findAll(), HttpStatus.OK);
+    }
+
+    public ResponseEntity<Task> getTaskById(String id) {
+        return new ResponseEntity<>(taskRepository.findById(id).get(), HttpStatus.OK);
+    }
+
+    public ResponseEntity<Task> updateTask(Task task) {
+        ResponseEntity<Task> updatedTask = null;
+        String id = task.getId();
+        Optional<Task> oldTaskOp = taskRepository.findById(id);
+
+        if(oldTaskOp.isPresent()) {
+            Task oldTask = oldTaskOp.get();
+
+            oldTask.setDescription(task.getDescription());
+            oldTask.setTitle(task.getTitle());
+            oldTask.setStatus(task.getStatus());
+            oldTask.setUser_id(task.getUser_id());
+           // oldTask.setProject_id(task.getProject_id());
+
+            updatedTask = new ResponseEntity<>(taskRepository.save(oldTask), HttpStatus.OK);
+        } else {
+            updatedTask = new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+
+        return updatedTask;
+    }
+    public ResponseEntity<Task> updateTask(Task task, String userId) {
+        ResponseEntity<Task> response = null;
+        Optional<Task> taskRes = taskRepository.findById(task.getId());
+        if (taskRes.isPresent()) {
+            if (taskRes.get().getUser_id().equalsIgnoreCase(userId)) {
+                taskRes.get().setStatus(task.getStatus());
+                response =new ResponseEntity<>(taskRepository.save(taskRes.get()), HttpStatus.OK);
+            }
+        }
+      return response;
+    }
+
+    public ResponseEntity<Void> deleteTask(String id) {
+        ResponseEntity<Void> response = null;
+        if (taskRepository.existsById(id)) {
+            taskRepository.deleteById(id);
+            response = new ResponseEntity<>(HttpStatus.OK);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        return response;
+    }
+}
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/service/UserService.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/service/UserService.java
new file mode 100644
index 0000000..9230755
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/service/UserService.java
@@ -0,0 +1,67 @@
+package com.accenture.codingtest.springbootcodingtest.service;
+
+import com.accenture.codingtest.springbootcodingtest.entity.User;
+import com.accenture.codingtest.springbootcodingtest.repository.UserRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+@Service
+public class UserService {
+
+    @Autowired
+    private UserRepository userRepository;
+
+    public ResponseEntity<User> saveUser(User user) {
+        ResponseEntity<User> response = null;
+        if (user != null) {
+           response = new ResponseEntity<>(userRepository.save(user), HttpStatus.OK);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+      return response;
+    }
+
+
+    public ResponseEntity<List<User>> getAllUsers() {
+        return new ResponseEntity<>(userRepository.findAll(), HttpStatus.OK);
+    }
+
+    public ResponseEntity<User> getUserById(String id) {
+           return new ResponseEntity<>(userRepository.findById(id).get(), HttpStatus.OK);
+    }
+
+    public ResponseEntity<User> updateUser(User user) {
+        ResponseEntity<User> updatedUser = null;
+        String id = user.getId();
+        Optional<User> oldUserOp = userRepository.findById(id);
+
+        if(oldUserOp.isPresent()) {
+            User oldUser = oldUserOp.get();
+
+            oldUser.setUsername(user.getUsername());
+            oldUser.setPassword(user.getPassword());
+
+            updatedUser = new ResponseEntity<>(userRepository.save(oldUser), HttpStatus.OK);
+        } else {
+            updatedUser = new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+
+        return updatedUser;
+    }
+
+    public ResponseEntity<Void> deleteUser(String id) {
+        ResponseEntity<Void> response = null;
+        if (userRepository.existsById(id)) {
+            userRepository.deleteById(id);
+            response = new ResponseEntity<>(HttpStatus.OK);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        return response;
+    }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 8b13789..9991ffb 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1 +1,11 @@
+spring.datasource.url=jdbc:mysql://localhost:3306/test
+#spring.datasource.driverClassName=com.mysql.jdbc.Driver
+spring.datasource.username=root
+spring.datasource.password=123456
+
+
+
+spring.jpa.show-sql=true
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
+spring.jpa.hibernate.ddl-auto= update
 

From 176ad89deba0103c06bfa34af2461a86b9739033 Mon Sep 17 00:00:00 2001
From: "DESKTOP-HM1TM18\\RBTSB" <raghavendra@rbtsb.com>
Date: Sun, 28 May 2023 22:17:46 +0800
Subject: [PATCH 4/8] test

---
 .../springbootcodingtest/controller/UserController.java         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
index 7b3d2d8..2672863 100644
--- a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
@@ -11,6 +11,6 @@
 public class UserController {
 
 	@Autowired
-	private UserService userService;
+	private UserService userService; 
 
 }

From 01ccc3310a444ae1007c01e40f0f2730a76cb82d Mon Sep 17 00:00:00 2001
From: "DESKTOP-HM1TM18\\RBTSB" <raghavendra@rbtsb.com>
Date: Sun, 28 May 2023 22:20:22 +0800
Subject: [PATCH 5/8] Implement features

---
 .../controller/ProjectController.java         | 57 +++++++++-----
 .../controller/TaskController.java            | 76 ++++++++++++++-----
 .../controller/UserController.java            | 71 +++++++++++++++--
 .../springbootcodingtest/model/Role.java      |  7 ++
 4 files changed, 164 insertions(+), 47 deletions(-)
 create mode 100644 src/main/java/com/accenture/codingtest/springbootcodingtest/model/Role.java

diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
index 12dc41d..c0e2fb5 100644
--- a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
@@ -3,42 +3,57 @@
 import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.accenture.codingtest.springbootcodingtest.entity.Project;
+import com.accenture.codingtest.springbootcodingtest.model.Role;
 import com.accenture.codingtest.springbootcodingtest.service.ProjectService;
 
 @RestController
 @RequestMapping("/api")
 public class ProjectController {
 	@Autowired
-	private ProjectService projectService;
-
-	@GetMapping("/v1/projects")
-	public ResponseEntity<List<Project>> getAllProjects() {
-		return projectService.getAllProjects();
-	}
-
-	@GetMapping("/v1/projects/{project_id}")
-	public ResponseEntity<Project> getProjectById(@PathVariable("project_id") String project_id) {
-		return projectService.getProjectById(project_id);
-	}
-
-	@PutMapping("/v1/projects")
-	public ResponseEntity<Project> updateProject(@RequestBody Project project) {
-		return projectService.updateProject(project);
-	}
-
-	@DeleteMapping("/v1/projects/{project_id}")
-	public ResponseEntity<Void> deleteProjectById(@PathVariable("project_id") String project_id) {
-		return projectService.deleteProject(project_id);
-	}
+    private ProjectService projectService;
+
+    @GetMapping("/v1/projects")
+    public ResponseEntity<List<Project>> getAllProjects() {
+        return projectService.getAllProjects();
+    }
+
+    @PostMapping("/v1/projects/{role}")
+    public  ResponseEntity<Project> saveProject(@RequestBody Project project,
+                                                @PathVariable("role") String role) {
+        ResponseEntity<Project> response;
+        if(Role.ADMIN.toString().equalsIgnoreCase(role)) {
+            response = projectService.saveProject(project);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return  response;
+    }
+
+    @GetMapping("/v1/projects/{project_id}")
+    public ResponseEntity<Project> getProjectById(@PathVariable("project_id") String project_id) {
+        return projectService.getProjectById(project_id);
+    }
+
+    @PutMapping("/v1/projects")
+    public  ResponseEntity<Project> updateProject(@RequestBody Project project) {
+        return  projectService.updateProject(project);
+    }
+
+    @DeleteMapping("/v1/projects/{project_id}")
+    public ResponseEntity<Void> deleteProjectById(@PathVariable("project_id") String project_id) {
+        return projectService.deleteProject(project_id);
+    }
 
 }
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/TaskController.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/TaskController.java
index bcab6b7..d897f2b 100644
--- a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/TaskController.java
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/TaskController.java
@@ -2,13 +2,11 @@
 
 import java.util.List;
 
+import com.accenture.codingtest.springbootcodingtest.model.Role;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import com.accenture.codingtest.springbootcodingtest.entity.Task;
 import com.accenture.codingtest.springbootcodingtest.service.TaskService;
@@ -17,20 +15,56 @@
 @RequestMapping("/api")
 public class TaskController {
 	@Autowired
-	private TaskService taskService;
-
-	@GetMapping("/v1/tasks")
-	public ResponseEntity<List<Task>> getAllTasks() {
-		return taskService.getAllTasks();
-	}
-
-	@GetMapping("/v1/tasks/{task_id}")
-	public ResponseEntity<Task> getTaskById(@PathVariable("task_id") String task_id) {
-		return taskService.getTaskById(task_id);
-	}
-
-	@DeleteMapping("/v1/tasks/{task_id}")
-	public ResponseEntity<Void> deleteTaskById(@PathVariable("task_id") String task_id) {
-		return taskService.deleteTask(task_id);
-	}
+    private TaskService taskService;
+
+    @GetMapping("/v1/tasks")
+    public ResponseEntity<List<Task>> getAllTasks() {
+        return taskService.getAllTasks();
+    }
+
+    @PostMapping("/v1/tasks/{role}")
+    public  ResponseEntity<Task> saveTask(@RequestBody Task task, @PathVariable("role") String role) {
+        ResponseEntity<Task> response = null;
+        if(Role.PRODUCT_OWNER.toString().equalsIgnoreCase(role)) {
+            response = taskService.saveTask(task);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return response;
+    }
+
+    @GetMapping("/v1/tasks/{task_id}")
+    public ResponseEntity<Task> getTaskById(@PathVariable("task_id") String task_id) {
+        return taskService.getTaskById(task_id);
+    }
+
+    @PatchMapping("/v1/tasks/{role}")
+    public  ResponseEntity<Task> updateTask(@RequestBody Task task,
+                                            @PathVariable("userId") String userId,
+                                            @PathVariable("role") String role) {
+        ResponseEntity<Task> response = null;
+        if(Role.PRODUCT_OWNER.toString().equalsIgnoreCase(role)) {
+            response = taskService.updateTask(task, userId);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return response;
+    }
+
+    @PutMapping("/v1/tasks/{role}")
+    public  ResponseEntity<Task> updateTask(@RequestBody Task task, @PathVariable("role") String role) {
+        ResponseEntity<Task> response = null;
+        if(Role.PRODUCT_OWNER.toString().equalsIgnoreCase(role)) {
+            response = taskService.updateTask(task);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return  response;
+    }
+
+
+    @DeleteMapping("/v1/tasks/{task_id}")
+    public ResponseEntity<Void> deleteTaskById(@PathVariable("task_id") String task_id) {
+        return taskService.deleteTask(task_id);
+    }
 }
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
index 2672863..65099d1 100644
--- a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/UserController.java
@@ -1,16 +1,77 @@
 package com.accenture.codingtest.springbootcodingtest.controller;
 
+import com.accenture.codingtest.springbootcodingtest.entity.User;
+import com.accenture.codingtest.springbootcodingtest.model.Role;
+import com.accenture.codingtest.springbootcodingtest.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
 
-import com.accenture.codingtest.springbootcodingtest.service.UserService;
+import java.util.List;
 
 @RestController
 @RequestMapping("/api")
 public class UserController {
 
-	@Autowired
-	private UserService userService; 
+    @Autowired
+    private UserService userService;
+
+    @GetMapping("/v1/users/{role}")
+    public ResponseEntity<List<User>> getAllUsers(@PathVariable("role") String role) {
+        ResponseEntity<List<User>> response = null;
+        if(Role.ADMIN.toString().equalsIgnoreCase(role)) {
+            response = userService.getAllUsers();
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return response;
+    }
+
+    @GetMapping("/v1/users/{user_id}/{role}")
+    public ResponseEntity<User> getUserById(@PathVariable("user_id") String user_id,
+                                            @PathVariable("role") String role) {
+        ResponseEntity<User> response = null;
+        if(Role.ADMIN.toString().equalsIgnoreCase(role)) {
+            response = userService.getUserById(user_id);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return response;
+    }
+
+    @PostMapping("/v1/users/{role}")
+    public  ResponseEntity<User> saveUser(@RequestBody User user, @PathVariable("role") String role) {
+
+        ResponseEntity<User> response = null;
+        if(Role.ADMIN.toString().equalsIgnoreCase(role)) {
+            response = userService.saveUser(user);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return  response;
+    }
+
+    @PutMapping("/v1/users")
+    public  ResponseEntity<User> updateUser(@RequestBody User user, @PathVariable("role") String role) {
+        ResponseEntity<User> response = null;
+        if(Role.ADMIN.toString().equalsIgnoreCase(role)) {
+            response = userService.updateUser(user);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return  response;
+    }
 
+    @DeleteMapping("/v1/users/{user_id}")
+    public ResponseEntity<Void> deleteUserById(@PathVariable("user_id") String user_id,
+                                               @PathVariable("role") String role) {
+        ResponseEntity<Void> response;
+        if(Role.ADMIN.toString().equalsIgnoreCase(role)) {
+            response = userService.deleteUser(user_id);
+        } else {
+            response = new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
+        }
+        return response;
+    }
 }
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/model/Role.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/model/Role.java
new file mode 100644
index 0000000..7348574
--- /dev/null
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/model/Role.java
@@ -0,0 +1,7 @@
+package com.accenture.codingtest.springbootcodingtest.model;
+
+public enum Role {
+    ADMIN,
+    PRODUCT_OWNER
+    
+}

From 174a2b140025c5bf5af334a456ce8b26bc362c6e Mon Sep 17 00:00:00 2001
From: "DESKTOP-HM1TM18\\RBTSB" <raghavendra@rbtsb.com>
Date: Mon, 29 May 2023 12:39:17 +0800
Subject: [PATCH 6/8] Write test

---
 .../ProjectCreationTest.java                  | 39 ++++++++++++++++
 .../TaskStatusChangeTest.java                 | 35 +++++++++++++++
 .../UserCreationTest.java                     | 44 +++++++++++++++++++
 3 files changed, 118 insertions(+)
 create mode 100644 src/test/java/com/accenture/codingtest/springbootcodingtest/ProjectCreationTest.java
 create mode 100644 src/test/java/com/accenture/codingtest/springbootcodingtest/TaskStatusChangeTest.java
 create mode 100644 src/test/java/com/accenture/codingtest/springbootcodingtest/UserCreationTest.java

diff --git a/src/test/java/com/accenture/codingtest/springbootcodingtest/ProjectCreationTest.java b/src/test/java/com/accenture/codingtest/springbootcodingtest/ProjectCreationTest.java
new file mode 100644
index 0000000..5b0a747
--- /dev/null
+++ b/src/test/java/com/accenture/codingtest/springbootcodingtest/ProjectCreationTest.java
@@ -0,0 +1,39 @@
+package com.accenture.codingtest.springbootcodingtest;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import com.accenture.codingtest.springbootcodingtest.entity.Project;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class ProjectCreationTest {
+
+	@LocalServerPort
+	private int port;
+
+	private final TestRestTemplate restTemplate = new TestRestTemplate();
+
+	@Test
+	public void createProjectAndAssignUsersTest() {
+		// Prepare the request body for creating a project
+		Project project = new Project("123", "Sample project");
+
+		// Send the POST request to create a project
+		ResponseEntity<Project> createProjectResponse = restTemplate
+				.postForEntity(getBaseUrl() + "/api/v1/projects/ADMIN", project, Project.class);
+
+		// Assert the response status code is 200 OK
+		assertEquals(HttpStatus.OK, createProjectResponse.getStatusCode());
+
+	}
+
+	private String getBaseUrl() {
+		return "http://localhost:" + port;
+	}
+}
diff --git a/src/test/java/com/accenture/codingtest/springbootcodingtest/TaskStatusChangeTest.java b/src/test/java/com/accenture/codingtest/springbootcodingtest/TaskStatusChangeTest.java
new file mode 100644
index 0000000..27d22d5
--- /dev/null
+++ b/src/test/java/com/accenture/codingtest/springbootcodingtest/TaskStatusChangeTest.java
@@ -0,0 +1,35 @@
+package com.accenture.codingtest.springbootcodingtest;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import com.accenture.codingtest.springbootcodingtest.entity.User;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class TaskStatusChangeTest {
+
+	@LocalServerPort
+	private int port;
+
+	private final TestRestTemplate restTemplate = new TestRestTemplate();
+
+	@Test
+	public void changeTaskStatusTest() {
+		// Create a user
+		User user = new User("123", "test@example.com", "test");
+		ResponseEntity<User> createUserResponse = restTemplate.postForEntity(getBaseUrl() + "/api/v1/users/ADMIN", user,
+				User.class);
+		assertEquals(HttpStatus.OK, createUserResponse.getStatusCode());
+
+	}
+
+	private String getBaseUrl() {
+		return "http://localhost:" + port;
+	}
+}
diff --git a/src/test/java/com/accenture/codingtest/springbootcodingtest/UserCreationTest.java b/src/test/java/com/accenture/codingtest/springbootcodingtest/UserCreationTest.java
new file mode 100644
index 0000000..655c9c2
--- /dev/null
+++ b/src/test/java/com/accenture/codingtest/springbootcodingtest/UserCreationTest.java
@@ -0,0 +1,44 @@
+package com.accenture.codingtest.springbootcodingtest;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import com.accenture.codingtest.springbootcodingtest.entity.User;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class UserCreationTest {
+
+	@LocalServerPort
+	private int port;
+
+	private final TestRestTemplate restTemplate = new TestRestTemplate();
+
+	@Test
+	public void createUserTest() {
+		// Prepare the request body for creating a user
+		User user = new User("123", "abc@example.com", "test");
+
+		// Send the POST request to create a user
+		ResponseEntity<User> response = restTemplate.postForEntity(getBaseUrl() + "/api/v1/users/ADMIN", user,
+				User.class);
+
+		// Assert the response status code is 201 Created
+		assertEquals(HttpStatus.OK, response.getStatusCode());
+
+		// Assert the response body contains the created user
+		User createdUser = response.getBody();
+		assertEquals(user.getUsername(), createdUser.getUsername());
+		assertEquals(user.getPassword(), createdUser.getPassword());
+	}
+
+	private String getBaseUrl() {
+		return "http://localhost:" + port;
+	}
+
+}

From 8f13c89e2b9f2ef2b0ed7f3cb320057b0cc5be60 Mon Sep 17 00:00:00 2001
From: "DESKTOP-HM1TM18\\RBTSB" <raghavendra@rbtsb.com>
Date: Mon, 29 May 2023 12:44:39 +0800
Subject: [PATCH 7/8] Implement pagination

---
 .../controller/ProjectController.java         |  23 ++++
 .../repository/ProjectRepository.java         |   8 +-
 .../service/ProjectService.java               | 112 ++++++++++--------
 3 files changed, 92 insertions(+), 51 deletions(-)

diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
index c0e2fb5..f6a00c7 100644
--- a/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/controller/ProjectController.java
@@ -3,6 +3,9 @@
 import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -12,6 +15,7 @@
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.accenture.codingtest.springbootcodingtest.entity.Project;
@@ -55,5 +59,24 @@ public  ResponseEntity<Project> updateProject(@RequestBody Project project) {
     public ResponseEntity<Void> deleteProjectById(@PathVariable("project_id") String project_id) {
         return projectService.deleteProject(project_id);
     }
+    
+    @GetMapping
+	public Page<Project> getProjects(@RequestParam(value = "q", required = false) String searchKeyword, @RequestParam(value = "pageIndex", defaultValue = "0") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "3") int pageSize,
+			@RequestParam(value = "sortBy", defaultValue = "name") String sortBy, @RequestParam(value = "sortDirection", defaultValue = "ASC") String sortDirection) {
+
+		Sort.Direction direction = Sort.Direction.ASC;
+		if (sortDirection.equalsIgnoreCase("DESC")) {
+			direction = Sort.Direction.DESC;
+		}
+
+		Sort sort = Sort.by(direction, sortBy);
+		PageRequest pageRequest = PageRequest.of(pageIndex, pageSize, sort);
+
+		if (searchKeyword != null && !searchKeyword.isEmpty()) {
+			return projectService.searchProjectsByName(searchKeyword, pageRequest);
+		} else {
+			return projectService.getAllProjects(pageRequest);
+		}
+	}
 
 }
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/ProjectRepository.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/ProjectRepository.java
index b1a9458..893af7c 100644
--- a/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/ProjectRepository.java
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/repository/ProjectRepository.java
@@ -1,7 +1,13 @@
 package com.accenture.codingtest.springbootcodingtest.repository;
 
-import com.accenture.codingtest.springbootcodingtest.entity.Project;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 
+import com.accenture.codingtest.springbootcodingtest.entity.Project;
+
 public interface ProjectRepository extends JpaRepository<Project, String> {
+
+	Page<Project> findByNameContainingIgnoreCase(String name, Pageable pageable);
+
 }
diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/service/ProjectService.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/service/ProjectService.java
index d0deef1..42972ba 100644
--- a/src/main/java/com/accenture/codingtest/springbootcodingtest/service/ProjectService.java
+++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/service/ProjectService.java
@@ -3,63 +3,75 @@
 import java.util.List;
 import java.util.Optional;
 
-import com.accenture.codingtest.springbootcodingtest.entity.Project;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
+
+import com.accenture.codingtest.springbootcodingtest.entity.Project;
 import com.accenture.codingtest.springbootcodingtest.repository.ProjectRepository;
 
 @Service
 public class ProjectService {
 	@Autowired
-    private ProjectRepository projectRepository;
-
-    public ResponseEntity<Project> saveProject(Project project) {
-        ResponseEntity<Project> response = null;
-        if (project != null) {
-           response = new ResponseEntity<>(projectRepository.save(project), HttpStatus.OK);
-        } else {
-            response = new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
-        }
-      return response;
-    }
-    public ResponseEntity<List<Project>> getAllProjects() {
-        return new ResponseEntity<>(projectRepository.findAll(), HttpStatus.OK);
-    }
-
-    public ResponseEntity<Project> getProjectById(String id) {
-        return new ResponseEntity<>(projectRepository.findById(id).get(), HttpStatus.OK);
-    }
-
-    public ResponseEntity<Project> updateProject(Project project) {
-        ResponseEntity<Project> updatedProject = null;
-        String id = project.getId();
-        Optional<Project> oldProjectOp = projectRepository.findById(id);
-
-        if(oldProjectOp.isPresent()) {
-            Project oldProject = oldProjectOp.get();
-
-            oldProject.setName(project.getName());
-            // oldProject.setProject_id(project.getProject_id());
-
-            updatedProject = new ResponseEntity<>(projectRepository.save(oldProject), HttpStatus.OK);
-        } else {
-            updatedProject = new ResponseEntity<>(HttpStatus.NOT_FOUND);
-        }
-
-        return updatedProject;
-    }
-
-    public ResponseEntity<Void> deleteProject(String id) {
-        ResponseEntity<Void> response = null;
-        if (projectRepository.existsById(id)) {
-            projectRepository.deleteById(id);
-            response = new ResponseEntity<>(HttpStatus.OK);
-        } else {
-            response = new ResponseEntity<>(HttpStatus.NOT_FOUND);
-        }
-        return response;
-    }
-    
+	private ProjectRepository projectRepository;
+
+	public ResponseEntity<Project> saveProject(Project project) {
+		ResponseEntity<Project> response = null;
+		if (project != null) {
+			response = new ResponseEntity<>(projectRepository.save(project), HttpStatus.OK);
+		} else {
+			response = new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+		}
+		return response;
+	}
+
+	public ResponseEntity<List<Project>> getAllProjects() {
+		return new ResponseEntity<>(projectRepository.findAll(), HttpStatus.OK);
+	}
+
+	public ResponseEntity<Project> getProjectById(String id) {
+		return new ResponseEntity<>(projectRepository.findById(id).get(), HttpStatus.OK);
+	}
+
+	public ResponseEntity<Project> updateProject(Project project) {
+		ResponseEntity<Project> updatedProject = null;
+		String id = project.getId();
+		Optional<Project> oldProjectOp = projectRepository.findById(id);
+
+		if (oldProjectOp.isPresent()) {
+			Project oldProject = oldProjectOp.get();
+
+			oldProject.setName(project.getName());
+			// oldProject.setProject_id(project.getProject_id());
+
+			updatedProject = new ResponseEntity<>(projectRepository.save(oldProject), HttpStatus.OK);
+		} else {
+			updatedProject = new ResponseEntity<>(HttpStatus.NOT_FOUND);
+		}
+
+		return updatedProject;
+	}
+
+	public ResponseEntity<Void> deleteProject(String id) {
+		ResponseEntity<Void> response = null;
+		if (projectRepository.existsById(id)) {
+			projectRepository.deleteById(id);
+			response = new ResponseEntity<>(HttpStatus.OK);
+		} else {
+			response = new ResponseEntity<>(HttpStatus.NOT_FOUND);
+		}
+		return response;
+	}
+
+	public Page<Project> searchProjectsByName(String searchKeyword, Pageable pageable) {
+		return projectRepository.findByNameContainingIgnoreCase(searchKeyword, pageable);
+	}
+
+	public Page<Project> getAllProjects(Pageable pageable) {
+		return projectRepository.findAll(pageable);
+	}
+
 }

From 41e593bd4bfcec454808dada6188e7f38e687d3a Mon Sep 17 00:00:00 2001
From: "DESKTOP-HM1TM18\\RBTSB" <raghavendra@rbtsb.com>
Date: Mon, 29 May 2023 14:51:31 +0800
Subject: [PATCH 8/8] "Add postman collection

---
 docs/Test.postman_collection.json | 422 ++++++++++++++++++++++++++++++
 1 file changed, 422 insertions(+)
 create mode 100644 docs/Test.postman_collection.json

diff --git a/docs/Test.postman_collection.json b/docs/Test.postman_collection.json
new file mode 100644
index 0000000..af7f6b7
--- /dev/null
+++ b/docs/Test.postman_collection.json
@@ -0,0 +1,422 @@
+{
+	"info": {
+		"_postman_id": "46d4fbb1-6fba-4a9e-afae-b98ccd86217d",
+		"name": "Test",
+		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
+		"_exporter_id": "1035454"
+	},
+	"item": [
+		{
+			"name": "User",
+			"item": [
+				{
+					"name": "get all users",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api/v1/users/ADMIN",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"users",
+								"ADMIN"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "get user by id",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api/v1/users/1/ADMIN",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"users",
+								"1",
+								"ADMIN"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "save users",
+					"request": {
+						"method": "POST",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"id\":\"123\",\r\n    \"username\":\"123\",\r\n    \"password\":\"234\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8082/api/v1/users/ADMIN",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"users",
+								"ADMIN"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "update users",
+					"request": {
+						"method": "PUT",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"id\":\"123\",\r\n    \"username\":\"123\",\r\n    \"password\":\"234\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8082/api/v1/users",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"users"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "delete user",
+					"request": {
+						"method": "DELETE",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api/v1/users/123/ADMIN",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"users",
+								"123",
+								"ADMIN"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		},
+		{
+			"name": "Tasks",
+			"item": [
+				{
+					"name": "get all tasks",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api/v1/tasks",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"tasks"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "get tasks by id",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api/v1/tasks/1",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"tasks",
+								"1"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "save tasks",
+					"request": {
+						"method": "POST",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"id\": \"123\",\r\n    \"title\": \"test\",\r\n    \"description\": \"erty\",\r\n    \"status\": \"erty\",\r\n    \"project_id\": \"234\",\r\n    \"user_id\": \"324\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8082/api/v1/tasks/PRODUCT_OWNER",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"tasks",
+								"PRODUCT_OWNER"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "update tasks",
+					"request": {
+						"method": "PUT",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"id\": \"123\",\r\n    \"title\": \"test\",\r\n    \"description\": \"erty\",\r\n    \"status\": \"erty\",\r\n    \"project_id\": \"234\",\r\n    \"user_id\": \"324\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8082/api/v1/tasks/PRODUCT_OWNER",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"tasks",
+								"PRODUCT_OWNER"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "delete tasks",
+					"request": {
+						"method": "DELETE",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api/v1/tasks/123",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"tasks",
+								"123"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		},
+		{
+			"name": "Projects",
+			"item": [
+				{
+					"name": "pagination",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api?pageIndex=0&pageSize=3&sortDirection=ASC&q=Nikhila",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api"
+							],
+							"query": [
+								{
+									"key": "pageIndex",
+									"value": "0"
+								},
+								{
+									"key": "pageSize",
+									"value": "3"
+								},
+								{
+									"key": "sortDirection",
+									"value": "ASC"
+								},
+								{
+									"key": "q",
+									"value": "Nikhila"
+								}
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "get projects",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api/v1/projects",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"projects"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "get projects by id",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "http://localhost:8082/api/v1/projects/1",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"projects",
+								"1"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "save projects by admin",
+					"request": {
+						"method": "POST",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"id\":\"1\",\r\n    \"name\":\"Test\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8082/api/v1/projects/ADMIN",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"projects",
+								"ADMIN"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "update projects",
+					"request": {
+						"method": "PUT",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"id\":\"1\",\r\n    \"name\":\"Test\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8082/api/v1/projects",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8082",
+							"path": [
+								"api",
+								"v1",
+								"projects"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		}
+	]
+}
\ No newline at end of file