// Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java
// public class UserResource {
// 
//     private UserService userService;
// 
//     public Optional<User> user(String user) {
//         try {
//             return Optional.ofNullable(userService.user(user));
//         } catch (Exception ex) {
//             return Optional.empty();
//         }
//     }
// 
//     public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{
//         try {
//             return Optional.ofNullable(userService.authenticatedUser(accessToken));
//         } catch (Exception ex) {
//             throw new UnAuthorizedException();
//         }
//     }
// 
// 
//     public UserResource url(RestAdapter restAdapter) {
//         this.userService = restAdapter.create(UserService.class);
//         return this;
//     }
// }
// 
// Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java
// public class UnAuthorizedException extends TwitchException {
// }
// 
// Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java
// public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) {
//     try {
//         exceptionThrower.throwException();
//     } catch (Throwable caught) {
//         return new ThrowableAssertion(caught);
//     }
//     throw new ExceptionNotThrownAssertionError();
// }


import com.deswaef.twitch.api.user.UserResource;
import com.deswaef.twitch.exception.UnAuthorizedException;
import org.junit.Before;
import org.junit.Test;
import retrofit.RestAdapter;
import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown;
package com.deswaef.twitch.api.oauth;




public class AuthorizingUserConnectorTest {

    private UserResource connector;

    private RestAdapter restAdapter;

    @Before
    public void init() {
        restAdapter = new RestAdapter.Builder()
                .setEndpoint("https://api.twitch.tv/kraken")
                .build();
        connector = new UserResource().url(restAdapter);
    }

    @Test
    public void testAndFaultyAccessToken() {
        assertThrown(
                () -> connector.getAuthenticatedUser("token")
// Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java
// public class UserResource {
// 
//     private UserService userService;
// 
//     public Optional<User> user(String user) {
//         try {
//             return Optional.ofNullable(userService.user(user));
//         } catch (Exception ex) {
//             return Optional.empty();
//         }
//     }
// 
//     public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{
//         try {
//             return Optional.ofNullable(userService.authenticatedUser(accessToken));
//         } catch (Exception ex) {
//             throw new UnAuthorizedException();
//         }
//     }
// 
// 
//     public UserResource url(RestAdapter restAdapter) {
//         this.userService = restAdapter.create(UserService.class);
//         return this;
//     }
// }
// 
// Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java
// public class UnAuthorizedException extends TwitchException {
// }
// 
// Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java
// public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) {
//     try {
//         exceptionThrower.throwException();
//     } catch (Throwable caught) {
//         return new ThrowableAssertion(caught);
//     }
//     throw new ExceptionNotThrownAssertionError();
// }


// Path: src/test/java/com/deswaef/twitch/api/oauth/AuthorizingUserConnectorTest.java
import com.deswaef.twitch.api.user.UserResource;
import com.deswaef.twitch.exception.UnAuthorizedException;
import org.junit.Before;
import org.junit.Test;
import retrofit.RestAdapter;
import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown;

package com.deswaef.twitch.api.oauth;




public class AuthorizingUserConnectorTest {

    private UserResource connector;

    private RestAdapter restAdapter;

    @Before
    public void init() {
        restAdapter = new RestAdapter.Builder()
                .setEndpoint("https://api.twitch.tv/kraken")
                .build();
        connector = new UserResource().url(restAdapter);
    }

    @Test
    public void testAndFaultyAccessToken() {
        assertThrown(
                () -> connector.getAuthenticatedUser("token")
        ).isInstanceOf(UnAuthorizedException.class);