Skip to content

Commit

Permalink
Reformat all files via InteliJ IDEA base don our checkstyle (#37)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Stejskal <[email protected]>
  • Loading branch information
Frawless authored Jun 28, 2024
1 parent fc98e52 commit 6095bd8
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 59 deletions.
8 changes: 7 additions & 1 deletion .checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
</module>
<module name="Indentation"/>
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="tabWidth" value="4"/>
</module>
<module name="MethodParamPad"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
Expand Down
6 changes: 3 additions & 3 deletions dummy-module/src/test/java/io/skodjob/DummyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void testMethodOne() {

@TestDoc(
description = @Desc("Test checking that the application works as expected. " +
"This is just a little bit longer line, nothing else."),
"This is just a little bit longer line, nothing else."),
contact = @Contact(name = "Jakub Stejskal", email = "[email protected]"),
steps = {
@Step(value = "Create object instance", expected = "Instance of an object is created"),
Expand All @@ -60,7 +60,7 @@ void testMethodTwo() {

@TestDoc(
description = @Desc("Test checking that the application works as expected. " +
"This is just a little bit longer line, nothing else."),
"This is just a little bit longer line, nothing else."),
contact = @Contact(name = "Jakub Stejskal", email = "[email protected]")
)
void testMethodThree() {
Expand All @@ -69,7 +69,7 @@ void testMethodThree() {

@TestDoc(
description = @Desc("Test checking that the application works as expected. " +
"This is just a little bit longer line, nothing else."),
"This is just a little bit longer line, nothing else."),
contact = @Contact(name = "Jakub Stejskal", email = "[email protected]"),
labels = {
@Label(value = "default"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
* DocGeneratorMojo class for Maven plugin handling
*/
@Mojo(
name = "test-docs-generator",
defaultPhase = LifecyclePhase.COMPILE,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME
name = "test-docs-generator",
defaultPhase = LifecyclePhase.COMPILE,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME
)
public class DocGeneratorMojo extends AbstractMojo {

Expand Down Expand Up @@ -79,10 +79,10 @@ public DocGeneratorMojo() {
/**
* Method for the execution of the test-docs-generator Maven plugin
* Generates documentation of test-cases based on specified parameters:
* - {@link #testsPath}
* - {@link #docsPath}
* - {@link #project}
* - {@link #descriptor}
* <ul><li>{@link #testsPath}</li>
* <li>{@link #docsPath}</li>
* <li>{@link #project}</li>
* <li>{@link #descriptor}</li></ul>
*/
public void execute() {

Expand All @@ -100,7 +100,7 @@ public void execute() {
// Add all jar files in target lib
addJarFilesToClassPath(new File(project.getBuild().getDirectory()), classRealm);
} catch (MalformedURLException e) {
e.printStackTrace();
getLog().error(e);
}

getLog().debug("Loaded files in classpath:");
Expand All @@ -121,7 +121,7 @@ public void execute() {
} else {
getLog().debug("Skipping fmf generation");
}
MdGenerator.generate(testClass, docsPath + mdDirectoryName + entry.getKey() + ".md");
MdGenerator.generate(testClass, docsPath + mdDirectoryName + entry.getKey() + ".md");

} catch (ClassNotFoundException | IOException ex) {
getLog().warn(String.format("Cannot load %s", entry.getValue()));
Expand All @@ -136,9 +136,10 @@ public void execute() {

/**
* It goes through all files inside the {@param directory} and does two things:
* - in case that file is directory (another package), it recursively calls itself and adds all .jar files to the classPath
* - otherwise adds the .jar files to classPath
* @param directory where the files are listed
* <ul><li>in case that file is directory (another package), it recursively calls itself and adds all .jar files to the classPath</li>
* <li>otherwise adds the .jar files to classPath</li></ul>
*
* @param directory where the files are listed
* @param classRealm realm containing all libs set on classPath, from where the test-classes will be loaded
* @throws MalformedURLException during URL construction
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private FmfGenerator() {
* parent folders (if needed), new FMF file for the class, and after that generates test-suite documentation using
* {@link #generateDocumentationForTestCases(PrintWriter, List)}, all written inside the newly created Markdown file.
*
* @param testClass for which the FMF file is created and test-cases are documented
* @param testClass for which the FMF file is created and test-cases are documented
* @param classFilePath path of the FMF file
* @throws IOException during file creation
*/
Expand All @@ -63,7 +63,8 @@ public static void generate(Class<?> testClass, String classFilePath) throws IOE

/**
* Generates documentation records for each test-cases (test-methods) from {@param methods}
* @param writer file writer
*
* @param writer file writer
* @param methods containing {@link TestDoc} annotation
*/
private static void generateDocumentationForTestCases(PrintWriter writer, List<Method> methods) {
Expand All @@ -82,8 +83,8 @@ private static void generateDocumentationForTestCases(PrintWriter writer, List<M
* The record contains: name of the test, description, steps, labels, and use-cases obtained from the
* {@param testDoc}.
*
* @param write file writer
* @param testDoc annotation containing all @TestDoc objects, from which is the record generated
* @param write file writer
* @param testDoc annotation containing all @TestDoc objects, from which is the record generated
* @param methodName name of the test-case containing {@param testDoc}
*/
public static void createTestRecord(PrintWriter write, TestDoc testDoc, String methodName) {
Expand Down Expand Up @@ -138,6 +139,7 @@ private static List<Map<String, String>> createListOfSteps(Step[] steps) {

/**
* Creates list of labels for the particular test-case
*
* @param labels list of labels from the {@link TestDoc} annotation
* @return list of labels in {@link List<String>}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ public static void createSuiteRecord(PrintWriter write, SuiteDoc suiteDoc) {

/**
* For the provided list of steps creates table with following columns:
* - Step - number of the current step
* - Action - action done during the step
* - Result - expected result of the step
* <ul>Step - number of the current step</li>
* <li>Action - action done during the step</li>
* <li>Result - expected result of the step</li></ul>
*
* @param steps list of steps of the test-case
* @return String representation of table in Markdown
Expand Down Expand Up @@ -231,7 +231,7 @@ private static List<String> createLabels(Label[] labels) {
* Update label file that is available in the docs dir
*
* @param labelFilePath path to label file within docs dir
* @param updatedData data that will be put into the file
* @param updatedData data that will be put into the file
*/
private static void updateLabelFile(String labelFilePath, String updatedData) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
public @interface Contact {
/**
* Contact name of the test-case stored inside `name` field
*
* @return name in String
*/
String name();

/**
* Contact email of the test-case stored inside `email` field
*
* @return email in String
*/
String email();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public @interface Desc {
/**
* Description of the test-case stored inside `value` field
*
* @return description in String
*/
String value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public @interface Label {
/**
* Label of the test-case stored inside `value` field
*
* @return label in String
*/
String value() default "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
public @interface Step {
/**
* Step of the test-case stored inside `value` field
*
* @return step in String
*/
String value() default "";

/**
* Expected outcome of the particular step in test-case
*
* @return expected outcome in String
*/
String expected() default "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,41 @@

/**
* Annotation collecting all information about the test-suite.
* Currently, we can specify following:
* - description
* - beforeTestSteps
* - afterTestSteps
* - labels
*
* Example usage:
* ```
* \@SuiteDoc(
* description = @Desc("My test suite containing various tests"),
* beforeTestSteps = {
* \@Step(value = "Deploy uber operator across all namespaces, with custom configuration", expected = "Uber operator is deployed"),
* \@Step(value = "Deploy management Pod for accessing all other Pods", expected = "Management Pod is deployed")
* },
* afterTestSteps = {
* \@Step(value = "Delete management Pod", expected = "Management Pod is deleted"),
* \@Step(value = "Delete uber operator", expected = "Uber operator is deleted")
* },
* labels = {
* \@Label(value = "regression")
* }
* )
* public static class TestClass {
* ```
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface SuiteDoc {

/**
* Description of particular test-suite
*
* @return description in {@link Desc}
*/
Desc description();

/**
* Contact name of particular test-case
*
* @return contact name in {@link Contact}
*/
Contact contact() default @Contact(name = "", email = "");

/**
* Array of steps done before tests execution
*
* @return array of steps in {@link Step}
*/
Step[] beforeTestSteps() default {};

/**
* Array of steps done after tests execution
*
* @return array of steps in {@link Step}
*/
Step[] afterTestSteps() default {};

/**
* Array of labels describing the test-case
*
* @return array of labels in {@link Label}
*/
Label[] labels() default {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,28 @@

/**
* Description of particular test-case
*
* @return description in {@link Desc}
*/
Desc description();

/**
* Contact name of particular test-case
*
* @return contact name in {@link Contact}
*/
Contact contact() default @Contact(name = "", email = "");

/**
* Array of steps done in the test-case
*
* @return array of steps in {@link Step}
*/
Step[] steps() default {};

/**
* Array of labels describing the test-case
*
* @return array of labels in {@link Label}
*/
Label[] labels() default {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ private Utils() {
/**
* Updates Map ({@param classes}) with info about classes inside {@param packagePath}.
* It goes through all files inside the {@param packagePath} and does two things:
* - in case that file is directory (another package), it recursively calls itself and adds all info needed for all files
* inside the directory
* - otherwise adds key/value record in the map
* - key -> path in which the particular `.md` file will be generated, typically {@param generatePath}/{@code classPackagePath}
* - f.e. -> ./test-docs/path/to/my/package/TestClassST
* - value -> path for the particular test class -> in package format, available on classpath
* - f.e. -> path.to.my.package.TestClassST
* @param classes Map that should be updated with test-classes info
* <ul><li>in case that file is directory (another package), it recursively calls itself and adds all info needed for all files inside the directory</li>
* <li>otherwise adds key/value record in the map
* <ul><li>key -> path in which the particular `.md` file will be generated, typically {@param generatePath}/{@code classPackagePath}
* <ul><li>f.e. -> ./test-docs/path/to/my/package/TestClassST</li>
* <li>value -> path for the particular test class -> in package format, available on classpath</li>
* <li>f.e. -> path.to.my.package.TestClassST</li></ul></li></ul></li></ul>
*
* @param classes Map that should be updated with test-classes info
* @param packagePath path on which the files and classes should be listed
* @return updated Map with test-classes info from the {@param packagePath}
*/
Expand Down Expand Up @@ -69,7 +69,8 @@ private static Map<String, String> getClassesForPackage(Map<String, String> clas
* path, where the Markdown file will be created, and value is package with class name available
* on classpath
* Also excludes files that should not be considered for documentation (currently just "AbstractST")
* @param filePath path where are all test-classes present
*
* @param filePath path where are all test-classes present
* @param generateDirs whether it should generate subfolders for packages or not
* @return Map with test-classes info from the {@param filePath}
*/
Expand All @@ -87,6 +88,7 @@ public static Map<String, String> getTestClassesWithTheirPath(String filePath, b

/**
* Creates needed files and folders for the particular test-suite (test-class)
*
* @param classFilePath path where the test-suite (test-class) is present
* @return file writer
* @throws IOException during file creation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private Header() {

/**
* Method for creating first level header containing {@param text}
*
* @param text that should be in first level header
* @return first level header with {@param text}
*/
Expand All @@ -27,6 +28,7 @@ public static String firstLevelHeader(String text) {

/**
* Method for creating second level header containing {@param text}
*
* @param text that should be in second level header
* @return second level header with {@param text}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private Line() {

/**
* Creates horizontal line
*
* @return horizontal line in String
*/
public static String horizontalLine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ private Table() {

/**
* Creates the Markdown table in text format, containing specified headers and rows
*
* @param headers list of headers that should be inside the table
* @param rows list of rows added to the table
* @param rows list of rows added to the table
* @return Markdown table in text format, returned as String
*/
public static String createTable(List<String> headers, List<String> rows) {
Expand All @@ -44,6 +45,7 @@ public static String createTable(List<String> headers, List<String> rows) {

/**
* Creates a single row for {@param content}
*
* @param content of the row
* @return table row in text format, returned as String
*/
Expand Down
Loading

0 comments on commit 6095bd8

Please sign in to comment.