updated mockito, fixed some unit tests
parent
d330bd1c9b
commit
ce1f3f2f94
|
@ -65,12 +65,15 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
|
||||||
@Mock
|
@Mock
|
||||||
private BlacklistedSiteService blacklistedSiteService;
|
private BlacklistedSiteService blacklistedSiteService;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private SystemScopeService scopeService;
|
||||||
|
|
||||||
@InjectMocks
|
@InjectMocks
|
||||||
private DefaultOAuth2ClientDetailsEntityService service;
|
private DefaultOAuth2ClientDetailsEntityService service;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void prepare() {
|
public void prepare() {
|
||||||
Mockito.reset(clientRepository, tokenRepository, approvedSiteService, whitelistedSiteService, blacklistedSiteService);
|
Mockito.reset(clientRepository, tokenRepository, approvedSiteService, whitelistedSiteService, blacklistedSiteService, scopeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,11 +38,14 @@ import org.mitre.oauth2.repository.AuthenticationHolderRepository;
|
||||||
import org.mitre.oauth2.repository.OAuth2TokenRepository;
|
import org.mitre.oauth2.repository.OAuth2TokenRepository;
|
||||||
import org.mitre.oauth2.service.ClientDetailsEntityService;
|
import org.mitre.oauth2.service.ClientDetailsEntityService;
|
||||||
import org.mitre.oauth2.service.SystemScopeService;
|
import org.mitre.oauth2.service.SystemScopeService;
|
||||||
|
import org.mockito.AdditionalAnswers;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
import org.mockito.Matchers;
|
import org.mockito.Matchers;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
import org.mockito.stubbing.Answer;
|
||||||
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
|
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
|
||||||
import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
|
import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
|
||||||
import org.springframework.security.oauth2.common.exceptions.InvalidScopeException;
|
import org.springframework.security.oauth2.common.exceptions.InvalidScopeException;
|
||||||
|
@ -91,6 +94,9 @@ public class TestDefaultOAuth2ProviderTokenService {
|
||||||
@Mock
|
@Mock
|
||||||
private TokenEnhancer tokenEnhancer;
|
private TokenEnhancer tokenEnhancer;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private SystemScopeService scopeService;
|
||||||
|
|
||||||
@InjectMocks
|
@InjectMocks
|
||||||
private DefaultOAuth2ProviderTokenService service;
|
private DefaultOAuth2ProviderTokenService service;
|
||||||
|
|
||||||
|
@ -131,6 +137,8 @@ public class TestDefaultOAuth2ProviderTokenService {
|
||||||
Mockito.when(storedAuthentication.getOAuth2Request()).thenReturn(storedAuthRequest);
|
Mockito.when(storedAuthentication.getOAuth2Request()).thenReturn(storedAuthRequest);
|
||||||
|
|
||||||
Mockito.when(authenticationHolderRepository.save(Matchers.any(AuthenticationHolderEntity.class))).thenReturn(storedAuthHolder);
|
Mockito.when(authenticationHolderRepository.save(Matchers.any(AuthenticationHolderEntity.class))).thenReturn(storedAuthHolder);
|
||||||
|
|
||||||
|
Mockito.when(scopeService.removeRestrictedScopes(Matchers.anySet())).then(AdditionalAnswers.returnsFirstArg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -245,7 +245,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-all</artifactId>
|
<artifactId>mockito-all</artifactId>
|
||||||
<version>1.9.0</version>
|
<version>1.9.5</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- /Test -->
|
<!-- /Test -->
|
||||||
|
|
Loading…
Reference in New Issue