package com.uwetrottmann.getglue;

import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;

import static org.fest.assertions.api.Assertions.assertThat;

public class GetGlueTest extends BaseTestCase {

    public void test_getAuthorizationRequest() throws OAuthSystemException {
        OAuthClientRequest request = GetGlue.getAuthorizationRequest(CLIENT_ID, REDIRECT_URI);
        System.out.println("GetGlue Authorization URL: " + request.getLocationUri());
        assertThat(request.getLocationUri())
                .isEqualTo("https://api.getglue.com/oauth2/authorize"
                        + "?response_type=code&scope=public+read+write"
                        + "&redirect_uri=http%3A%2F%2Flocalhost"
                        + "&client_id=" + CLIENT_ID);
    }

    public void test_getAccessTokenRequest() throws OAuthSystemException {
        String code = "S0meRand0mS1uff";
        OAuthClientRequest request = GetGlue
                .getAccessTokenRequest(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, code);
        System.out.println("GetGlue Access Token URL: " + request.getLocationUri());
        assertThat(request.getLocationUri())
                .isEqualTo("https://api.getglue.com/oauth2/access_token"
                        + "?client_secret=" + CLIENT_SECRET
                        + "&grant_type=authorization_code"
                        + "&redirect_uri=http%3A%2F%2Flocalhost"
                        + "&code=" + code
                        + "&client_id=" + CLIENT_ID);
    }

}

@@ -679,27 +679,8 @@
 + %22?
-response_type=code&
 scop
@@ -700,16 +700,64 @@
 +write%22%0A
+                        + %22&response_type=code%22%0A
         
@@ -1357,38 +1357,20 @@
  %22?c
-lient_secret=%22 + CLIENT_SECRET
+ode=%22 + code
 %0A   
@@ -1421,24 +1421,84 @@
 ation_code%22%0A
+                        + %22&client_secret=%22 + CLIENT_SECRET%0A
             
@@ -1554,50 +1554,8 @@
 st%22%0A
-                        + %22&code=%22 + code%0A
     

Fix tests (url param order switched, whyever).