Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SFE committed Jun 24, 2024
0 parents commit 2e1127c
Show file tree
Hide file tree
Showing 19 changed files with 1,456 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!target/*-runner
!target/*-runner.jar
!target/lib/*
!target/quarkus-app/*
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
.flattened-pom.xml

# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode
.factorypath

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Local environment
.env

# Plugin directory
/.quarkus/cli/plugins/
1 change: 1 addition & 0 deletions .mvn/wrapper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maven-wrapper.jar
98 changes: 98 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.IOException;
import java.io.InputStream;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public final class MavenWrapperDownloader
{
private static final String WRAPPER_VERSION = "3.2.0";

private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );

public static void main( String[] args )
{
log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );

if ( args.length != 2 )
{
System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
System.exit( 1 );
}

try
{
log( " - Downloader started" );
final URL wrapperUrl = new URL( args[0] );
final String jarPath = args[1].replace( "..", "" ); // Sanitize path
final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
downloadFileFromURL( wrapperUrl, wrapperJarPath );
log( "Done" );
}
catch ( IOException e )
{
System.err.println( "- Error downloading: " + e.getMessage() );
if ( VERBOSE )
{
e.printStackTrace();
}
System.exit( 1 );
}
}

private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
throws IOException
{
log( " - Downloading to: " + wrapperJarPath );
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
{
final String username = System.getenv( "MVNW_USERNAME" );
final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
Authenticator.setDefault( new Authenticator()
{
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication( username, password );
}
} );
}
try ( InputStream inStream = wrapperUrl.openStream() )
{
Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
}
log( " - Downloader complete" );
}

private static void log( String msg )
{
if ( VERBOSE )
{
System.out.println( msg );
}
}

}
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# hexa-archi-exercise

This repository is a backend project based on `Quarkus` and `MongoDB`, which allows to manipulate todos, thanks to a CRUD API.

## Run the application

In order to run the application, you need to install `java` and `quarkus-cli` in your machine.
Please check the following documentation if it is not already the case:
- https://www.java.com/en/download/help/download_options.html (for java)
- https://quarkus.io/guides/cli-tooling (for quarkus-cli)

Then, you can run the backend in dev using:
```shell script
quarkus dev
```

The application will be available in the port **8080**.

Note that you can test the API using the postman collection located [there](dev%2Fhexa-archi-exercise.postman_collection.json).

## Exercise instructions

Before starting the exercise, you should of course get familiar with [Quarkus](https://quarkus.io/guides/getting-started) and [MongoDB](https://www.mongodb.com/docs/manual/tutorial/getting-started/) basics.

1) As a first task, please edit the API so that we can filter by tag, without considering case matching and accents (ex: 'Santé' should match with 'sante'). Also, we would like to be able to specify multiple tags as a parameter.
2) Then, add 3 users: 'Ewen' & 'Sebastien' (two regular users) and 'Nicolas', (an admin). A regular user should be able to add/modify/delete/get its own todos, while the administrator has full rights. Please update the resources and entities accordingly.
3) Finally, refactor the application to use the [hexagonal infrastructure](https://en.wikipedia.org/wiki/Hexagonal_architecture_(software)). NB: Propose a system to make sure that there is no regression.

Good luck ! ;)
182 changes: 182 additions & 0 deletions dev/hexa-archi-exercise.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"info": {
"_postman_id": "bf40fe17-e343-452d-a3dd-ba154580d089",
"name": "hexa-archi-exercise",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "10486745"
},
"item": [
{
"name": "Get all todos",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{host}}/api/todos",
"host": [
"{{host}}"
],
"path": [
"api",
"todos"
]
}
},
"response": []
},
{
"name": "Get all todos by tag",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{host}}/api/todos?tag={{tag}}",
"host": [
"{{host}}"
],
"path": [
"api",
"todos"
],
"query": [
{
"key": "tag",
"value": "{{tag}}"
}
]
}
},
"response": []
},
{
"name": "Get one todo",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{host}}/api/todos/{{todo_id}}",
"host": [
"{{host}}"
],
"path": [
"api",
"todos",
"{{todo_id}}"
]
}
},
"response": []
},
{
"name": "Delete one todo",
"request": {
"method": "DELETE",
"header": [],
"url": {
"raw": "{{host}}/api/todos/{{todo_id}}",
"host": [
"{{host}}"
],
"path": [
"api",
"todos",
"{{todo_id}}"
]
}
},
"response": []
},
{
"name": "Add one todo",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"title\": \"Brush my teeth\",\n \"tags\": [ \"health\", \"boring\" ],\n \"done\": false\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{host}}/api/todos",
"host": [
"{{host}}"
],
"path": [
"api",
"todos"
]
}
},
"response": []
},
{
"name": "Update one todo",
"request": {
"method": "PUT",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"6671c2707167b70bb531bef2\",\n \"title\": \"Brush my teeth\",\n \"tags\": [ \"health\" ],\n \"done\": true\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{host}}/api/todos",
"host": [
"{{host}}"
],
"path": [
"api",
"todos"
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"packages": {},
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"packages": {},
"exec": [
""
]
}
}
],
"variable": [
{
"key": "host",
"value": "localhost:8080",
"type": "string"
},
{
"key": "todo_id",
"value": "6671c2707167b70bb531bef2"
},
{
"key": "tag",
"value": "health",
"type": "string"
}
]
}
Loading

0 comments on commit 2e1127c

Please sign in to comment.