Fix unit test

This commit is contained in:
René Pfeuffer
2018-10-26 16:43:52 +02:00
parent a285ddb253
commit 007baecc86
2 changed files with 5 additions and 3 deletions

View File

@@ -7,8 +7,8 @@ public class InvalidPasswordException extends ExceptionWithContext {
private static final String CODE = "8YR7aawFW1"; private static final String CODE = "8YR7aawFW1";
public InvalidPasswordException(ContextEntry.ContextBuilder passwordChange) { public InvalidPasswordException(ContextEntry.ContextBuilder context) {
super(passwordChange.build(), "The given old password does not match with the stored one."); super(context.build(), "The given old password does not match with the stored one.");
} }
@Override @Override

View File

@@ -13,6 +13,7 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import sonia.scm.ContextEntry;
import sonia.scm.user.InvalidPasswordException; import sonia.scm.user.InvalidPasswordException;
import sonia.scm.user.User; import sonia.scm.user.User;
import sonia.scm.user.UserManager; import sonia.scm.user.UserManager;
@@ -168,7 +169,8 @@ public class MeResourceTest {
.content(content.getBytes()); .content(content.getBytes());
MockHttpResponse response = new MockHttpResponse(); MockHttpResponse response = new MockHttpResponse();
doThrow(InvalidPasswordException.class).when(userManager).changePasswordForLoggedInUser(any(), any()); doThrow(new InvalidPasswordException(ContextEntry.ContextBuilder.entity("passwortChange", "-")))
.when(userManager).changePasswordForLoggedInUser(any(), any());
dispatcher.invoke(request, response); dispatcher.invoke(request, response);