[AB-246] fixing new lines being removed from parameters

creating javadoc profile to only build javadoc on release builds
This commit is contained in:
Sheldan
2021-05-02 20:33:23 +02:00
parent bbae3575f8
commit a35cc0ab61
21 changed files with 38 additions and 49 deletions

View File

@@ -17,7 +17,7 @@ jobs:
id: version id: version
run: echo "version=$(mvn --file abstracto-application/pom.xml -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_ENV run: echo "version=$(mvn --file abstracto-application/pom.xml -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_ENV
- name: Publish to GitHub Packages - name: Publish to GitHub Packages
run: mvn --file abstracto-application/pom.xml -B deploy -P documentation,deployment-docker -Dmaven.wagon.http.pool=false -DskipTests=true run: mvn --file abstracto-application/pom.xml -B deploy -P documentation,javadoc -Dmaven.wagon.http.pool=false -DskipTests=true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy documentation to GitHub pages - name: Deploy documentation to GitHub pages

View File

@@ -35,7 +35,7 @@ public class AChannelParameterHandlerImpl implements AChannelParameterHandler {
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
TextChannel textChannel = (TextChannel) textChannelParameterHandler.handle(input, iterators, param, context, command); TextChannel textChannel = (TextChannel) textChannelParameterHandler.handle(input, iterators, param, context, command);
if(textChannel == null) { if(textChannel == null) {
Long channelId = Long.parseLong((String) input.getValue()); Long channelId = Long.parseLong(((String) input.getValue()).trim());
AChannel actualInstance = channelManagementService.loadChannel(channelId); AChannel actualInstance = channelManagementService.loadChannel(channelId);
return AChannel.builder().fake(true).id(actualInstance.getId()).build(); return AChannel.builder().fake(true).id(actualInstance.getId()).build();
} else { } else {

View File

@@ -41,7 +41,7 @@ public class AUserInAServerParameterHandlerImpl implements AUserInAServerParamet
Member member = (Member) o; Member member = (Member) o;
actualInstance = userInServerManagementService.loadOrCreateUser(member); actualInstance = userInServerManagementService.loadOrCreateUser(member);
} else { } else {
Long userId = Long.parseLong((String) input.getValue()); Long userId = Long.parseLong(((String) input.getValue()).trim());
actualInstance = userInServerManagementService.loadAUserInAServerOptional(context.getGuild().getIdLong(), userId).orElseThrow(() -> new UserInServerNotFoundException(0L)); actualInstance = userInServerManagementService.loadAUserInAServerOptional(context.getGuild().getIdLong(), userId).orElseThrow(() -> new UserInServerNotFoundException(0L));
} }
future.complete(AUserInAServer.builder().userInServerId(actualInstance.getUserInServerId()).build()); future.complete(AUserInAServer.builder().userInServerId(actualInstance.getUserInServerId()).build());

View File

@@ -18,7 +18,7 @@ public class BooleanParameterHandlerImpl implements BooleanParameterHandler {
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
return Boolean.valueOf((String) input.getValue()); return Boolean.valueOf(((String) input.getValue()).trim());
} }
@Override @Override

View File

@@ -28,7 +28,7 @@ public class ChannelGroupParameterHandlerImpl implements ChannelGroupParameterHa
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
AServer server = serverManagementService.loadServer(context.getGuild().getIdLong()); AServer server = serverManagementService.loadServer(context.getGuild().getIdLong());
String inputString = (String) input.getValue(); String inputString = ((String) input.getValue()).trim();
AChannelGroup actualInstance = channelGroupManagementService.findByNameAndServerOptional(inputString, server) AChannelGroup actualInstance = channelGroupManagementService.findByNameAndServerOptional(inputString, server)
.orElseThrow(() -> new ChannelGroupNotFoundException(inputString, channelGroupManagementService.getAllAvailableAsString(server))); .orElseThrow(() -> new ChannelGroupNotFoundException(inputString, channelGroupManagementService.getAllAvailableAsString(server)));
ChannelGroupType channelGroupType = ChannelGroupType ChannelGroupType channelGroupType = ChannelGroupType

View File

@@ -29,7 +29,7 @@ public class ChannelGroupTypeParameterHandlerImpl implements ChannelGroupTypePar
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
ChannelGroupType actualGroupType = channelGroupTypeManagementService.findChannelGroupTypeByKey((String) input.getValue()); ChannelGroupType actualGroupType = channelGroupTypeManagementService.findChannelGroupTypeByKey(((String) input.getValue()).trim());
return ChannelGroupType return ChannelGroupType
.builder() .builder()
.groupTypeKey(actualGroupType.getGroupTypeKey()) .groupTypeKey(actualGroupType.getGroupTypeKey())

View File

@@ -20,7 +20,7 @@ public class CommandKeyParameterHandlerImpl implements CommandKeyParameterHandle
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
return CommandParameterKey.getEnumFromKey(param.getType(), (String) input.getValue()); return CommandParameterKey.getEnumFromKey(param.getType(), ((String) input.getValue()).trim());
} }
@Override @Override

View File

@@ -18,7 +18,7 @@ public class DoubleParameterHandlerImpl implements DoubleParameterHandler {
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
return Double.parseDouble((String) input.getValue()); return Double.parseDouble(((String) input.getValue()).trim());
} }
@Override @Override

View File

@@ -21,7 +21,7 @@ public class DurationParameterHandlerImpl implements DurationParameterHandler {
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
return ParseUtils.parseDuration((String) input.getValue()); return ParseUtils.parseDuration(((String) input.getValue()).trim());
} }
@Override @Override

View File

@@ -22,7 +22,7 @@ public class EmoteParameterHandlerImpl implements EmoteParameterHandler {
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
String inputString = (String) input.getValue(); String inputString = ((String) input.getValue()).trim();
Matcher matcher = Message.MentionType.EMOTE.getPattern().matcher(inputString); Matcher matcher = Message.MentionType.EMOTE.getPattern().matcher(inputString);
if(matcher.matches() && iterators.getEmoteIterator().hasNext()) { if(matcher.matches() && iterators.getEmoteIterator().hasNext()) {
return iterators.getEmoteIterator().next(); return iterators.getEmoteIterator().next();

View File

@@ -19,7 +19,7 @@ public class IntegerParameterHandlerImpl implements IntegerParameterHandler {
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
return Integer.parseInt((String) input.getValue()); return Integer.parseInt(((String) input.getValue()).trim());
} }
@Override @Override

View File

@@ -19,7 +19,7 @@ public class LongParameterHandlerImpl implements LongParameterHandler {
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
return Long.parseLong((String) input.getValue()); return Long.parseLong(((String) input.getValue()).trim());
} }
@Override @Override

View File

@@ -30,7 +30,7 @@ public class MemberParameterHandlerImpl implements MemberParameterHandler {
@Override @Override
public CompletableFuture<Object> handleAsync(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public CompletableFuture<Object> handleAsync(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
String inputString = (String) input.getValue(); String inputString = ((String) input.getValue()).trim();
Matcher matcher = Message.MentionType.USER.getPattern().matcher(inputString); Matcher matcher = Message.MentionType.USER.getPattern().matcher(inputString);
if(matcher.matches() && iterators.getMemberIterator().hasNext()) { if(matcher.matches() && iterators.getMemberIterator().hasNext()) {
return CompletableFuture.completedFuture(iterators.getMemberIterator().next()); return CompletableFuture.completedFuture(iterators.getMemberIterator().next());

View File

@@ -24,7 +24,7 @@ public class RoleParameterHandlerImpl implements RoleParameterHandler {
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
String inputString = (String) input.getValue(); String inputString = ((String) input.getValue()).trim();
Matcher matcher = Message.MentionType.ROLE.getPattern().matcher(inputString); Matcher matcher = Message.MentionType.ROLE.getPattern().matcher(inputString);
if(matcher.matches() && iterators.getRoleIterator().hasNext()) { if(matcher.matches() && iterators.getRoleIterator().hasNext()) {
return iterators.getRoleIterator().next(); return iterators.getRoleIterator().next();

View File

@@ -24,7 +24,7 @@ public class TextChannelParameterHandlerImpl implements TextChannelParameterHand
@Override @Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) { public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
String inputString = (String) input.getValue(); String inputString = ((String) input.getValue()).trim();
Matcher matcher = Message.MentionType.CHANNEL.getPattern().matcher(inputString); Matcher matcher = Message.MentionType.CHANNEL.getPattern().matcher(inputString);
if(matcher.matches() && iterators.getChannelIterator().hasNext()) { if(matcher.matches() && iterators.getChannelIterator().hasNext()) {
return iterators.getChannelIterator().next(); return iterators.getChannelIterator().next();

View File

@@ -51,12 +51,6 @@ public class BooleanParameterHandlerImplTest extends AbstractParameterHandlerTes
Assert.assertFalse((Boolean)testUnit.handle(piece, null, parameter, null, command)); Assert.assertFalse((Boolean)testUnit.handle(piece, null, parameter, null, command));
} }
@Test
public void testNullInput() {
UnparsedCommandParameterPiece piece = getPieceWithValue(null);
Assert.assertFalse((Boolean)testUnit.handle(piece, null, parameter, null, command));
}
@Test @Test
public void testEmptyStringAsInput() { public void testEmptyStringAsInput() {
UnparsedCommandParameterPiece piece = getPieceWithValue(""); UnparsedCommandParameterPiece piece = getPieceWithValue("");

View File

@@ -54,11 +54,6 @@ public class DurationParameterHandlerImplTest extends AbstractParameterHandlerTe
Assert.assertEquals(targetDuration, testUnit.handle(getPieceWithValue("5h5m4d"), null, parameter, null, command)); Assert.assertEquals(targetDuration, testUnit.handle(getPieceWithValue("5h5m4d"), null, parameter, null, command));
} }
@Test(expected = DurationFormatException.class)
public void testNullInput() {
testUnit.handle(getPieceWithValue(null), null, parameter, null, command);
}
@Test(expected = DurationFormatException.class) @Test(expected = DurationFormatException.class)
public void testEmptyStringAsInput() { public void testEmptyStringAsInput() {
testUnit.handle(getPieceWithValue(""), null, parameter, null, command); testUnit.handle(getPieceWithValue(""), null, parameter, null, command);

View File

@@ -60,11 +60,6 @@ public class IntegerParameterHandlerImplTest extends AbstractParameterHandlerTes
testUnit.handle(getPieceWithValue("someText"), null, parameter, null, command); testUnit.handle(getPieceWithValue("someText"), null, parameter, null, command);
} }
@Test(expected = NumberFormatException.class)
public void testNullInput() {
testUnit.handle(getPieceWithValue(null), null, parameter, null, command);
}
@Test(expected = NumberFormatException.class) @Test(expected = NumberFormatException.class)
public void testEmptyStringAsInput() { public void testEmptyStringAsInput() {
testUnit.handle(getPieceWithValue(""), null, parameter, null, command); testUnit.handle(getPieceWithValue(""), null, parameter, null, command);

View File

@@ -59,11 +59,6 @@ public class LongParameterHandlerImplTest extends AbstractParameterHandlerTest {
testUnit.handle(getPieceWithValue("someText"), null, parameter, null, command); testUnit.handle(getPieceWithValue("someText"), null, parameter, null, command);
} }
@Test(expected = NumberFormatException.class)
public void testNullInput() {
testUnit.handle(getPieceWithValue(null), null, parameter, null, command);
}
@Test(expected = NumberFormatException.class) @Test(expected = NumberFormatException.class)
public void testEmptyStringAsInput() { public void testEmptyStringAsInput() {
testUnit.handle(getPieceWithValue(""), null, parameter, null, command); testUnit.handle(getPieceWithValue(""), null, parameter, null, command);

View File

@@ -11,7 +11,7 @@ import java.util.regex.Pattern;
@Getter @Getter
public class UnParsedCommandParameter { public class UnParsedCommandParameter {
private static Pattern SPLIT_REGEX = Pattern.compile("\"([^\"]*)\"|(\\S+)"); private static Pattern SPLIT_REGEX = Pattern.compile("\"([^\"]*)\"|(\\S+\\n*)");
public UnParsedCommandParameter(String parameters, Message message) { public UnParsedCommandParameter(String parameters, Message message) {
this.parameters = new ArrayList<>(); this.parameters = new ArrayList<>();

View File

@@ -139,21 +139,31 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>javadoc</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>