Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into mainToDev
Browse files Browse the repository at this point in the history
# Conflicts:
#	report-viewer/package-lock.json
  • Loading branch information
Kr0nox committed Jun 22, 2024
2 parents 570efab + 9b2a7e8 commit 815d005
Show file tree
Hide file tree
Showing 110 changed files with 1,160 additions and 1,176 deletions.
6 changes: 3 additions & 3 deletions cli/src/main/java/de/jplag/cli/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public CLI(String[] args) {
}

/**
* Executes the cli
* Executes the cli.
* @throws ExitException If anything on the side of JPlag goes wrong
* @throws IOException If any files did not work
*/
Expand Down Expand Up @@ -84,7 +84,7 @@ public boolean executeCliAndHandleErrors() {
}

/**
* Runs JPlag and returns the file the result has been written to
* Runs JPlag and returns the file the result has been written to.
* @return The file containing the result
* @throws ExitException If JPlag threw an exception
* @throws FileNotFoundException If the file could not be written
Expand All @@ -103,7 +103,7 @@ public File runJPlag() throws ExitException, FileNotFoundException {
}

/**
* Runs the report viewer using the given file as the default result.zip
* Runs the report viewer using the given file as the default result.zip.
* @param zipFile The zip file to pass to the viewer. Can be null, if no result should be opened by default
* @throws IOException If something went wrong with the internal server
*/
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/de/jplag/cli/JPlagOptionsBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import de.jplag.options.JPlagOptions;

/**
* Handles the building of JPlag options from the cli options
* Handles the building of JPlag options from the cli options.
*/
public class JPlagOptionsBuilder {
private static final Logger logger = LoggerFactory.getLogger(JPlagOptionsBuilder.class);
Expand All @@ -25,7 +25,7 @@ public class JPlagOptionsBuilder {
private final CliOptions cliOptions;

/**
* @param cliInputHandler The cli handler containing the parsed cli options
* @param cliInputHandler The cli handler containing the parsed cli options.
*/
public JPlagOptionsBuilder(CliInputHandler cliInputHandler) {
this.cliInputHandler = cliInputHandler;
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/de/jplag/cli/JPlagRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private JPlagRunner() {
}

/**
* Executes JPlag
* Executes JPlag.
* @param options The options to pass to JPlag
* @return The result returned by JPlag
* @throws ExitException If JPlag throws an error
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/de/jplag/cli/OutputFileGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import de.jplag.reporting.reportobject.ReportObjectFactory;

/**
* Manages the creation of output files
* Manages the creation of output files.
*/
public final class OutputFileGenerator {
private static final Logger logger = LoggerFactory.getLogger(OutputFileGenerator.class);
Expand All @@ -40,7 +40,7 @@ public static void generateCsvOutput(JPlagResult result, File outputRoot, CliOpt
}

/**
* Generates the JPLag result zip
* Generates the JPLag result zip.
* @param result The JPlag result
* @param outputFile The output file
* @throws FileNotFoundException If the file cannot be written
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/de/jplag/cli/logger/CollectedLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.slf4j.helpers.MessageFormatter;

/**
* A logger implementation, that prints all errors during finalization
* A logger implementation, that prints all errors during finalization.
*/
public class CollectedLogger extends JPlagLoggerBase {
private static final int MAXIMUM_MESSAGE_LENGTH = 32;
Expand Down
3 changes: 2 additions & 1 deletion cli/src/main/java/de/jplag/cli/logger/IdleBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public void dispose() {
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
this.output.println();
this.output.print('\r');
this.output.println(this.text + ": complete");
}

private void run() {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/de/jplag/cli/logger/LogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.slf4j.event.Level;

/**
* Holds a log entry for later usage
* Holds a log entry for later usage.
* @param message The message of the log
* @param cause The cause of the log
* @param timeOfLog The time of the log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import picocli.CommandLine.ParseResult;

/**
* Handles the parsing of the command line arguments
* Handles the parsing of the command line arguments.
*/
public class CliInputHandler {
private static final String OPTION_LIST_HEADING = "Parameter descriptions: ";
Expand Down
6 changes: 3 additions & 3 deletions cli/src/main/java/de/jplag/cli/picocli/CustomHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import picocli.CommandLine;

/**
* Custom implementation for the help page, including the custom {@link ParamLabelRenderer}
* Custom implementation for the help page, including the custom {@link ParameterLabelRenderer}.
*/
public class CustomHelp extends CommandLine.Help {
private final IParamLabelRenderer paramLabelRenderer;

/**
* New instance
* Created a custom help text.
* @param command The {@link picocli.CommandLine.Model.CommandSpec} to build the help for
* @param colorScheme The {@link picocli.CommandLine.Help.ColorScheme} for the help page
*/
public CustomHelp(CommandLine.Model.CommandSpec command, ColorScheme colorScheme) {
super(command, colorScheme);

this.paramLabelRenderer = new ParamLabelRenderer(super.parameterLabelRenderer());
this.paramLabelRenderer = new ParameterLabelRenderer(super.parameterLabelRenderer());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/de/jplag/cli/picocli/HelpFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import picocli.CommandLine;

/**
* Custom help factory, used to add the custom {@link ParamLabelRenderer}.
* Custom help factory, used to add the custom {@link ParameterLabelRenderer}.
*/
public class HelpFactory implements CommandLine.IHelpFactory {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@
* Custom implementation of {@link picocli.CommandLine.Help.IParamLabelRenderer}, that show the available options for
* enums. For all other parameter types, the base renderer is called.
*/
public class ParamLabelRenderer implements CommandLine.Help.IParamLabelRenderer {
private final CommandLine.Help.IParamLabelRenderer base;
public class ParameterLabelRenderer implements CommandLine.Help.IParamLabelRenderer {

private static final String PARAM_LABEL_PATTERN = "=<{%s}>";
private static final String VALUE_SEPARATOR = ", ";

private final CommandLine.Help.IParamLabelRenderer base;

/**
* New instance
* Creates a new parameter label renderer.
* @param base The base renderer used for all non enum types
*/
public ParamLabelRenderer(CommandLine.Help.IParamLabelRenderer base) {
public ParameterLabelRenderer(CommandLine.Help.IParamLabelRenderer base) {
this.base = base;
}

@Override
public CommandLine.Help.Ansi.Text renderParameterLabel(CommandLine.Model.ArgSpec argSpec, CommandLine.Help.Ansi ansi,
List<CommandLine.Help.Ansi.IStyle> styles) {
if (argSpec.type().isEnum()) {
@SuppressWarnings("unchecked")
Enum<?>[] enumConstants = ((Class<Enum<?>>) argSpec.type()).getEnumConstants();
String enumValueNames = Arrays.stream(enumConstants).map(Enum::name).collect(Collectors.joining(VALUE_SEPARATOR));
Object[] enumConstants = argSpec.type().getEnumConstants();
String enumValueNames = Arrays.stream(enumConstants).map(enumConstant -> (Enum.class.cast(enumConstant)).name())
.collect(Collectors.joining(VALUE_SEPARATOR));
return CommandLine.Help.Ansi.AUTO.text(String.format(PARAM_LABEL_PATTERN, enumValueNames));
}

Expand Down
1 change: 1 addition & 0 deletions cli/src/main/java/de/jplag/cli/server/ReportViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ReportViewer implements HttpHandler {
private HttpServer server;

/**
* Launches a locally hosted report viewer.
* @param zipFile The zip file to use for the report viewer
* @param port The port to use for the server. You can use 0 to use any free port.
* @throws IOException If the zip file cannot be read
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/de/jplag/cli/server/ResponseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.InputStream;

/**
* Data for a http response
* Data for a http response.
* @param stream The stream containing the binary data
* @param contentType The type of data
* @param size The total size of the data
Expand All @@ -18,7 +18,7 @@ public ResponseData(InputStream data) {
}

/**
* Constructor with unknown size
* Constructor with unknown size.
* @param data The binary data
* @param contentType The type of content
*/
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/de/jplag/cli/server/Routing.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ default HttpRequestMethod[] allowedMethods() {
}

/**
* Gets the data for the given url
* Gets the data for the given url.
* @param subPath The remaining suffix of the url, that is not yet interpreted
* @param request The original http request
* @param viewer The current report viewer
Expand Down
6 changes: 3 additions & 3 deletions cli/src/main/java/de/jplag/cli/server/RoutingAlias.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import com.sun.net.httpserver.HttpExchange;

/**
* An alias routing, that will respond with the response for a different path
* An alias routing, that will respond with the response for a different path.
*/
public class RoutingAlias implements Routing {
private final RoutingPath path;

/**
* @param path The path to actually use
* @param path The path to actually use.
*/
public RoutingAlias(RoutingPath path) {
this.path = path;
}

/**
* @param path The path to actually use
* @param path The path to actually use.
*/
public RoutingAlias(String path) {
this(new RoutingPath(path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.sun.net.httpserver.HttpExchange;

/**
* Responds with data from the resources
* Responds with data from the resources.
*/
public class RoutingResources implements Routing {
private String prefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.sun.net.httpserver.HttpExchange;

/**
* Responds with a given file
* Responds with a given file.
*/
public class RoutingStaticFile implements Routing {
private final byte[] data;
Expand Down
14 changes: 7 additions & 7 deletions cli/src/main/java/de/jplag/cli/server/RoutingTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
import org.apache.commons.lang3.tuple.Pair;

/**
* Manages the tree of paths handled by the web server
* Manages the tree of paths handled by the web server.
*/
public class RoutingTree {
private final RoutingTreeNode root;

/**
* Creates an empty tree
* Creates an empty tree.
*/
public RoutingTree() {
this.root = new RoutingTreeNode();
}

/**
* Adds a new routing to the tree
* Adds a new routing to the tree.
* @param path The path to use the routing for
* @param routing The routing
*/
Expand All @@ -28,7 +28,7 @@ public void insertRouting(RoutingPath path, Routing routing) {
}

/**
* Adds a new routing to the tree
* Adds a new routing to the tree.
* @param path The path to use the routing for
* @param routing The routing
*/
Expand All @@ -37,7 +37,7 @@ public void insertRouting(String path, Routing routing) {
}

/**
* Gets the routing for a given path
* Gets the routing for a given path.
* @param path The path to look up
* @return The remaining path to be handled by the routing and the found routing
*/
Expand All @@ -49,12 +49,12 @@ private static class RoutingTreeNode {
private final Map<String, RoutingTreeNode> children;
private Routing routing;

public RoutingTreeNode(RoutingPath building, Routing routing) {
RoutingTreeNode(RoutingPath building, Routing routing) {
this();
this.buildRouting(building, routing);
}

public RoutingTreeNode() {
RoutingTreeNode() {
this.children = new HashMap<>();
}

Expand Down
23 changes: 0 additions & 23 deletions cli/src/test/java/de/jplag/cli/AdvancedGroupTest.java

This file was deleted.

21 changes: 16 additions & 5 deletions cli/src/test/java/de/jplag/cli/BaseCodeOptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,32 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.io.IOException;

import org.junit.jupiter.api.Test;

class BaseCodeOptionTest extends CommandLineInterfaceTest {
import de.jplag.cli.test.CliArgument;
import de.jplag.cli.test.CliResult;
import de.jplag.cli.test.CliTest;
import de.jplag.exceptions.ExitException;
import de.jplag.options.JPlagOptions;

class BaseCodeOptionTest extends CliTest {

private static final String NAME = "BaseCodeName";

@Test
void testDefaultValue() throws CliException {
buildOptionsFromCLI(defaultArguments());
void testDefaultValue() throws ExitException, IOException {
JPlagOptions options = runCli().jPlagOptions();

assertNull(options.baseCodeSubmissionDirectory());
}

@Test
void testCustomName() throws CliException {
buildOptionsFromCLI(defaultArguments().baseCode(NAME));
void testCustomName() throws ExitException, IOException {
CliResult result = runCli(options -> options.with(CliArgument.BASE_CODE, NAME));
JPlagOptions options = result.jPlagOptions();

assertEquals(NAME, options.baseCodeSubmissionDirectory().getName());
}
}
Loading

0 comments on commit 815d005

Please sign in to comment.