PageRenderTime 86ms CodeModel.GetById 81ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/plugin-module-codegen-engine/src/main/resources/templates/stash/ssh/SshScmRequestHandlerTest.java.vtl

https://bitbucket.org/mmeinhold/amps
Unknown | 65 lines | 52 code | 13 blank | 0 comment | 0 complexity | 304fd5cc637d56b34f80511975624ee7 MD5 | raw file
 1package ${PACKAGE};
 2
 3import com.atlassian.stash.scm.ssh.ExitCodeCallback;
 4import com.atlassian.stash.scm.ssh.SshScmRequest;
 5import org.junit.Before;
 6import org.junit.Test;
 7import org.junit.runner.RunWith;
 8import org.mockito.Mock;
 9import org.mockito.runners.MockitoJUnitRunner;
10
11import java.io.InputStream;
12import java.io.OutputStream;
13
14import static junit.framework.Assert.assertNull;
15import static org.hamcrest.MatcherAssert.assertThat;
16import static org.hamcrest.Matchers.instanceOf;
17
18import ${FQ_CLASS_UNDER_TEST};
19import ${FQ_REQUEST_CLASSNAME};
20
21@RunWith(MockitoJUnitRunner.class)
22public class ${CLASSNAME}
23{
24
25    @Mock
26    InputStream in;
27    @Mock
28    OutputStream out;
29    @Mock
30    OutputStream error;
31    @Mock
32    ExitCodeCallback exitCodeCallback;
33
34    ${CLASS_UNDER_TEST} sshRequestHandler;
35
36    @Before
37    public void setUp()
38    {
39        sshRequestHandler = new ${CLASS_UNDER_TEST}();
40    }
41
42    @Test
43    public void echo()
44    {
45        assertCommandMatches("echo");
46        assertCommandMatches("eChO");
47    }
48
49    @Test
50    public void notEcho()
51    {
52        assertNull(createSshRequest("fishsticks"));
53    }
54
55    private void assertCommandMatches(String command)
56    {
57        assertThat(createSshRequest(command), instanceOf(${REQUEST_CLASSNAME}.class));
58    }
59
60    private SshScmRequest createSshRequest(String command)
61    {
62        return sshRequestHandler.create(command, in, out, error, exitCodeCallback);
63    }
64
65}