Added Soft assertions to PuppetLintParserTest
@@ -9,7 +9,8 @@ import edu.hm.hafner.analysis.AbstractParser;
import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.Issues;
import edu.hm.hafner.analysis.Priority;
-import static org.junit.jupiter.api.Assertions.*;
+import static edu.hm.hafner.analysis.assertj.IssuesAssert.*;
+import static edu.hm.hafner.analysis.assertj.SoftAssertions.*;
/**
* Tests the class {@link PuppetLintParser}.
@@ -27,32 +28,26 @@ public class PuppetLintParserTest extends ParserTester {
@Test
public void testParse() throws IOException {
Issues results = createParser().parse(openFile());
- assertEquals(5, results.size());
+ assertThat(results).hasSize(5);
Iterator<Issue> iterator = results.iterator();
-
- Issue annotation = iterator.next();
- checkLintWarning(annotation,
+ checkLintWarning(iterator.next(),
1, "failtest not in autoload module layout",
"failtest.pp", TYPE, "autoloader_layout", Priority.HIGH, "-");
- annotation = iterator.next();
- checkLintWarning(annotation,
+ checkLintWarning(iterator.next(),
3, "line has more than 80 characters",
"./modules/test/manifests/init.pp", TYPE, "80chars", Priority.NORMAL, "::test");
- annotation = iterator.next();
- checkLintWarning(annotation,
+ checkLintWarning(iterator.next(),
10, "line has more than 80 characters",
"./modules/test/manifests/sub/class/morefail.pp", TYPE, "80chars", Priority.NORMAL, "::test::sub::class");
- annotation = iterator.next();
- checkLintWarning(annotation,
+ checkLintWarning(iterator.next(),
4, "tab character found",
"C:/ProgramData/PuppetLabs/puppet/etc/manifests/site.pp", TYPE, "hard_tabs", Priority.HIGH, "-");
- annotation = iterator.next();
- checkLintWarning(annotation,
+ checkLintWarning(iterator.next(),
15, "line has more than 80 characters",
"C:/CI CD/puppet/modules/jenkins/init.pp", TYPE, "80chars", Priority.NORMAL, "-");
}
@@ -71,8 +66,16 @@ public class PuppetLintParserTest extends ParserTester {
*/
// CHECKSTYLE:OFF
private void checkLintWarning(final Issue annotation, final int lineNumber, final String message, final String fileName, final String type, final String category, final Priority priority, final String packageName) {
- checkWarning(annotation, lineNumber, message, fileName, type, category, priority);
- assertEquals(packageName, annotation.getPackageName(), "Wrong packageName detected.");
+ assertSoftly(softly -> softly.assertThat(annotation)
+ .hasPriority(Priority.NORMAL)
+ .hasCategory("28101")
+ .hasLineStart(1)
+ .hasLineEnd(1)
+ .hasMessage("failtest not in autoload module layout")
+ .hasFileName("failtest.pp")
+ .hasType(TYPE)
+ .hasPackageName(packageName)
+ );
}
// CHECKSTYLE:ON
