package io.jenkins.plugins.analysis.core.model;

import java.io.File;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.function.Function;

import org.junit.jupiter.api.Test;

import edu.hm.hafner.analysis.AbstractParser;
import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.IssueParser;
import edu.hm.hafner.analysis.Issues;
import edu.hm.hafner.analysis.Priority;
import static io.jenkins.plugins.analysis.core.testutil.Assertions.assertThat;
import static org.mockito.Mockito.*;

public class StaticAnalysisToolSuiteTest {

    private Issue issue = new IssueBuilder().setMessage("test")
            .setFileName("filename")
            .setPriority(Priority.HIGH)
            .build();
    private File file = mock(File.class);
    private Function<String, String> func = mock(Function.class);
    private Charset charset = mock(Charset.class);
    private AbstractParser<Issue> parser = mock(AbstractParser.class);

    private StaticAnalysisToolSuite suite = new StaticAnalysisToolSuite() {
        @Override
        protected Collection<? extends AbstractParser<Issue>> getParsers() {
            Issues<Issue> list = new Issues<>();
            list.add(issue);
            when(parser.parse(file, charset, func)).thenReturn(list);
            return asList(parser);
        }
    };

    //parse
    @Test
    void shouldBeOkIfCreateDoesNotReturnNull() {
        IssueParser<Issue> parser = suite.createParser();
        assertThat(parser).isNotNull();
    }

    @Test
    void shouldBeOkIfAsListDoesNotReturnNull() {
        Collection<? extends AbstractParser<Issue>> result = suite.asList();
        assertThat(result).isNotNull();
    }

    @Test
    void shouldBeOkIfParseIsCalledExactlyOnce() {
        suite.createParser().parse(file, charset, func);
        verify(parser, times(1)).parse(file, charset, func);
    }

}
@@ -125,16 +125,39 @@
 ection;%0A
+import java.util.List;%0A
 import j
@@ -352,51 +352,8 @@
 er;%0A
-import edu.hm.hafner.analysis.IssueParser;%0A
 impo
@@ -547,15 +547,95 @@
 *;%0A%0A
-public 
+/**%0A * Tests the class %7B@link StaticAnalysisToolSuite%7D.%0A *%0A * @author Arne Schntag%0A */%0A
 clas
@@ -1445,16 +1445,17 @@
 //parse%0A
+%0A
     @Tes
@@ -1481,412 +1481,1649 @@
 OkIf
-CreateDoesNotReturnNull() %7B%0A        IssueParser%3CIssue%3E parser = suite.createParser();%0A        assertThat(parser).isNotNull();%0A    %7D%0A%0A    @Test%0A    void shouldBeOkIfAsListDoesNotReturnNull() %7B%0A        Collection%3C? extends AbstractParser%3CIssue%3E%3E result = suite.asList();%0A        assertThat(result).isNotNull();%0A    %7D%0A%0A    @Test%0A    void shouldBeOkIfParseIsCalledExactlyOnce() %7B%0A        suite.createP
+AsListDoesContainParser() %7B%0A        List%3CAbstractParser%3CIssue%3E%3E result = (List%3CAbstractParser%3CIssue%3E%3E) suite.asList(parser);%0A        assertThat(result).contains(this.parser);%0A    %7D%0A%0A    @Test%0A    void shouldBeOkIfParseIsPerformedCorrectlyWithOneParser() %7B%0A        Issues%3CIssue%3E issues = suite.createParser().parse(file, charset, func);%0A        verify(parser, times(1)).parse(file, charset, func);%0A        assertThat(issues.get(0)).isEqualTo(issue);%0A    %7D%0A%0A    @Test%0A    void shouldBeOkIfParseIsPerformedCorrectlyWithMoreParsers() %7B%0A        AbstractParser%3CIssue%3E parser2 = mock(AbstractParser.class);%0A        Issue issue2 = new IssueBuilder().setMessage(%22second%22)%0A                .setFileName(%22filename2%22)%0A                .setPriority(Priority.LOW)%0A                .build();%0A%0A        AbstractParser%3CIssue%3E parser3 = mock(AbstractParser.class);%0A        Issue issue3 = new IssueBuilder().setMessage(%22third%22)%0A                .setFileName(%22filename3%22)%0A                .setPriority(Priority.NORMAL)%0A                .build();%0A%0A        StaticAnalysisToolSuite toolSuite = new StaticAnalysisToolSuite() %7B%0A            @Override%0A            protected Collection%3C? extends AbstractParser%3CIssue%3E%3E getParsers() %7B%0A                Issues%3CIssue%3E list = new Issues%3C%3E();%0A                list.add(issue);%0A                when(parser.parse(file, charset, func)).thenReturn(list);%0A%0A                Issues%3CIssue%3E list2 = new Issues%3C%3E();%0A                list.add(issue2);%0A                when(parser2.parse(file, charset, func)).thenReturn(list2);%0A%0A                Issues%3CIssue%3E list3 = new Issues%3C%3E();%0A                list.add(issue3);%0A                when(p
 arser
-()
+3
 .par
@@ -3149,68 +3149,231 @@
 unc)
-;%0A        verify(parser, times(1)).parse(file, charset, func
+).thenReturn(list3);%0A                return asList(parser, parser2, parser3);%0A            %7D%0A        %7D;%0A        Issues%3CIssue%3E issues = toolSuite.createParser().parse(file, charset, func);%0A        assertThat(issues).hasSize(3
 );%0A 

update test class