Giter Site home page Giter Site logo

gds-swe's Introduction

GDS SWE Mini Project

User Web Application with HTTP endpoints, built with Spring Boot.

Requirements

For building and running the application you need:

Database

The web app uses a H2 in-memory database. It can be changed easily in the application.propertiesfile.

Running the application locally

You'll need Java 8 installed.

 ./mvnw spring-boot:run

To test that it works, open a browser tab at http://localhost:8080/users.
Alternatively, you can run

curl 'http://localhost:8080/users'

Acceptance Requirement 1

1. Return all users

curl 'https://localhost:8080/users'

Expected Response Body:

{
    "results": [
        {
            "name": "John",
            "salary": 2500.05
        },
        {
            "name": "Mary Posa",
            "salary": 4000.0
        },
        {
            "name": "Sally Tan",
            "salary": 1000.0
        }
    ]
}

2. End Point Parameters (Valid)

curl 'http://localhost:8080/users?min=1000&max=3000&sort=salary'

Expected Response Body:

{
    "results": [
        {
            "name": "Sally Tan",
            "salary": 1000.0
        },
        {
            "name": "John",
            "salary": 2500.05
        }
    ]
}

3. End Point Parameters (Invalid)

Run:

curl 'http://localhost:8080/users?sort=birthdate'

Expected Response:

{
    "error": "Illegal Sorting Parameter"
}

Run:

curl 'http://localhost:8080/users?min=onehundred'

Expected Response:

{
    "error": "For input string: \"onehundred\""
}

Acceptance Requirement 2

CSV files can be found in the userapp/csv folder.

1. Upload valid CSV

csv file: acceptance-criteria-2.csv

NAME,SALARY
Peter Parker,0
Tony Stark,1000000
Steve Rogers,2000
Thor,3000.1
Bruce Banner,2100
Tchalla,3999
Natasha Romanoff,2100.83
Thanos,-100
John,1200.05
Mary Posa,1500.15

Run:

curl -F file=@<file_location> http://localhost:8080/upload/

Expected Response:

{
    "Success": 1
}

Validate Response:

Run:

curl 'https://localhost:8080/users/'

Expected Response:

{
    "results": [
        {
            "name": "John",
            "salary": 1200.05
        },
        {
            "name": "Mary Posa",
            "salary": 1500.15
        },
        {
            "name": "Sally Tan",
            "salary": 1000.0
        },
        {
            "name": "Peter Parker",
            "salary": 0.0
        },
        {
            "name": "Steve Rogers",
            "salary": 2000.0
        },
        {
            "name": "Thor",
            "salary": 3000.1
        },
        {
            "name": "Bruce Banner",
            "salary": 2100.0
        },
        {
            "name": "Tchalla",
            "salary": 3999.0
        },
        {
            "name": "Natasha Romanoff",
            "salary": 2100.83
        }
    ]
}

Acceptance Requirement 3

1. Upload invalid CSV File (Salary column has invalid valid type)

csv file: acceptance-criteria-3a.csv

NAME,SALARY
Peter Parker,20
Tony Stark,2000000
Steve Rogers,2000
Thor,3000.1
Bruce Banner,HULK
Tchalla,3999
Natasha Romanoff,2100.83
Thanos,-100
John,1200.05
Mary Posa,1500.15

Run:

curl -F file=@<file_location> http://localhost:8080/upload/

Expected Response:

{
    "Success": 0
}

Validate Response:

Run:

curl 'https://localhost:8080/users/'

Expected Response:

{
    "results": [
        {
            "name": "John",
            "salary": 1200.05
        },
        {
            "name": "Mary Posa",
            "salary": 1500.15
        },
        {
            "name": "Sally Tan",
            "salary": 1000.0
        },
        {
            "name": "Peter Parker",
            "salary": 0.0
        },
        {
            "name": "Steve Rogers",
            "salary": 2000.0
        },
        {
            "name": "Thor",
            "salary": 3000.1
        },
        {
            "name": "Bruce Banner",
            "salary": 2100.0
        },
        {
            "name": "Tchalla",
            "salary": 3999.0
        },
        {
            "name": "Natasha Romanoff",
            "salary": 2100.83
        }
    ]
}

2. Upload invalid CSV File (Extra column)

csv file: acceptance-criteria-3b.csv

NAME,SALARY,ALIAS
Peter Parker,2,Spiderman
Tony Stark,1000000,Ironman
Steve Rogers,3000,Captain America
Thor,3000.1,Thor
Bruce Banner,2100,Hulk
Tchalla,3999,Black Panther
Natasha Romanoff,2100.83,Black Widow
Thanos,-100,Thanos
John,1200.05,Hancock
Mary Posa,1500.15,Poppins

Expected Response:

{
    "Success": 0
}

Validate Response: Same as above

gds-swe's People

Contributors

zulyang avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.