Browse Source

Merge pull request #1 from herrphon/develop

Fix Tests in patch-1
pull/46/head
Alexander von Renteln 7 years ago committed by GitHub
parent
commit
e33b8aa631
  1. 22
      pom.xml
  2. 12
      src/test/java/com/englishtown/bitbucket/hook/MirrorRepositoryHookTest.java
  3. 4
      src/test/java/com/englishtown/bitbucket/hook/PasswordHandlerTest.java

22
pom.xml

@ -28,11 +28,13 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<bitbucket.version>4.0.1</bitbucket.version>
<bitbucket.data.version>${bitbucket.version}</bitbucket.data.version>
<atlassian-sal-api.version>3.0.5</atlassian-sal-api.version>
<amps.version>6.1.0</amps.version>
<amps.version>6.3.0</amps.version>
</properties>
<dependencyManagement>
@ -101,14 +103,6 @@
</products>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
@ -135,14 +129,14 @@
</pluginRepositories>
<scm>
<connection>scm:git:ssh://git@github.com:englishtown/stash-hook-mirror.git</connection>
<developerConnection>scm:git:ssh://git@github.com:englishtown/stash-hook-mirror.git</developerConnection>
<url>scm:git:https://github.com/englishtown/stash-hook-mirror</url>
<connection>scm:git:ssh://git@github.com:ef-labs/stash-hook-mirror.git</connection>
<developerConnection>scm:git:ssh://git@github.com:ef-labs/stash-hook-mirror.git</developerConnection>
<url>scm:git:https://github.com/ef-labs/stash-hook-mirror</url>
</scm>
<issueManagement>
<system>Github Issues</system>
<url>https://github.com/englishtown/stash-hook-mirror/issues</url>
<url>https://github.com/ef-labs/stash-hook-mirror/issues</url>
</issueManagement>
</project>

12
src/test/java/com/englishtown/bitbucket/hook/MirrorRepositoryHookTest.java

@ -91,7 +91,6 @@ public class MirrorRepositoryHookTest {
when(passwordEncryptor.decrypt(anyString())).thenReturn(password);
Repository repo = mock(Repository.class);
when(repo.getName()).thenReturn("test");
hook.postReceive(buildContext(repo), new ArrayList<>());
verifyExecutor();
@ -123,19 +122,19 @@ public class MirrorRepositoryHookTest {
Runnable runnable = argumentCaptor.getValue();
runnable.run();
verify(executor, times(1)).schedule(argumentCaptor.capture(), anyInt(), any(TimeUnit.class));
verify(executor, times(1)).schedule(argumentCaptor.capture(), anyLong(), any(TimeUnit.class));
runnable = argumentCaptor.getValue();
runnable.run();
verify(executor, times(2)).schedule(argumentCaptor.capture(), anyInt(), any(TimeUnit.class));
verify(executor, times(2)).schedule(argumentCaptor.capture(), anyLong(), any(TimeUnit.class));
runnable = argumentCaptor.getValue();
runnable.run();
verify(executor, times(3)).schedule(argumentCaptor.capture(), anyInt(), any(TimeUnit.class));
verify(executor, times(3)).schedule(argumentCaptor.capture(), anyLong(), any(TimeUnit.class));
runnable = argumentCaptor.getValue();
runnable.run();
verify(executor, times(4)).schedule(argumentCaptor.capture(), anyInt(), any(TimeUnit.class));
verify(executor, times(4)).schedule(argumentCaptor.capture(), anyLong(), any(TimeUnit.class));
runnable = argumentCaptor.getValue();
runnable.run();
@ -143,7 +142,7 @@ public class MirrorRepositoryHookTest {
runnable.run();
runnable.run();
runnable.run();
verify(executor, times(4)).schedule(argumentCaptor.capture(), anyInt(), any(TimeUnit.class));
verify(executor, times(4)).schedule(argumentCaptor.capture(), anyLong(), any(TimeUnit.class));
}
@ -249,7 +248,6 @@ public class MirrorRepositoryHookTest {
verify(errors, never()).addFormError(anyString());
verify(errors, never()).addFieldError(anyString(), anyString());
when(passwordEncryptor.isEncrypted(anyString())).thenReturn(true);
errors = mock(SettingsValidationErrors.class);
hook.validate(settings, errors, repo);
verify(errors, never()).addFormError(anyString());

4
src/test/java/com/englishtown/bitbucket/hook/PasswordHandlerTest.java

@ -44,7 +44,7 @@ public class PasswordHandlerTest {
@Test
public void testOnCancel() throws Exception {
handler.onCancel(secretText, 0, secretText, null);
handler.onCancel(secretText, 0, secretText, new RuntimeException());
verify(exitHandler).onCancel(eq(cleanedText), eq(0), eq(cleanedText), any(Throwable.class));
}
@ -52,7 +52,7 @@ public class PasswordHandlerTest {
@Test
public void testOnExit() throws Exception {
handler.onExit(secretText, 0, secretText, null);
handler.onExit(secretText, 0, secretText, new RuntimeException());
verify(exitHandler).onExit(eq(cleanedText), eq(0), eq(cleanedText), any(Throwable.class));
}

Loading…
Cancel
Save