mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-01 00:19:44 +02:00
fix unit tests
This commit is contained in:
@@ -32,6 +32,7 @@ import org.apache.shiro.authc.AuthenticationInfo;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.AlreadyExistsException;
|
||||
@@ -48,6 +49,7 @@ import java.io.IOException;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
@@ -149,10 +151,15 @@ public class SyncingRealmHelperTest {
|
||||
*/
|
||||
@Test
|
||||
public void testStoreUserCreate() {
|
||||
ArgumentCaptor<User> userArgumentCaptor = ArgumentCaptor.forClass(User.class);
|
||||
User user = new User("tricia");
|
||||
|
||||
helper.store(user);
|
||||
verify(userManager, times(1)).create(user);
|
||||
verify(userManager, times(1)).create(userArgumentCaptor.capture());
|
||||
|
||||
User value = userArgumentCaptor.getValue();
|
||||
assertEquals(user.getDisplayName(), value.getDisplayName());
|
||||
assertEquals(user.getName(), value.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,9 +167,10 @@ public class SyncingRealmHelperTest {
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testStoreUserFailure() {
|
||||
ArgumentCaptor<User> userArgumentCaptor = ArgumentCaptor.forClass(User.class);
|
||||
User user = new User("tricia");
|
||||
|
||||
doThrow(AlreadyExistsException.class).when(userManager).create(user);
|
||||
doThrow(AlreadyExistsException.class).when(userManager).create(userArgumentCaptor.capture());
|
||||
helper.store(user);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user