You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2022/01/20 18:25:40 UTC
[sling-org-apache-sling-repoinit-parser] 02/02: SLING-11078 - Adding JavaDocs to describe the Operation.asRepoInitString() contract and validate line separate compliance
This is an automated email from the ASF dual-hosted git repository.
dklco pushed a commit to branch SLING-11078
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-repoinit-parser.git
commit 0ee646daf979b495eb9a9d5c9208ea4b02bd9d8c
Author: Dan Klco <kl...@adobe.com>
AuthorDate: Thu Jan 20 13:25:22 2022 -0500
SLING-11078 - Adding JavaDocs to describe the Operation.asRepoInitString() contract and validate line separate compliance
---
.../org/apache/sling/repoinit/parser/operations/Operation.java | 8 ++++++++
.../apache/sling/repoinit/parser/operations/AsRepoInitTest.java | 9 ++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/repoinit/parser/operations/Operation.java b/src/main/java/org/apache/sling/repoinit/parser/operations/Operation.java
index 9aa4157..aed4b43 100644
--- a/src/main/java/org/apache/sling/repoinit/parser/operations/Operation.java
+++ b/src/main/java/org/apache/sling/repoinit/parser/operations/Operation.java
@@ -31,6 +31,14 @@ public abstract class Operation {
protected abstract String getParametersDescription();
+ /**
+ * Converts this operation instance to a RepoInit string representation
+ * including the current operation parameters. The representation must be
+ * parsable back into an equivalent operation and must end with a OS-compatible
+ * line separator.
+ *
+ * @return the repoinit string for the operation
+ */
@NotNull
public abstract String asRepoInitString();
diff --git a/src/test/java/org/apache/sling/repoinit/parser/operations/AsRepoInitTest.java b/src/test/java/org/apache/sling/repoinit/parser/operations/AsRepoInitTest.java
index fe12c50..1c19cd2 100644
--- a/src/test/java/org/apache/sling/repoinit/parser/operations/AsRepoInitTest.java
+++ b/src/test/java/org/apache/sling/repoinit/parser/operations/AsRepoInitTest.java
@@ -25,6 +25,8 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
@@ -52,7 +54,12 @@ public class AsRepoInitTest {
private static Reader rebuildInputScript(Reader input) throws Exception {
StringBuilder sb = new StringBuilder();
for (Operation o : new RepoInitParserService().parse(input)) {
- sb.append(o.asRepoInitString());
+ String repoinitStatement = o.asRepoInitString();
+ assertTrue(
+ "Operation.asRepoInitString() should always end with an-OS agnostic line separator. Not found for "
+ + o.toString(),
+ repoinitStatement.endsWith(System.lineSeparator()));
+ sb.append(repoinitStatement);
}
return new StringReader(sb.toString());
}