Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 20 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,21 @@
# Global Line Network Test
Test for Global Line Network

## 1. Technologies Used
- Java 8
- IntelliJ
- Maven
- SpringBoot
- Spring Data JPA
- h2database
- SpringBootTest

## 2. Implementation details
- Implemented services to perfor curd operation for user
- Can be deployed and run through springboot
- Test is added to verify service

## 3. Instalation and Testing
- It is Maven project with spring boot all libs can be added thorugh maven and project can run throgh spring boot
- Service can be called at http://localhost:8080/

<p align="center">
<img src="https://globalline.my/static/logo.png" width="200">
</p>


Thanks for taking the time to do our front-end / full-stack practical coding challenge.

The objective of this challenge is to evaluate your domain knowledge in front-end / full-stack development: code organization, style and best practices.

# Overview:
The main challenge will be to build a simple user management tool that will perform basic CRUD operations on a user. Please use mockups as a reference
about look of the application. There are no business rules & guidelines other than to show us what you’re truly made of. It can be as simple or as complex as you want it to be.

### Prerequisites
There are none :) Our main solutions stack include but not limited to Kotlin, Java, AngularJS, Flutter, Spring...
Feel free to use any languages and technologies you are comfortable with.

## Mockups
<p align="center">
<img src="https://globalline.my/static/1.jpg" width="250">
<img src="https://globalline.my/static/2.jpg" width="250">
<img src="https://globalline.my/static/3.jpg" width="250">
</p>

### Front-end:
- For API please use https://reqres.in/.

### Back-end:
- The API should be similar to https://reqres.in/, performing basic operations for user.

_We'll be happy if you cover application with tests._

### Submission Guidelines
- Please fork the repo and then submit a Pull Request when you are done.
- Instructions must be provided to run the application, install any dependencies, and any other information needed.
- Please use version control and make sure we can see the history of how you went about it, rather than just uploading the complete project to GitHub.

## Questions? ###
Please feel free to reach out and ask any questions while you are working on a solution.
Send your questions to [tech@chimaera.my](mailto:tech@chimaera.my).


Good luck!





2 changes: 2 additions & 0 deletions coding-challenge.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
62 changes: 62 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>org.example</groupId>
<artifactId>coding-challenge</artifactId>
<version>1.0-SNAPSHOT</version>
<name>codingchallenge</name>
<description>codingchallenge</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
13 changes: 13 additions & 0 deletions src/main/java/com/gln/GLNApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.gln;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class GLNApplication {

public static void main(String[] args) {
SpringApplication.run(GLNApplication.class, args);
}

}
50 changes: 50 additions & 0 deletions src/main/java/com/gln/controller/UserController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.gln.controller;

import com.gln.entity.User;
import com.gln.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Optional;


@RestController
@RequestMapping("/user")
public class UserController {

@Autowired
UserService userService;

@PostMapping("/create")
public User saveUser(@RequestBody User user) {
return userService.save(user);
}

@PutMapping("/update")
public User update(@RequestBody User user) {
return userService.save(user);
}

@DeleteMapping("/delete")
public ResponseEntity<User> delete(@RequestBody User user) {
userService.delete(user);
return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

@GetMapping("/{id}")
public ResponseEntity<User> getUser(@PathVariable Long id) {
Optional<User> user = userService.get(id);
if (user.equals(Optional.empty()))
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
else
return new ResponseEntity<>(user.get(), HttpStatus.NOT_FOUND);
}

@GetMapping("list")
public Page<User> getUserList(@RequestParam Integer pageNo) {
return userService.getList(pageNo);
}
}
65 changes: 65 additions & 0 deletions src/main/java/com/gln/entity/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.gln.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class User {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String email;
private String firstName;
private String lastName;
private String avatar;

protected User() {
}

public User(String firstName, String lastName, String email, String avatar) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.avatar = avatar;
}


public Long getId() {
return id;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public String getEmail() {
return email;
}

public String getAvatar() {
return avatar;
}

public void setEmail(String email) {
this.email = email;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public void setAvatar(String avatar) {
this.avatar = avatar;
}
}
8 changes: 8 additions & 0 deletions src/main/java/com/gln/repository/UserRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.gln.repository;

import com.gln.entity.User;
import org.springframework.data.repository.PagingAndSortingRepository;

public interface UserRepository extends PagingAndSortingRepository<User, Long> {

}
38 changes: 38 additions & 0 deletions src/main/java/com/gln/service/UserService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.gln.service;

import com.gln.entity.User;
import com.gln.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class UserService {
@Autowired
UserRepository repository;

public User save(User user) {
return repository.save(user);

}

public void delete(User user) {
repository.delete(user);

}

public Optional<User> get(Long id) {
return repository.findById(id);

}

public Page<User> getList(int pageNo) {
Pageable pageable = PageRequest.of(pageNo, 6);
return repository.findAll(pageable);

}
}
Loading