mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Fixed unit test
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package sonia.scm.api.v2.resources;
|
package sonia.scm.api.v2.resources;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import de.otto.edison.hal.Links;
|
import de.otto.edison.hal.Links;
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
@@ -21,6 +22,11 @@ public abstract class UserToUserDtoMapper extends BaseMapper<User, UserDto> {
|
|||||||
@Inject
|
@Inject
|
||||||
private ResourceLinks resourceLinks;
|
private ResourceLinks resourceLinks;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void setResourceLinks(ResourceLinks resourceLinks) {
|
||||||
|
this.resourceLinks = resourceLinks;
|
||||||
|
}
|
||||||
|
|
||||||
@AfterMapping
|
@AfterMapping
|
||||||
void removePassword(@MappingTarget UserDto target) {
|
void removePassword(@MappingTarget UserDto target) {
|
||||||
target.setPassword(UserResource.DUMMY_PASSWORT);
|
target.setPassword(UserResource.DUMMY_PASSWORT);
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ import static org.mockito.Mockito.*;
|
|||||||
import static org.mockito.MockitoAnnotations.initMocks;
|
import static org.mockito.MockitoAnnotations.initMocks;
|
||||||
|
|
||||||
@SubjectAware(
|
@SubjectAware(
|
||||||
// username = "trillian",
|
|
||||||
// password = "secret",
|
|
||||||
configuration = "classpath:sonia/scm/repository/shiro.ini"
|
configuration = "classpath:sonia/scm/repository/shiro.ini"
|
||||||
)
|
)
|
||||||
public class MeResourceTest {
|
public class MeResourceTest {
|
||||||
@@ -50,6 +48,8 @@ public class MeResourceTest {
|
|||||||
|
|
||||||
private Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
private Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
||||||
|
|
||||||
|
|
||||||
|
private final ResourceLinks resourceLinks = ResourceLinksMock.createMock(URI.create("/"));
|
||||||
@Mock
|
@Mock
|
||||||
private UriInfo uriInfo;
|
private UriInfo uriInfo;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -67,9 +67,10 @@ public class MeResourceTest {
|
|||||||
public void prepareEnvironment() throws IOException, UserException {
|
public void prepareEnvironment() throws IOException, UserException {
|
||||||
initMocks(this);
|
initMocks(this);
|
||||||
createDummyUser("trillian");
|
createDummyUser("trillian");
|
||||||
doNothing().when(userManager).create(userCaptor.capture());
|
when(userManager.create(userCaptor.capture())).thenAnswer(invocation -> invocation.getArguments()[0]);
|
||||||
doNothing().when(userManager).modify(userCaptor.capture());
|
doNothing().when(userManager).modify(userCaptor.capture());
|
||||||
doNothing().when(userManager).delete(userCaptor.capture());
|
doNothing().when(userManager).delete(userCaptor.capture());
|
||||||
|
userToDtoMapper.setResourceLinks(resourceLinks);
|
||||||
MeResource meResource = new MeResource(userToDtoMapper, userManager);
|
MeResource meResource = new MeResource(userToDtoMapper, userManager);
|
||||||
dispatcher.getRegistry().addSingletonResource(meResource);
|
dispatcher.getRegistry().addSingletonResource(meResource);
|
||||||
when(uriInfo.getBaseUri()).thenReturn(URI.create("/"));
|
when(uriInfo.getBaseUri()).thenReturn(URI.create("/"));
|
||||||
|
|||||||
Reference in New Issue
Block a user