1
2
3
4
5 package com.qulice.checkstyle;
6
7 import com.qulice.spi.Environment;
8 import com.qulice.spi.Violation;
9 import java.io.File;
10 import java.io.IOException;
11 import java.util.Collection;
12 import org.cactoos.io.ResourceOf;
13 import org.cactoos.text.FormattedText;
14 import org.cactoos.text.IoCheckedText;
15 import org.cactoos.text.TextOf;
16 import org.hamcrest.MatcherAssert;
17 import org.hamcrest.Matchers;
18 import org.junit.jupiter.api.Assertions;
19 import org.junit.jupiter.api.Test;
20
21
22
23
24
25
26 final class MultilineJavadocTagsCheckTest {
27
28 @Test
29 void rejectsInvalidMethodDocWithoutInternalException() throws Exception {
30 Assertions.assertDoesNotThrow(
31 () -> this.runValidation("InvalidMethodDoc.java", false)
32 );
33 }
34
35 private Collection<Violation> runValidation(final String file,
36 final boolean passes) throws IOException {
37 final Environment.Mock mock = new Environment.Mock();
38 final Environment env = mock.withParam(
39 "license",
40 String.format(
41 "file:%s",
42 new License().savePackageInfo(
43 new File(mock.basedir(), "src/main/java/foo")
44 ).withLines("Hello.")
45 .withEol(String.valueOf('\n')).file()
46 )
47 ).withFile(
48 String.format("src/main/java/foo/%s", file),
49 new IoCheckedText(
50 new TextOf(
51 new ResourceOf(
52 new FormattedText("com/qulice/checkstyle/%s", file)
53 )
54 )
55 ).asString()
56 );
57 final Collection<Violation> results =
58 new CheckstyleValidator(env).validate(env.files(file));
59 MatcherAssert.assertThat(
60 "validation result should match expected state",
61 results.isEmpty(),
62 Matchers.is(passes)
63 );
64 return results;
65 }
66 }