[AB-150] creating repost detection feature including configuration and documentation

adding http and hash service
adding ability to add default emotes to a message to message service
adding message embedded listener to wrap the embedded event
adding custom channel groups which can be defined by modules, in case a change on a channel group (only created and updated) happens a listener is available in order to sync the state in dependant areas
changing command receiver re-throwing abstracto runtime exceptions in order to display them better
changing channel group parameter handler to throw an exception in case the channel group was not found
adding User in a server parameter handler
split channel not found exception to be able to differentiate between not found in database and not found in guild
changing exception handling in command received handler to handle the case for only one parameter handler future which failed (the whole single future failed, which was not reported)
changing parameter type of `removeFromChannelGroup` to AChannel in order to be able to delete channels in the database via ID
moving method to mock utils for mocking consumer
removing parameter validation from commands, as it should be done in the command received handler and parameter handlers anyway
This commit is contained in:
Sheldan
2020-12-04 00:38:18 +01:00
parent e966c710ce
commit 325264a325
249 changed files with 5310 additions and 686 deletions

View File

@@ -31,7 +31,6 @@ public class DisableExpForRole extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
ARole role = (ARole) parameters.get(0);
ARole actualRole = roleManagementService.findRole(role.getId());

View File

@@ -32,7 +32,6 @@ public class DisableExpGain extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
Member para = (Member) commandContext.getParameters().getParameters().get(0);
AUserInAServer userInAServer = userInServerManagementService.loadUser(para);
aUserExperienceService.disableExperienceForUser(userInAServer);

View File

@@ -31,7 +31,6 @@ public class EnableExpForRole extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
ARole role = (ARole) commandContext.getParameters().getParameters().get(0);
ARole actualRole = roleManagementService.findRole(role.getId());
if(disabledExpRoleManagementService.isExperienceDisabledForRole(actualRole)) {

View File

@@ -32,7 +32,6 @@ public class EnableExpGain extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
Member para = (Member) commandContext.getParameters().getParameters().get(0);
AUserInAServer userInAServer = userInServerManagementService.loadUser(para);
aUserExperienceService.enableExperienceForUser(userInAServer);

View File

@@ -30,7 +30,6 @@ public class ExpScale extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
Double scale = (Double) commandContext.getParameters().getParameters().get(0);
Long guildId = commandContext.getGuild().getIdLong();
configService.setDoubleValue(EXP_MULTIPLIER_KEY, guildId, scale);

View File

@@ -54,7 +54,6 @@ public class LeaderBoardCommand extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
// parameter is optional, in case its not present, we default to the 0th page
Integer page = !parameters.isEmpty() ? (Integer) parameters.get(0) : 1;

View File

@@ -42,7 +42,6 @@ public class ListDisabledExperienceRoles extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<ADisabledExpRole> disabledRolesForServer = disabledExpRoleManagementService.getDisabledRolesForServer(commandContext.getUserInitiatedContext().getServer());
DisabledExperienceRolesModel disabledExperienceRolesModel = (DisabledExperienceRolesModel) ContextConverter.fromCommandContext(commandContext, DisabledExperienceRolesModel.class);
disabledRolesForServer.forEach(aDisabledExpRole -> {

View File

@@ -66,7 +66,6 @@ public class Rank extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
RankModel rankModel = (RankModel) ContextConverter.slimFromCommandContext(commandContext, RankModel.class);
LeaderBoardEntry userRank = userExperienceService.getRankOfUserInServer(commandContext.getUserInitiatedContext().getAUserInAServer());
CompletableFuture<LeaderBoardEntryModel> future = converter.fromLeaderBoardEntry(userRank);

View File

@@ -41,7 +41,6 @@ public class SetExpRole extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
Integer level = (Integer) commandContext.getParameters().getParameters().get(0);
Role role = (Role) commandContext.getParameters().getParameters().get(1);
log.info("Setting role {} to be used for level {} on server {}", role.getId(), level, role.getGuild().getId());

View File

@@ -33,7 +33,6 @@ public class UnSetExpRole extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
ARole role = (ARole) commandContext.getParameters().getParameters().get(0);
ARole actualRole = roleManagementService.findRole(role.getId());
// do not check for the existence of the role, because if the role was deleted, users should be able

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.experience.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.ARole;
@@ -34,16 +32,6 @@ public class DisableExpForRoleTest {
@Mock
private DisabledExpRoleManagementService disabledExpRoleManagementService;
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTest(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void testExecuteCommandForNotDisabledRole() {
executeDisableExpForRoleTest(false, 1);

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.experience.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
@@ -34,16 +32,6 @@ public class DisableExpGainTest {
@Mock
private UserInServerManagementService userInServerManagementService;
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTest(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void testDisableExpForMember() {
CommandContext noParameters = CommandTestUtilities.getNoParameters();

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.experience.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.ARole;
@@ -32,16 +30,6 @@ public class EnableExpForRoleTest {
@Mock
private RoleManagementService roleManagementService;
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTest(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void testExecuteCommandForNotDisabledRole() {
executeEnableExpForRoleTest(false, 0);

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.experience.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
@@ -34,16 +32,6 @@ public class EnableExpGainTest {
@Mock
private UserInServerManagementService userInServerManagementService;
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTest(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void testEnableExpForMember() {
CommandContext noParameters = CommandTestUtilities.getNoParameters();

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.experience.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.service.ConfigService;
@@ -26,16 +24,6 @@ public class ExpScaleTest {
@Mock
private ConfigService configService;
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTest(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void testSetExpScaleForGuild() {
double newScale = 4.5;

View File

@@ -1,6 +1,5 @@
package dev.sheldan.abstracto.experience.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.service.ChannelService;
@@ -44,11 +43,6 @@ public class LeaderBoardCommandTest {
@Mock
private LeaderBoardModelConverter converter;
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void testLeaderBoardWithNoParameter() {
testLeaderBoardCommand(CommandTestUtilities.getNoParameters(), 1);

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.experience.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.service.RoleService;
@@ -37,28 +35,6 @@ public class SetExpRoleTest {
@Mock
private RoleManagementService roleManagementService;
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = InsufficientParametersException.class)
public void testRoleMissing() {
CommandContext context = CommandTestUtilities.getWithParameters(Arrays.asList(4));
testUnit.executeAsync(context);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testLevelProvidedButNotRole() {
CommandContext context = CommandTestUtilities.getWithParameters(Arrays.asList(4, ""));
testUnit.executeAsync(context);
}
@Test
public void setExpRole() {
CommandContext noParameters = CommandTestUtilities.getNoParameters();

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.experience.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.ARole;
@@ -34,16 +32,6 @@ public class UnSetExpRoleTest {
@Mock
private RoleManagementService roleManagementService;
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void setUnSetExpRole() {
CommandContext noParameters = CommandTestUtilities.getNoParameters();