Update TestDefaultIntrospectionResultAssembler.java
Hi Justin, I am trying to throw a ParseException where the actual value and expected value are not equal for the expiration parameters. I am trying to test the catch block. I have used the same parameters which are already used in other test cases in the same file. Can you please guide me on how to approach catch case in this particular scenario, I have already tried but I am not sure this is the right way. Thank youpull/1367/head
parent
9f9e778d93
commit
c7cacbbe65
|
@ -304,16 +304,32 @@ public class TestDefaultIntrospectionResultAssembler {
|
||||||
assertThat(result, is(equalTo(expected)));
|
assertThat(result, is(equalTo(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ParseException.class)
|
@Test(expected=ParseException.class)
|
||||||
public void testAssembleFrom_refresh() {
|
public void testAssembleFrom_OAuth2AccessTokenEntityExpiration() {
|
||||||
|
|
||||||
|
// given
|
||||||
|
OAuth2AccessTokenEntity accessToken = accessToken(null, scopes("foo", "bar"), null, "Bearer",
|
||||||
|
oauth2AuthenticationWithUser(oauth2Request("clientId"), "name"));
|
||||||
|
|
||||||
OAuth2RefreshTokenEntity refreshToken = refreshToken(null,
|
UserInfo userInfo = userInfo("sub");
|
||||||
oauth2AuthenticationWithUser(oauth2Request("clientId", scopes("foo", "bar")), "name"));
|
|
||||||
|
|
||||||
Set<String> authScopes = scopes("foo", "bar", "baz");
|
Set<String> authScopes = scopes("foo", "bar", "baz");
|
||||||
// this should fail with an error
|
|
||||||
assembler.assembleFrom(refreshToken, null , authScopes);
|
|
||||||
|
|
||||||
|
// when
|
||||||
|
Map<String, Object> result = assembler.assembleFrom(accessToken, userInfo, authScopes);
|
||||||
|
|
||||||
|
|
||||||
|
// then
|
||||||
|
Map<String, Object> expected = new ImmutableMap.Builder<String, Object>()
|
||||||
|
.put("sub", "sub")
|
||||||
|
.put("scope", "bar foo")
|
||||||
|
.put("active", Boolean.TRUE)
|
||||||
|
.put("user_id", "name")
|
||||||
|
.put("client_id", "clientId")
|
||||||
|
.put("token_type", "Bearer")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertThat(result, is(not(equalTo(expected))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserInfo userInfo(String sub) {
|
private UserInfo userInfo(String sub) {
|
||||||
|
|
Loading…
Reference in New Issue