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
27 final class CheckstyleOperatorWrapTest {
28
29 @Test
30 void acceptsEqualityOperatorAtStartOfWrappedLine() throws Exception {
31 Assertions.assertDoesNotThrow(
32 () -> this.runValidation("ValidEqualityOperatorWrap.java", true)
33 );
34 }
35
36 private Collection<Violation> runValidation(final String file,
37 final boolean passes) throws IOException {
38 final Environment.Mock mock = new Environment.Mock();
39 final Environment env = mock.withParam(
40 "license",
41 String.format(
42 "file:%s",
43 new License().savePackageInfo(
44 new File(mock.basedir(), "src/main/java/foo")
45 ).withLines("Hello.")
46 .withEol(String.valueOf('\n')).file()
47 )
48 ).withFile(
49 String.format("src/main/java/foo/%s", file),
50 new IoCheckedText(
51 new TextOf(
52 new ResourceOf(
53 new FormattedText("com/qulice/checkstyle/%s", file)
54 )
55 )
56 ).asString()
57 );
58 final Collection<Violation> results =
59 new CheckstyleValidator(env).validate(env.files(file));
60 MatcherAssert.assertThat(
61 "validation result should match expected state",
62 results.isEmpty(),
63 Matchers.is(passes)
64 );
65 return results;
66 }
67 }