refractor package & adapte to framework

This commit is contained in:
jeffcheasey88 2023-08-29 16:46:50 +02:00
parent 5481dbd2cf
commit 50dacdff15
48 changed files with 399 additions and 1119 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,110 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Class {
private static Pattern PATTERN = Pattern.compile("^(\\s*([^\\{]*)\\{(.*)\\})\\s*$");
private int modifier;
private String name;
private List<Variable> vars;
private List<Function> functions;
public Class(){}
public int parse(String content) throws Exception{
Matcher matcher = PATTERN.matcher(content);
matcher.matches();
String[] split = matcher.group(2).split("\\s+");
for(int i = 0; i < split.length-1; i++){
this.modifier+=JavaParser.getModifier(split[i]);
}
this.name = split[split.length-1];
this.vars = new ArrayList<>();
this.functions = new ArrayList<>();
content = matcher.group(3);
Pattern empty = Pattern.compile("^\\s*$");
while(!(empty.matcher(content).matches())){
int quotes = indexOf(content,";");
int braces = indexOf(content,"\\{");
int equals = indexOf(content,"=");
if(quotes < braces && quotes < equals){
boolean quote = false;
Variable last = null;
do {
Variable variable = (last == null) ? new Variable() : new Variable(last.getModifier(), last.getType());
int index = variable.parse(content);
this.vars.add(variable);
content = content.substring(index);
quote = content.startsWith(",");
if(quote) {
content = content.substring(1);
last = variable;
}
}while(quote);
}else if(equals < braces){
//variable with value
boolean quote = false;
Variable last = null;
do {
Variable variable = (last == null) ? new Variable() : new Variable(last.getModifier(), last.getType());
int index = variable.parse(content);
this.vars.add(variable);
content = content.substring(index);
quote = content.startsWith(",");
if(quote) {
content = content.substring(1);
last = variable;
}else if(indexOf(content, "=") < indexOf(content, ";")){
Operation operation = new Operation();
index = operation.parse(content);
content = content.substring(index);
break;
}
}while(quote);
}else{
System.out.println("Function "+content);
Function func = new Function();
int index = func.parse(content);
this.functions.add(func);
content = content.substring(index);
System.out.println("End "+content);
}
}
return matcher.group(1).length();
}
private int indexOf(String value, String target){
return value.split(target)[0].length();
}
public int getModifier(){
return this.modifier;
}
public String getName(){
return this.name;
}
public List<Variable> getVariables(){
return this.vars;
}
public void show(){
System.out.println(Modifier.toString(modifier)+" "+this.name+"{");
for(Variable v : this.vars) v.show(1);
System.out.println();
for(Function f : this.functions) f.show(1);
System.out.println("}");
}
}

View file

@ -1,94 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class CleanerPool {
private static String CONSTANT_REPLACER_STRING = "$STRING_STATEMENT_CONSTANT_";
private static String CONSTANT_REPLACER_CHAR = "$CHAR_STATEMENT_CONSTANT_";
private static String CONSTANT_REPLACER_GENERIC = "$GENERIC_STATEMENT_CONSTANT_";
private List<String> constants;
private CleanerPool(){
this.constants = new ArrayList<>();
}
public String clean(String statement){
char[] chars = statement.toCharArray();
StringBuilder builder = new StringBuilder();
for(int i = 0; i < chars.length; i++){
char current = chars[i];
if(current== '"'){
int constantPos = this.constants.size();
String constant = cutConstant(chars, i);
i+=constant.length()+1;
builder.append(CONSTANT_REPLACER_STRING+constantPos);
this.constants.add(constant);
}else{
builder.append(current);
}
}
for(String s : constants){
System.out.println("CONSTANT="+s);
}
return builder.toString();
}
public boolean isConstant(String region){
return region.startsWith(CONSTANT_REPLACER_STRING);
}
public String getConstant(String replacer){
if(!replacer.startsWith(CONSTANT_REPLACER_STRING)) return null;
return this.constants.get(Integer.parseInt(replacer.replace(CONSTANT_REPLACER_STRING,"")));
}
public List<String> getConstants(){
return this.constants;
}
private static Pattern parenthesisPattern = Pattern.compile("^\\$SQL_STATEMENT_PARENTHESIS_([0-9]*$)");
public boolean isParenthesis(String region){
return parenthesisPattern.matcher(region).matches();
}
private String cutConstant(char[] chars, int pos){
StringBuilder builder = new StringBuilder();
for(int i = pos+1; i < chars.length; i++){
char current = chars[i];
if(current == '"'){
if(current == '\\'){ //toChange
builder.append(current);
}else break;
}else{
builder.append(current);
}
}
return builder.toString();
}
public static interface Cutter{
String execute(String value, List<String> constants, String pattern);
default String cutOpenable(String value, List<String> constants, String pattern, char open, char close){
StringBuilder builder = new StringBuilder();
for(char c : value.toCharArray()){
if(c == open){
}else if(c == close){
}
}
return builder.toString();
}
}
}

View file

@ -1,85 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Function {
private static Pattern PATTERN = Pattern.compile("^(\\s*([^(]*)\\(([^)]*)\\)\\s*([^{]*)\\{)(.*)$");
private int modifier;
private String name;
private String exceptions;
private String parameters;
private List<Function> functions;
private List<Operation> operations;
public Function(){
this.functions = new ArrayList<>();
this.operations = new ArrayList<>();
}
public int parse(String content) throws Exception{
Matcher matcher = PATTERN.matcher(content);
matcher.matches();
String[] split = matcher.group(2).split("\\s+");
for(int i = 0; i < split.length-2; i++){
this.modifier+=JavaParser.getModifier(split[i]);
}
this.name = split[split.length-1];
this.parameters = matcher.group(3);
this.exceptions = matcher.group(4);
String body = matcher.group(5);
int offset = 0;
int index = 0;
do {
int end = body.indexOf('}');
int braces = body.indexOf('{');
int quotes = body.indexOf(';');
if((end < 0) || (end < braces && end < quotes)){
if(end > 0) offset+=end;
break;
}
if(braces < 0 && quotes < 0){
if(end > 0) offset+=end;
break;
}
if(braces >= 0 && braces < quotes){
Function func = new Function();
index = func.parse(body.substring(0, end+1));
this.functions.add(func);
}else{
Operation op = new Operation();
index = op.parse(body.substring(0, end+1));
this.operations.add(op);
}
offset+=index+1;
body = body.substring(index);
}while(offset > -1);
return matcher.group(1).length()+offset;
}
public void show(int tab){
String start = "";
for(int i = 0; i < tab; i++) start+="\t";
System.out.println(start+Modifier.toString(modifier)+" "+name+"("+parameters+") "+exceptions+" {");
for(Operation o : this.operations) o.show(tab+1);
System.out.println();
for(Function f : this.functions) f.show(tab+1);
System.out.println(start+"}");
}
@Override
public String toString(){
return "Function[name="+name+",param="+parameters+",exception="+exceptions+"]";
}
}

View file

@ -1,28 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Import {
private static Pattern PATTERN = Pattern.compile("^\\s*(import\\s+([^;]*);).*$");
public static boolean isImport(String content){
return PATTERN.matcher(content).matches();
}
private String name;
public Import(){}
public int parse(String content) throws Exception{
Matcher matcher = PATTERN.matcher(content);
matcher.matches();
this.name = matcher.group(2);
return matcher.group(1).length();
}
public String getName(){
return this.name;
}
}

View file

@ -1,96 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
public class JavaParser {
public static void main(String[] args) throws Exception {
File file = new File("C:\\Users\\jeffc\\eclipse-workspace\\peer-at-code-backend\\src\\be\\jeffcheasey88\\peeratcode\\parser\\java\\Import.java");
BufferedReader reader = new BufferedReader(new FileReader(file));
JavaParser parser = new JavaParser(reader);
parser.parse();
System.out.println("SHOW-----------------");
parser.show();
}
private Package pack;
private List<Import> imports;
private Class clazz;
private BufferedReader reader;
public JavaParser(BufferedReader reader){
this.reader = reader;
}
public void parse() throws Exception{
String content = "";
int index;
String line;
while((line = reader.readLine()) != null) content+=line;
// content = CleanerPool.getterToDelete.clean(content);
this.pack = new Package();
index = this.pack.parse(content);
content = content.substring(index);
this.imports = new ArrayList<>();
while(Import.isImport(content)){
Import imp = new Import();
index = imp.parse(content);
this.imports.add(imp);
content = content.substring(index);
}
this.clazz = new Class();
index = this.clazz.parse(content);
content = content.substring(index);
}
public Package getPackage(){
return this.pack;
}
public List<Import> getImports(){
return this.imports;
}
public Class getClazz(){
return this.clazz;
}
public void show(){
System.out.println("package "+this.pack.getName()+";");
System.out.println();
for(Import i : this.imports) System.out.println("import "+i.getName()+";");
System.out.println();
this.clazz.show();
}
public static int getModifier(String modifier){
switch(modifier){
case "public": return Modifier.PUBLIC;
case "private": return Modifier.PRIVATE;
case "protected": return Modifier.PROTECTED;
case "static": return Modifier.STATIC;
case "final": return Modifier.FINAL;
case "synchronized": return Modifier.SYNCHRONIZED;
case "volatile": return Modifier.VOLATILE;
case "transient": return Modifier.TRANSIENT;
case "native": return Modifier.NATIVE;
case "abstract": return Modifier.ABSTRACT;
case "strictfp": return Modifier.STRICT;
default: break;
}
return 0;
}
}

View file

@ -1,29 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Operation {
private static Pattern VARIABLE_PATTERN = Pattern.compile("^(\\s*([^;]*)).*$");
private String tmp;
public Operation(){}
public int parse(String content) throws Exception{
Matcher matcher = VARIABLE_PATTERN.matcher(content);
if(matcher.matches()){
this.tmp = matcher.group(2);
return matcher.group(1).length()+1;
}
return 0;
}
public void show(int tab){
String start = "";
for(int i = 0; i < tab; i++) start+="\t";
System.out.println(start+tmp+";");
}
}

View file

@ -1,24 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Package {
private static Pattern PATTERN = Pattern.compile("^(\\s*package\\s+([^;]*);).*$");
private String name;
public Package(){}
public int parse(String content) throws Exception{
Matcher matcher = PATTERN.matcher(content);
matcher.matches();
this.name = matcher.group(2);
return matcher.group(1).length();
}
public String getName(){
return this.name;
}
}

View file

@ -1,127 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Variable {
private static Pattern PATTERN = Pattern.compile("^(\\s*)(.*)$");
private int modifier;
private String name;
private String type;
private Variable value;
public Variable(){}
public Variable(int modifier, String type){
this.modifier = modifier;
this.type = type;
}
public int parse(String content) throws Exception{
Matcher matcher = PATTERN.matcher(content);
matcher.matches();
int offset = matcher.group(1).length();
String body = matcher.group(2);
int equals = indexOf(body, "=");
int quote = indexOf(body,",");
int quotes = indexOf(body, ";");
int min = Math.min(quote, quotes);
body = body.substring(0, min);
if(equals < quote && equals < quotes){
assigment(body);
}else{
onlyDefine(body);
}
return offset+min;
}
private void assigment(String content){
}
private void onlyDefine(String content){
content = generiqueTypes(content);
System.out.println(content);
String[] values = content.split("\\s+");
for(String value : values){
int modifier = JavaParser.getModifier(value);
if(modifier > 0){
this.modifier+=modifier;
continue;
}
if(this.type == null){
this.type = value;
continue;
}
this.name = value;
}
}
private String generiqueTypes(String content){
System.out.println(content);
String result = "";
int opened = 0;
for(char c : content.toCharArray()){
if(c == '<') opened++;
else if(c == '>') opened--;
if(opened > 0){
if(Character.isWhitespace(c)) continue;
}
result+=c;
}
result = result.replaceAll("(>\\s*)", "> ").replace("> >", ">>");
return result;
}
private int indexOf(String value, String target){
return value.split(target)[0].length();
}
public int getModifier(){
return this.modifier;
}
public String getName(){
return this.name;
}
public String getType(){
return this.type;
}
public Variable getValue(){
return this.value;
}
public void show(int tab){
String start = "";
for(int i = 0; i < tab; i++) start+="\t";
System.out.println(start+Modifier.toString(modifier)+" "+type+" "+name+(value == null ? ";":"="+value+";"));
}
public static class Value extends Variable{
private String value;
public Value(String value){
this.value = value;
}
public String value(){
return this.value;
}
@Override
public String toString(){
return this.value;
}
}
}

View file

@ -1,40 +0,0 @@
package be.jeffcheasey88.peeratcode.routes;
import java.util.regex.Matcher;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
public class Result implements Response {
private DatabaseRepository repo;
public Result(DatabaseRepository repo) {
this.repo = repo;
}
@RouteDoc(path = "/result/<id>", responseCode = 200, responseDescription = "Le score")
@RouteDoc(responseCode = 425, responseDescription = "Puzzle pas compléter")
@Route(path = "^\\/result\\/(\\d+)$", needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
int puzzle = Integer.parseInt(matcher.group(1));
PeerAtUser peerat = (PeerAtUser)user;
int score = this.repo.getScore(peerat.getId(), puzzle);
if (score < 0) {
writer.response(425, "Access-Control-Allow-Origin: *");
} else {
writer.response(200, "Access-Control-Allow-Origin: *");
writer.write(score + "");
}
}
}

View file

@ -1,34 +0,0 @@
package be.jeffcheasey88.peeratcode.routes.groups;
import java.util.regex.Matcher;
import org.json.simple.JSONArray;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
public class GroupList implements Response {
private DatabaseRepository repo;
public GroupList(DatabaseRepository repo) {
this.repo = repo;
}
@RouteDoc(path = "/groups", responseCode = 200, responseDescription = "JSON avec la liste des groups")
@Route(path = "^\\/groups$", needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
writer.response(200, "Access-Control-Allow-Origin: *");
JSONArray result = new JSONArray();
for(Group group : this.repo.getAllGroups()) result.add(group.toJson());
writer.write(result.toJSONString());
}
}

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode;
package dev.peerat.backend;
import java.io.BufferedReader;
import java.io.BufferedWriter;

View file

@ -1,35 +1,36 @@
package be.jeffcheasey88.peeratcode;
package dev.peerat.backend;
import static be.jeffcheasey88.peeratcode.framework.RequestType.OPTIONS;
import static dev.peerat.framework.RequestType.OPTIONS;
import java.util.regex.Matcher;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Locker;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.Router;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Completion;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import be.jeffcheasey88.peeratcode.routes.BadgeDetails;
import be.jeffcheasey88.peeratcode.routes.ChapterElement;
import be.jeffcheasey88.peeratcode.routes.ChapterList;
import be.jeffcheasey88.peeratcode.routes.DynamicLeaderboard;
import be.jeffcheasey88.peeratcode.routes.Leaderboard;
import be.jeffcheasey88.peeratcode.routes.Login;
import be.jeffcheasey88.peeratcode.routes.PlayerDetails;
import be.jeffcheasey88.peeratcode.routes.PuzzleElement;
import be.jeffcheasey88.peeratcode.routes.PuzzleResponse;
import be.jeffcheasey88.peeratcode.routes.Register;
import be.jeffcheasey88.peeratcode.routes.Result;
import be.jeffcheasey88.peeratcode.routes.groups.GroupCreate;
import be.jeffcheasey88.peeratcode.routes.groups.GroupJoin;
import be.jeffcheasey88.peeratcode.routes.groups.GroupList;
import be.jeffcheasey88.peeratcode.routes.groups.GroupQuit;
import dev.peerat.backend.model.Completion;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.backend.routes.BadgeDetails;
import dev.peerat.backend.routes.ChapterElement;
import dev.peerat.backend.routes.ChapterList;
import dev.peerat.backend.routes.DynamicLeaderboard;
import dev.peerat.backend.routes.Leaderboard;
import dev.peerat.backend.routes.Login;
import dev.peerat.backend.routes.PlayerDetails;
import dev.peerat.backend.routes.PuzzleElement;
import dev.peerat.backend.routes.PuzzleResponse;
import dev.peerat.backend.routes.Register;
import dev.peerat.backend.routes.Result;
import dev.peerat.backend.routes.groups.GroupCreate;
import dev.peerat.backend.routes.groups.GroupJoin;
import dev.peerat.backend.routes.groups.GroupList;
import dev.peerat.backend.routes.groups.GroupQuit;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Locker;
import dev.peerat.framework.RequestType;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
import dev.peerat.framework.Router;
public class Main{
public static void main(String[] args) throws Exception{
@ -47,9 +48,12 @@ public class Main{
claims.setExpirationTimeMinutesInTheFuture(config.getTokenExpiration());
},
(claims) -> new PeerAtUser(claims));
router.addDefaultHeaders(RequestType.GET, "Access-Control-Allow-Origin: *");
router.addDefaultHeaders(RequestType.POST, "Access-Control-Allow-Origin: *");
router.setDefault((matcher, user, reader, writer) -> {
writer.response(404, "Access-Control-Allow-Origin: *");
router.setDefault((matcher, context, reader, writer) -> {
context.response(404);
writer.write("404 not Found.\n");
writer.flush();
writer.close();
@ -57,9 +61,11 @@ public class Main{
router.register(new Response(){
@Route(path = "^(.*)$", type = OPTIONS)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
writer.response(200, "Access-Control-Allow-Origin: *",
"Access-Control-Allow-Methods: *", "Access-Control-Allow-Headers: *");
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
context.response(200,
"Access-Control-Allow-Origin: *",
"Access-Control-Allow-Methods: *",
"Access-Control-Allow-Headers: *");
}
});

View file

@ -1,12 +1,12 @@
package be.jeffcheasey88.peeratcode.bonus.discord;
package dev.peerat.backend.bonus.discord;
import java.util.List;
import be.jeffcheasey88.peeratcode.Configuration;
import be.jeffcheasey88.peeratcode.framework.Locker;
import be.jeffcheasey88.peeratcode.framework.Locker.Key;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.Configuration;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Locker;
import dev.peerat.framework.Locker.Key;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Guild;

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.bonus.extract;
package dev.peerat.backend.bonus.extract;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.bonus.extract;
package dev.peerat.backend.bonus.extract;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View file

@ -1,14 +1,14 @@
package be.jeffcheasey88.peeratcode.bonus.extract;
package dev.peerat.backend.bonus.extract;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Map.Entry;
import be.jeffcheasey88.peeratcode.framework.RequestType;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.Router;
import dev.peerat.framework.RequestType;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
import dev.peerat.framework.Router;
//A noter que le but est d'extraire des informations sans modifier le code source,
//comme les tests unitaire, ici je veux générer un élément textuel qui me donnera l'état des routes,

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.model;
package dev.peerat.backend.model;
import be.jeffcheasey88.peeratcode.mapping.Treasure;
@ -14,7 +14,7 @@ public class Badge {
this.logo = logo;
this.level = level;
}
public String getName(){
return name;
}

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.model;
package dev.peerat.backend.model;
import java.sql.Timestamp;
import java.util.List;

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.model;
package dev.peerat.backend.model;
import java.util.Arrays;

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.model;
package dev.peerat.backend.model;
import java.util.ArrayList;
import java.util.List;
@ -7,6 +7,10 @@ import java.util.Objects;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.mapping.SeaBottle;
import be.jeffcheasey88.peeratcode.mapping.Treasure;
@Treasure
public class Group implements Comparable<Group> {
private String name;
private Integer linkToChapter;
@ -18,7 +22,7 @@ public class Group implements Comparable<Group> {
return "Group[name="+name+", chapter="+linkToChapter+"]";
}
public Group(JSONObject json) {
public Group(JSONObject json){
this.name = (String) json.get("name");
if (json.containsKey("chapter"))
this.linkToChapter = ((Number) json.get("chapter")).intValue();
@ -31,6 +35,11 @@ public class Group implements Comparable<Group> {
this.linkToChapter = initChap;
// this.linkToPuzzle = initPuzz;
}
@SeaBottle
public static Group getGroup(int player){
return null;
}
public void addPlayer(Player newPlayer) {
if (newPlayer != null) {

View file

@ -1,8 +1,8 @@
package be.jeffcheasey88.peeratcode.model;
package dev.peerat.backend.model;
import org.jose4j.jwt.JwtClaims;
public class PeerAtUser extends be.jeffcheasey88.peeratcode.framework.User{
public class PeerAtUser extends dev.peerat.framework.User{
private int id;

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.model;
package dev.peerat.backend.model;
import java.util.Base64;
import java.util.HashSet;

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.model;
package dev.peerat.backend.model;
import java.util.Arrays;
import java.util.HashSet;

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.repository;
package dev.peerat.backend.repository;
import java.sql.Connection;
import java.sql.PreparedStatement;

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.repository;
package dev.peerat.backend.repository;
import java.sql.Connection;
import java.sql.DriverManager;
@ -15,14 +15,14 @@ import java.util.TreeSet;
import com.password4j.Hash;
import com.password4j.Password;
import be.jeffcheasey88.peeratcode.Configuration;
import be.jeffcheasey88.peeratcode.model.Badge;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.model.Completion;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.model.Player;
import be.jeffcheasey88.peeratcode.model.Puzzle;
import dev.peerat.backend.Configuration;
import dev.peerat.backend.model.Badge;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.model.Completion;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.model.Player;
import dev.peerat.backend.model.Puzzle;
public class DatabaseRepository {

View file

@ -1,18 +1,18 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import java.util.Base64;
import java.util.regex.Matcher;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Badge;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Badge;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class BadgeDetails implements Response {
@ -26,7 +26,7 @@ public class BadgeDetails implements Response {
@RouteDoc(responseCode = 400, responseDescription = "Aucun id donner")
@Route(path = "^\\/badge\\/([0-9]+)$", needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
if (matcher.groupCount() > 0) {
int badgeId = Integer.parseInt(matcher.group(1));
Badge badge = databaseRepo.getBadge(badgeId);
@ -37,10 +37,10 @@ public class BadgeDetails implements Response {
badgeJSON.put("logo", Base64.getEncoder().encodeToString(badge.getLogo()));
badgeJSON.put("level", badge.getLevel());
}
writer.response(200, "Access-Control-Allow-Origin: *");
context.response(200);
writer.write(badgeJSON.toJSONString().replace("\\", ""));
} else {
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
}
}

View file

@ -1,20 +1,20 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import java.util.regex.Matcher;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.model.Puzzle;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.model.Puzzle;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class ChapterElement implements Response {
@ -28,7 +28,7 @@ public class ChapterElement implements Response {
@RouteDoc(responseCode = 400, responseDescription = "Aucun id donner")
@Route(path = "^\\/chapter\\/([0-9]+)$", needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
Chapter chapter = databaseRepo.getChapter(Integer.parseInt(matcher.group(1)));
if (chapter != null){
JSONObject chapterJSON = new JSONObject();
@ -39,22 +39,22 @@ public class ChapterElement implements Response {
if (chapter.getEndDate() != null)
chapterJSON.put("endDate", chapter.getEndDate().toString());
JSONArray puzzles = new JSONArray();
PeerAtUser peerat = (PeerAtUser)user;
PeerAtUser user = context.getUser();
for (Puzzle puzzle : chapter.getPuzzles()){
JSONObject puzzleJSON = new JSONObject();
puzzleJSON.put("id", puzzle.getId());
puzzleJSON.put("name", puzzle.getName());
puzzleJSON.put("scoreMax", puzzle.getScoreMax());
if (puzzle.getTags() != null) puzzleJSON.put("tags", puzzle.getJsonTags());
int score = this.databaseRepo.getScore(peerat.getId(), puzzle.getId());
int score = this.databaseRepo.getScore(user.getId(), puzzle.getId());
if(score >= 0) puzzleJSON.put("score", score);
puzzles.add(puzzleJSON);
}
chapterJSON.put("puzzles", puzzles);
writer.response(200, "Access-Control-Allow-Origin: *");
context.response(200);
writer.write(chapterJSON.toJSONString());
} else {
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
}
}

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import java.util.List;
import java.util.regex.Matcher;
@ -6,14 +6,14 @@ import java.util.regex.Matcher;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class ChapterList implements Response {
@ -27,7 +27,7 @@ public class ChapterList implements Response {
@RouteDoc(responseCode = 400, responseDescription = "Aucun chapitre trouver")
@Route(path = "^\\/chapters$", needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
List<Chapter> allChapters = databaseRepo.getAllChapters();
if (allChapters != null) {
JSONArray chaptersJSON = new JSONArray();
@ -41,10 +41,10 @@ public class ChapterList implements Response {
chapterJSON.put("endDate", chapter.getEndDate().toString());
chaptersJSON.add(chapterJSON);
}
writer.response(200, "Access-Control-Allow-Origin: *");
context.response(200);
writer.write(chaptersJSON.toJSONString());
} else {
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
}
}

View file

@ -1,16 +1,16 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import java.util.regex.Matcher;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Locker;
import be.jeffcheasey88.peeratcode.framework.Locker.Key;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Completion;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Completion;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Locker;
import dev.peerat.framework.Locker.Key;
import dev.peerat.framework.Route;
public class DynamicLeaderboard extends Leaderboard{
@ -28,7 +28,7 @@ public class DynamicLeaderboard extends Leaderboard{
@RouteDoc(path = "/rleaderboard/{id}", responseCode = 101, responseDescription = "WebSocket")
@Route(path = "^\\/rleaderboard\\/?(\\d+)?$", websocket = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
Key key = new Key();
locker.init(key);

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import java.io.IOException;
import java.util.SortedSet;
@ -7,16 +7,16 @@ import java.util.regex.Matcher;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.model.Player;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.model.Player;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class Leaderboard implements Response {
@ -29,8 +29,8 @@ public class Leaderboard implements Response {
@RouteDoc(path = "/leaderboard/{id}", responseCode = 200, responseDescription = "JSON contenant le leaderboard")
@Route(path = "^\\/leaderboard\\/?(\\d+)?$")
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
writer.response(200, "Access-Control-Allow-Origin: *");
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
context.response(200);
if (matcher.group(1) != null) {
groupsLeaderboard(Integer.parseInt(matcher.group(1)), writer);
} else {

View file

@ -1,20 +1,20 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import static be.jeffcheasey88.peeratcode.framework.RequestType.POST;
import static dev.peerat.framework.RequestType.POST;
import java.util.regex.Matcher;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.Router;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
import dev.peerat.framework.Router;
public class Login implements Response {
@ -31,9 +31,9 @@ public class Login implements Response {
@RouteDoc(responseCode = 400, responseDescription = "Aucune données fournie / données invalide")
@Route(path = "^\\/login$", type = POST)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
if (user != null) {
writer.response(403, "Access-Control-Allow-Origin: *");
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
if (context.getUser() != null) {
context.response(403);
return;
}
JSONObject informations = reader.readJson();
@ -42,13 +42,13 @@ public class Login implements Response {
String password = (String) informations.get("passwd");
int id;
if ((id = databaseRepo.login(pseudo, password)) >= 0) {
writer.response(200, "Access-Control-Allow-Origin: *",
context.response(200,
"Access-Control-Expose-Headers: Authorization",
"Authorization: Bearer " + this.router.createAuthUser(new PeerAtUser(id)));
return;
}
}
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
}
}

View file

@ -1,19 +1,19 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import java.util.Base64;
import java.util.regex.Matcher;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.model.Player;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.model.Player;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class PlayerDetails implements Response {
@ -27,13 +27,13 @@ public class PlayerDetails implements Response {
@RouteDoc(responseCode = 400, responseDescription = "Utilisateur introuvable dans la base de donnée")
@Route(path = "^\\/player\\/?(.+)?$", needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
Player player;
if (matcher.group(1) != null) {
player = databaseRepo.getPlayerDetails(matcher.group(1));
} else {
PeerAtUser peerat = (PeerAtUser)user;
player = databaseRepo.getPlayerDetails(peerat.getId());
PeerAtUser user = context.getUser();
player = databaseRepo.getPlayerDetails(user.getId());
}
JSONObject playerJSON = new JSONObject();
if (player != null) {
@ -53,10 +53,10 @@ public class PlayerDetails implements Response {
playerJSON.put("badges", player.getJsonBadges());
if (player.getAvatar() != null)
playerJSON.put("avatar", Base64.getEncoder().encodeToString(player.getAvatar()));
writer.response(200, "Access-Control-Allow-Origin: *");
context.response(200);
writer.write(playerJSON.toJSONString().replace("\\", ""));
} else {
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
}
}

View file

@ -1,21 +1,21 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import java.time.LocalDateTime;
import java.util.regex.Matcher;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.model.Completion;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.model.Puzzle;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.model.Completion;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.model.Puzzle;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class PuzzleElement implements Response {
@ -30,13 +30,13 @@ public class PuzzleElement implements Response {
@RouteDoc(responseCode = 423, responseDescription = "L'utilisateur essaye de voir le puzzle en dehors de l'event")
@Route(path = "^\\/puzzle\\/([0-9]+)$", needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception {
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
Puzzle puzzle = databaseRepo.getPuzzle(extractId(matcher));
if (puzzle != null){
Chapter chapter = this.databaseRepo.getChapter(puzzle);
if(chapter.getStartDate() != null){
if(LocalDateTime.now().isBefore(chapter.getStartDate().toLocalDateTime())){
writer.response(423, "Access-Control-Allow-Origin: *");
context.response(423);
return;
}
}
@ -47,7 +47,7 @@ public class PuzzleElement implements Response {
// }
// }
PeerAtUser peerat = (PeerAtUser)user;
PeerAtUser user = context.getUser();
JSONObject puzzleJSON = new JSONObject();
puzzleJSON.put("id", puzzle.getId());
@ -55,17 +55,17 @@ public class PuzzleElement implements Response {
puzzleJSON.put("content", puzzle.getContent());
puzzleJSON.put("scoreMax", puzzle.getScoreMax());
if(puzzle.getTags() != null) puzzleJSON.put("tags", puzzle.getJsonTags());
Completion completion = this.databaseRepo.getCompletionGroup(peerat.getId(), puzzle.getId());
Completion completion = this.databaseRepo.getCompletionGroup(user.getId(), puzzle.getId());
if(completion != null && completion.getScore() >= 0){
puzzleJSON.put("score", completion.getScore());
puzzleJSON.put("tries", completion.getTries());
}
if(puzzle.getDepend() > 0) puzzleJSON.put("depend", puzzle.getDepend());
writer.response(200, "Access-Control-Allow-Origin: *", "Content-Type: application/json");
context.response(200, "Content-Type: application/json");
writer.write(puzzleJSON.toJSONString());
}
else {
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
}
}

View file

@ -1,6 +1,6 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import static be.jeffcheasey88.peeratcode.framework.RequestType.POST;
import static dev.peerat.framework.RequestType.POST;
import java.io.IOException;
import java.nio.file.Files;
@ -13,20 +13,20 @@ import java.util.regex.Matcher;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Locker;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.model.Completion;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.model.Player;
import be.jeffcheasey88.peeratcode.model.Puzzle;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.model.Completion;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.model.Player;
import dev.peerat.backend.model.Puzzle;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Locker;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class PuzzleResponse implements Response {
private final DatabaseRepository databaseRepo;
@ -47,18 +47,18 @@ public class PuzzleResponse implements Response {
@RouteDoc(responseCode = 423, responseDescription = "L'utilisateur essaye de répondre en dehors de l'event")
@Route(path = "^\\/puzzleResponse\\/([0-9]+)$", type = POST, needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
ReceivedResponse received = new ReceivedResponse(matcher, reader);
if (received.getResponse() == null){
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
return;
}
PeerAtUser peerat = (PeerAtUser)user;
PeerAtUser user = context.getUser();
//saveSourceCode(received, databaseRepo.getPlayer(user.getId()));
JSONObject responseJSON = new JSONObject();
if(this.databaseRepo.getScore(peerat.getId(), received.getPuzzleId()) > 0){
writer.response(403, "Access-Control-Allow-Origin: *");
if(this.databaseRepo.getScore(user.getId(), received.getPuzzleId()) > 0){
context.response(403);
return;
}
@ -66,43 +66,43 @@ public class PuzzleResponse implements Response {
Chapter chapter = this.databaseRepo.getChapter(currentPuzzle);
if(chapter.getStartDate() != null){
if(LocalDateTime.now().isBefore(chapter.getStartDate().toLocalDateTime())){
writer.response(423, "Access-Control-Allow-Origin: *");
context.response(423);
return;
}
}
if(chapter.getEndDate() != null){
if(LocalDateTime.now().isAfter(chapter.getEndDate().toLocalDateTime())){
if(Arrays.equals(currentPuzzle.getSoluce(), received.getResponse())){
writer.response(200, "Access-Control-Allow-Origin: *", "Content-Type: application/json");
context.response(200, "Content-Type: application/json");
JSONObject theoSaisPasJusteRecevoir200 = new JSONObject();
theoSaisPasJusteRecevoir200.put("success", true);
writer.write(theoSaisPasJusteRecevoir200.toJSONString());
return;
}
writer.response(423, "Access-Control-Allow-Origin: *");
context.response(423);
return;
}
Group group = this.databaseRepo.getPlayerGroup(peerat.getId(), chapter.getId());
Group group = this.databaseRepo.getPlayerGroup(user.getId(), chapter.getId());
if(group == null){
writer.response(423, "Access-Control-Allow-Origin: *");
context.response(423);
return;
}
}
Completion completion = databaseRepo.insertOrUpdatePuzzleResponse(received.getPuzzleId(), peerat.getId(),
Completion completion = databaseRepo.insertOrUpdatePuzzleResponse(received.getPuzzleId(), user.getId(),
received.getFileName(), received.getSourceCode(), received.getResponse(), currentPuzzle);
if(completion == null){
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
return;
}
if(completion.getScore() > 0){
writer.response(200, "Access-Control-Allow-Origin: *", "Content-Type: application/json");
context.response(200, "Content-Type: application/json");
responseJSON.put("score", completion.getScore());
responseJSON.put("tries", completion.getTries());
}else{
writer.response(406, "Access-Control-Allow-Origin: *", "Content-Type: application/json");
context.response(406, "Content-Type: application/json");
responseJSON.put("tries", completion.getTries());
}
writer.write(responseJSON.toJSONString());

View file

@ -1,6 +1,6 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import static be.jeffcheasey88.peeratcode.framework.RequestType.POST;
import static dev.peerat.framework.RequestType.POST;
import java.io.IOException;
import java.nio.file.Files;
@ -9,15 +9,15 @@ import java.util.regex.Matcher;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.Router;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
import dev.peerat.framework.Router;
public class Register implements Response {
@ -36,9 +36,9 @@ public class Register implements Response {
@RouteDoc(responseCode = 400, responseDescription = "Aucune données fournie / données invalide")
@Route(path = "^\\/register$", type = POST)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
if (user != null){
writer.response(403, "Access-Control-Allow-Origin: *");
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
if (context.getUser() != null){
context.response(403);
return;
}
JSONObject informations = reader.readJson();
@ -48,7 +48,7 @@ public class Register implements Response {
&& informations.containsKey("lastname") && informations.containsKey("description")
&& informations.containsKey("sgroup") && informations.containsKey("avatar");
if (!allFieldsFilled) {
writer.response(403, "Access-Control-Allow-Origin: *");
context.response(403);
return;
}
String pseudo = (String) informations.get("pseudo");
@ -66,14 +66,14 @@ public class Register implements Response {
int id;
if ((id = databaseRepo.register(pseudo, email, password, firstname, lastname, description, group,
avatar)) >= 0) {
writer.response(200, "Access-Control-Allow-Origin: *",
context.response(200,
"Access-Control-Expose-Headers: Authorization",
"Authorization: Bearer " + this.router.createAuthUser(new PeerAtUser(id)));
createFolderToSaveSourceCode(pseudo);
return;
}
} else {
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
JSONObject error = new JSONObject();
error.put("username_valid", pseudoAvailable);
error.put("email_valid", emailAvailable);
@ -81,7 +81,7 @@ public class Register implements Response {
return;
}
}
writer.response(400, "Access-Control-Allow-Origin: *");
context.response(400);
}
private void createFolderToSaveSourceCode(String pseudo) throws IOException {

View file

@ -0,0 +1,40 @@
package dev.peerat.backend.routes;
import java.util.regex.Matcher;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class Result implements Response {
private DatabaseRepository repo;
public Result(DatabaseRepository repo) {
this.repo = repo;
}
@RouteDoc(path = "/result/<id>", responseCode = 200, responseDescription = "Le score")
@RouteDoc(responseCode = 425, responseDescription = "Puzzle pas compléter")
@Route(path = "^\\/result\\/(\\d+)$", needLogin = true)
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
int puzzle = Integer.parseInt(matcher.group(1));
PeerAtUser user = context.getUser();
int score = this.repo.getScore(user.getId(), puzzle);
if (score < 0) {
context.response(425);
} else {
context.response(200);
writer.write(score + "");
}
}
}

View file

@ -1,21 +1,21 @@
package be.jeffcheasey88.peeratcode.routes.groups;
package dev.peerat.backend.routes.groups;
import static be.jeffcheasey88.peeratcode.framework.RequestType.POST;
import static dev.peerat.framework.RequestType.POST;
import java.time.LocalDateTime;
import java.util.regex.Matcher;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Locker;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Locker;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class GroupCreate implements Response {
@ -34,14 +34,14 @@ public class GroupCreate implements Response {
@RouteDoc(responseCode = 423, responseDescription = "L'utilisateur essaye de crée un groupe après le délai maximum de création de l'event")
@Route(path = "^\\/groupCreate$", type = POST, needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
Group newGroup = new Group(reader.readJson());
PeerAtUser peerat = (PeerAtUser)user;
PeerAtUser user = context.getUser();
if (this.repo.getPlayerGroup(peerat.getId(), newGroup.getLinkToChapter()) == null) {
if (this.repo.getPlayerGroup(user.getId(), newGroup.getLinkToChapter()) == null) {
try {
if(this.repo.getGroupId(newGroup) == null) throw new NullPointerException();
writer.response(403, "Access-Control-Allow-Origin: *");
context.response(403);
return;
}catch(NullPointerException e){
if(newGroup.getLinkToChapter() != null){
@ -49,21 +49,21 @@ public class GroupCreate implements Response {
if(chapter.getStartDate() != null){
LocalDateTime start = chapter.getStartDate().toLocalDateTime().plusMinutes(this.groupDelay);
if(LocalDateTime.now().isAfter(start)){
writer.response(423, "Access-Control-Allow-Origin: *");
context.response(423);
return;
}
}
}
if (this.repo.insertGroup(newGroup, peerat)) {
writer.response(200, "Access-Control-Allow-Origin: *");
if (this.repo.insertGroup(newGroup, user)) {
context.response(200);
locker.setValue(newGroup);
} else {
writer.response(403, "Access-Control-Allow-Origin: *");
context.response(403);
}
}
}else {
writer.response(403, "Access-Control-Allow-Origin: *");
context.response(403);
}
}
}

View file

@ -1,22 +1,22 @@
package be.jeffcheasey88.peeratcode.routes.groups;
package dev.peerat.backend.routes.groups;
import static be.jeffcheasey88.peeratcode.framework.RequestType.POST;
import static dev.peerat.framework.RequestType.POST;
import java.time.LocalDateTime;
import java.util.regex.Matcher;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Locker;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.model.Completion;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.model.Completion;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Locker;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class GroupJoin implements Response{
@ -39,18 +39,18 @@ public class GroupJoin implements Response{
@RouteDoc(responseCode = 409, responseDescription = "L'utilisateur est un peu débile... ou pas ?")
@Route(path = "^\\/groupJoin$", type = POST, needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
Group group = new Group(reader.readJson());
PeerAtUser peerat = (PeerAtUser)user;
PeerAtUser user = context.getUser();
Group userGroup = this.repo.getPlayerGroup(peerat.getId(), group.getLinkToChapter());
Group userGroup = this.repo.getPlayerGroup(user.getId(), group.getLinkToChapter());
if(group.equals(userGroup)){
writer.response(403, "Access-Control-Allow-Origin: *");
context.response(403);
return;
}
if(group.getLinkToChapter() == null){
writer.response(409, "Access-Control-Allow-Origin: *");
context.response(409);
writer.write(waitTime);
return;
}
@ -60,18 +60,18 @@ public class GroupJoin implements Response{
if(chapter.getStartDate() != null){
LocalDateTime start = chapter.getStartDate().toLocalDateTime().plusMinutes(this.groupDelay);
if(LocalDateTime.now().isAfter(start)){
writer.response(423, "Access-Control-Allow-Origin: *");
context.response(423);
return;
}
}
}
if (this.repo.insertUserInGroup(group, peerat)) {
writer.response(200, "Access-Control-Allow-Origin: *");
if (this.repo.insertUserInGroup(group, user)) {
context.response(200);
leaderboard.setValue(new Completion(0, 0, 0, null, 0));
} else {
writer.response(403, "Access-Control-Allow-Origin: *");
context.response(403);
}
}

View file

@ -0,0 +1,34 @@
package dev.peerat.backend.routes.groups;
import java.util.regex.Matcher;
import org.json.simple.JSONArray;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class GroupList implements Response {
private DatabaseRepository repo;
public GroupList(DatabaseRepository repo) {
this.repo = repo;
}
@RouteDoc(path = "/groups", responseCode = 200, responseDescription = "JSON avec la liste des groups")
@Route(path = "^\\/groups$", needLogin = true)
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception {
context.response(200);
JSONArray result = new JSONArray();
for(Group group : this.repo.getAllGroups()) result.add(group.toJson());
writer.write(result.toJSONString());
}
}

View file

@ -1,22 +1,22 @@
package be.jeffcheasey88.peeratcode.routes.groups;
package dev.peerat.backend.routes.groups;
import static be.jeffcheasey88.peeratcode.framework.RequestType.POST;
import static dev.peerat.framework.RequestType.POST;
import java.time.LocalDateTime;
import java.util.regex.Matcher;
import be.jeffcheasey88.peeratcode.bonus.extract.RouteDoc;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import be.jeffcheasey88.peeratcode.framework.Locker;
import be.jeffcheasey88.peeratcode.framework.Response;
import be.jeffcheasey88.peeratcode.framework.Route;
import be.jeffcheasey88.peeratcode.framework.User;
import be.jeffcheasey88.peeratcode.model.Chapter;
import be.jeffcheasey88.peeratcode.model.Completion;
import be.jeffcheasey88.peeratcode.model.Group;
import be.jeffcheasey88.peeratcode.model.PeerAtUser;
import be.jeffcheasey88.peeratcode.repository.DatabaseRepository;
import dev.peerat.backend.bonus.extract.RouteDoc;
import dev.peerat.backend.model.Chapter;
import dev.peerat.backend.model.Completion;
import dev.peerat.backend.model.Group;
import dev.peerat.backend.model.PeerAtUser;
import dev.peerat.backend.repository.DatabaseRepository;
import dev.peerat.framework.Context;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
import dev.peerat.framework.Locker;
import dev.peerat.framework.Response;
import dev.peerat.framework.Route;
public class GroupQuit implements Response{
@ -37,13 +37,13 @@ public class GroupQuit implements Response{
@RouteDoc(responseCode = 423, responseDescription = "L'utilisateur essaye de quitter un groupe après le délai maximum de création de l'event")
@Route(path = "^\\/groupQuit$", type = POST, needLogin = true)
public void exec(Matcher matcher, User user, HttpReader reader, HttpWriter writer) throws Exception{
public void exec(Matcher matcher, Context context, HttpReader reader, HttpWriter writer) throws Exception{
Group group = new Group(reader.readJson());
PeerAtUser peerat = (PeerAtUser)user;
PeerAtUser user = context.getUser();
Group userGroup = this.repo.getPlayerGroup(peerat.getId(), group.getLinkToChapter());
Group userGroup = this.repo.getPlayerGroup(user.getId(), group.getLinkToChapter());
if(!group.equals(userGroup)){
writer.response(403, "Access-Control-Allow-Origin: *");
context.response(403);
return;
}
@ -52,18 +52,18 @@ public class GroupQuit implements Response{
if(chapter.getStartDate() != null){
LocalDateTime start = chapter.getStartDate().toLocalDateTime().plusMinutes(this.groupDelay);
if(LocalDateTime.now().isAfter(start)){
writer.response(423, "Access-Control-Allow-Origin: *");
context.response(423);
return;
}
}
}
if (this.repo.leaveGroup(group, peerat)) {
writer.response(200, "Access-Control-Allow-Origin: *");
if (this.repo.leaveGroup(group, user)) {
context.response(200);
leaderboard.setValue(new Completion(0, 0, 0, null, 0));
} else {
writer.response(403, "Access-Control-Allow-Origin: *");
context.response(403);
}
}

View file

@ -1,142 +0,0 @@
package be.jeffcheasey88.peeratcode.parser.java;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.List;
import org.junit.jupiter.api.Test;
import be.jeffcheasey88.peeratcode.parser.java.Variable.Value;
class VariableTest {
//int i = 4;
//int i,j,k,l=1;
//int lm ;
//public static int l;
//Test<Test>t;
//Test<Test,K,L> j = new Test().schedule(p -> { return true;});
//int i =j=k=l=4;
@Test
void case1(){
try {
Variable variable = new Variable();
variable.parse(" int i = 4 ; ");
assertEquals(0, variable.getModifier());
assertEquals("int", variable.getType());
assertEquals("i", variable.getName());
assertEquals("4", ((Value)variable.getValue()).value());
}catch(Exception e){
fail(e);
}
}
@Test
void case2(){
try {
Variable variable = new Variable();
variable.parse("public static int l ; ");
assertEquals(JavaParser.getModifier("public")+JavaParser.getModifier("static"), variable.getModifier());
assertEquals("int", variable.getType());
assertEquals("l", variable.getName());
assertNull(variable.getValue());
}catch(Exception e){
fail(e);
}
}
@Test
void case3(){
try {
Variable variable = new Variable();
variable.parse(" int lm ; ");
assertEquals(0, variable.getModifier());
assertEquals("int", variable.getType());
assertEquals("lm", variable.getName());
assertNull(variable.getValue());
}catch(Exception e){
fail(e);
}
}
@Test
void case4(){
try {
Variable variable = new Variable();
variable.parse("Testas< List< Map< Test, List< Test >, Test>> >t; ");
assertEquals(0, variable.getModifier());
assertEquals("Testas<List<Map<Test,List<Test>,Test>>>", variable.getType());
assertEquals("t", variable.getName());
assertNull(variable.getValue());
}catch(Exception e){
fail(e);
}
}
@Test
void case5(){
try {
Variable variable = new Variable();
variable.parse(" int i,j,k,l=1; ");
assertEquals(0, variable.getModifier());
assertEquals("int", variable.getType());
assertEquals("i", variable.getName());
assertNull(variable.getValue());
}catch(Exception e){
fail(e);
}
}
@Test
void case6(){
try {
Class clazz = new Class();
clazz.parse("public class Test{ int i ,j,k,l=1; } ");
List<Variable> vars = clazz.getVariables();
assertEquals(vars.size(), 4);
for(int i = 0; i < 3; i++){
Variable v = vars.get(i);
assertEquals(0, v.getModifier());
assertEquals("int", v.getType());
assertEquals((char)('i'+i), v.getName().charAt(0));
assertNull(v.getValue());
}
Variable v = vars.get(3);
assertEquals(0, v.getModifier());
assertEquals("int", v.getType());
assertEquals('l', v.getName().charAt(0));
assertEquals("1", ((Value)v.getValue()).value());
}catch(Exception e){
fail(e);
}
}
@Test
void case7(){
try {
Class clazz = new Class();
clazz.parse("public class Test{ int i ,j,k; int l=i=k=l=4; } ");
List<Variable> vars = clazz.getVariables();
assertEquals(vars.size(), 4);
for(int i = 0; i < 4; i++){
Variable v = vars.get(i);
assertEquals(0, v.getModifier());
assertEquals("int", v.getType());
assertEquals((char)('i'+i), v.getName().charAt(0));
}
}catch(Exception e){
fail(e);
}
}
}

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import static org.junit.jupiter.api.Assertions.fail;
@ -8,8 +8,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import be.jeffcheasey88.peeratcode.Main;
import be.jeffcheasey88.peeratcode.webclient.WebClient;
import dev.peerat.backend.Main;
import dev.peerat.backend.webclient.WebClient;
@TestInstance(Lifecycle.PER_CLASS)
class PlayerDetailsTests {

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import static org.junit.jupiter.api.Assertions.fail;
@ -9,8 +9,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import be.jeffcheasey88.peeratcode.Main;
import be.jeffcheasey88.peeratcode.webclient.WebClient;
import dev.peerat.backend.Main;
import dev.peerat.backend.webclient.WebClient;
@TestInstance(Lifecycle.PER_CLASS)
public class ScoreTests {

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import static org.junit.jupiter.api.Assertions.fail;
@ -9,8 +9,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import be.jeffcheasey88.peeratcode.Main;
import be.jeffcheasey88.peeratcode.webclient.WebClient;
import dev.peerat.backend.Main;
import dev.peerat.backend.webclient.WebClient;
@TestInstance(Lifecycle.PER_CLASS)
public class TmpRoutesTests {

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.routes;
package dev.peerat.backend.routes;
import static org.junit.jupiter.api.Assertions.fail;
@ -8,8 +8,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import be.jeffcheasey88.peeratcode.Main;
import be.jeffcheasey88.peeratcode.webclient.WebClient;
import dev.peerat.backend.Main;
import dev.peerat.backend.webclient.WebClient;
@TestInstance(Lifecycle.PER_CLASS)
public class TriggerTests {

View file

@ -1,4 +1,4 @@
package be.jeffcheasey88.peeratcode.webclient;
package dev.peerat.backend.webclient;
import static org.junit.Assert.fail;
@ -11,8 +11,8 @@ import java.util.regex.Pattern;
import org.json.simple.JSONObject;
import be.jeffcheasey88.peeratcode.framework.HttpReader;
import be.jeffcheasey88.peeratcode.framework.HttpWriter;
import dev.peerat.framework.HttpReader;
import dev.peerat.framework.HttpWriter;
public class WebClient {