added tests for experience tracking module

refactored some things in experience tracking
changed the paging behaviour for leader board and added check for negative numbers
fixed rank not being correct for further pages
added test-common module to have some common code für tests
fixed command creation
This commit is contained in:
Sheldan
2020-05-30 09:27:41 +02:00
parent 62de5c2255
commit 563564aabe
69 changed files with 2825 additions and 136 deletions

View File

@@ -208,7 +208,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
}
}
} catch (NoSuchElementException e) {
throw new IncorrectParameter("The passed parameters did not have the correct type.", command, param.getType(), param.getName());
throw new IncorrectParameter(command, param.getType(), param.getName());
}
}

View File

@@ -44,7 +44,7 @@ public class CommandCreationListener {
log.warn("Command {} has null configuration.", command);
return;
}
if(commandService.doesCommandExist(command.getConfiguration().getName())) {
if(!commandService.doesCommandExist(command.getConfiguration().getName())) {
commandService.createCommand(command.getConfiguration().getName(), command.getConfiguration().getModule(), command.getFeature());
}
});

View File

@@ -3,11 +3,15 @@ package dev.sheldan.abstracto.core.command.repository;
import dev.sheldan.abstracto.core.command.models.database.ACommand;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.stereotype.Repository;
import javax.persistence.QueryHint;
@Repository
public interface CommandRepository extends JpaRepository<ACommand, Long> {
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
ACommand findByName(String name);
boolean existsByName(String name);
}

View File

@@ -45,7 +45,7 @@ public class CommandManager implements CommandRegistry {
boolean hasRemainderParameter = commandConfiguration.getParameters().stream().anyMatch(Parameter::isRemainder);
if(unParsedCommandParameter.getParameters().size() < commandConfiguration.getNecessaryParameterCount()) {
String nextParameterName = commandConfiguration.getParameters().get(commandConfiguration.getNecessaryParameterCount() - 1).getName();
throw new InsufficientParameters("Insufficient parameters", o, nextParameterName);
throw new InsufficientParameters(o, nextParameterName);
}
parameterFit = paramCountFits || hasRemainderParameter;
} else {

View File

@@ -45,7 +45,7 @@ public class CommandManagementServiceBean implements CommandManagementService {
@Override
public boolean doesCommandExist(String name) {
return findCommandByName(name) != null;
return commandRepository.existsByName(name.toLowerCase());
}
}