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 you
pull/1367/head
Aishwarya Gosavi 2018-04-22 18:42:42 -04:00 committed by GitHub
parent 9f9e778d93
commit c7cacbbe65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 6 deletions

View File

@ -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) {