// Path: src/main/java/org/dmfs/oauth2/client/OAuth2AuthCodeAuthorization.java
// public interface OAuth2AuthCodeAuthorization
// {
//     /**
//      * Returns the actual authorization code.
//      *
//      * @return
//      */
//     public CharSequence code();
// 
//     /**
//      * Returns the scope that this authorization has been granted for.
//      *
//      * @return
//      */
//     public OAuth2Scope scope();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2Scope.java
// public interface OAuth2Scope
// {
//     /**
//      * Returns whether this scope is empty.
//      *
//      * @return <code>true</code> if this scope is empty, <code>false</code> otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this scope contains the given scope token or not.
//      *
//      * @param token
//      *         The scope token to check for.
//      *
//      * @return <code>true</code> if the scope token is contained in this scope, <code>false</code> otherwise.
//      */
//     boolean hasToken(String token);
// 
//     /**
//      * Returns the number of tokens in this {@link OAuth2Scope}.
//      *
//      * @return The number of tokens in this {@link OAuth2Scope}.
//      */
//     int tokenCount();
// 
//     /**
//      * Returns a string version of this scope as described in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC 6749, section 3.3</a>, i.e. a list
//      * of scope tokens separated by spaces.
//      *
//      * @return A String containing a list scope tokens, separated by spaces, or an empty String if {@link #isEmpty()} returns <code>true</code>.
//      */
//     String toString();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/scope/BasicScope.java
// public final class BasicScope implements OAuth2Scope
// {
//     private final String[] mTokens;
// 
// 
//     /**
//      * Creates a new {@link OAuth2Scope} that contains the given tokens.
//      *
//      * @param tokens
//      *         The scope tokens in this scope. Must not contain <code>null</code> or empty {@link String}s.
//      */
//     public BasicScope(String... tokens)
//     {
//         mTokens = tokens.clone();
//     }
// 
// 
//     @Override
//     public boolean isEmpty()
//     {
//         return mTokens.length == 0;
//     }
// 
// 
//     @Override
//     public boolean hasToken(String token)
//     {
//         for (String scopeToken : mTokens)
//         {
//             if (scopeToken.equals(token))
//             {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
// 
//     @Override
//     public int tokenCount()
//     {
//         return mTokens.length;
//     }
// 
// 
//     @Override
//     public String toString()
//     {
//         StringBuilder result = new StringBuilder(mTokens.length * 30);
//         boolean first = true;
// 
//         for (String token : mTokens)
//         {
//             if (first)
//             {
//                 first = false;
//             }
//             else
//             {
//                 result.append(' ');
//             }
//             result.append(token);
//         }
//         return result.toString();
//     }
// 
// 
//     @Override
//     public boolean equals(Object obj)
//     {
//         if (!(obj instanceof OAuth2Scope))
//         {
//             return false;
//         }
// 
//         OAuth2Scope other = (OAuth2Scope) obj;
//         if (isEmpty() && other.isEmpty())
//         {
//             return true;
//         }
// 
//         if (tokenCount() != other.tokenCount())
//         {
//             return false;
//         }
// 
//         for (String token : mTokens)
//         {
//             if (!other.hasToken(token))
//             {
//                 return false;
//             }
//         }
//         return true;
//     }
// }


import org.dmfs.httpessentials.HttpMethod;
import org.dmfs.httpessentials.client.HttpRequestEntity;
import org.dmfs.httpessentials.types.MediaType;
import org.dmfs.httpessentials.types.StringMediaType;
import org.dmfs.jems.hamcrest.matchers.optional.PresentMatcher;
import org.dmfs.oauth2.client.OAuth2AuthCodeAuthorization;
import org.dmfs.oauth2.client.OAuth2Scope;
import org.dmfs.oauth2.client.scope.BasicScope;
import org.dmfs.rfc3986.encoding.Precoded;
import org.dmfs.rfc3986.parameters.ParameterList;
import org.dmfs.rfc3986.parameters.adapters.TextParameter;
import org.dmfs.rfc3986.parameters.adapters.XwfueParameterList;
import org.dmfs.rfc3986.parameters.parametertypes.BasicParameterType;
import org.dmfs.rfc3986.parameters.valuetypes.TextValueType;
import org.dmfs.rfc3986.uris.LazyUri;
import org.junit.Ignore;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
/*
 * Copyright 2017 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.oauth2.client.http.requests;





/**
 * @author Marten Gajda
 */
public class AuthorizationCodeTokenRequestTest
{
    @Test
    public void testRequestEntity() throws Exception
    {
        OAuth2AuthCodeAuthorization authorization = new OAuth2AuthCodeAuthorization()
        {
            @Override
            public CharSequence code()
            {
                return "authcode";
            }


            @Override
            public OAuth2Scope scope()
            {
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2AuthCodeAuthorization.java
// public interface OAuth2AuthCodeAuthorization
// {
//     /**
//      * Returns the actual authorization code.
//      *
//      * @return
//      */
//     public CharSequence code();
// 
//     /**
//      * Returns the scope that this authorization has been granted for.
//      *
//      * @return
//      */
//     public OAuth2Scope scope();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2Scope.java
// public interface OAuth2Scope
// {
//     /**
//      * Returns whether this scope is empty.
//      *
//      * @return <code>true</code> if this scope is empty, <code>false</code> otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this scope contains the given scope token or not.
//      *
//      * @param token
//      *         The scope token to check for.
//      *
//      * @return <code>true</code> if the scope token is contained in this scope, <code>false</code> otherwise.
//      */
//     boolean hasToken(String token);
// 
//     /**
//      * Returns the number of tokens in this {@link OAuth2Scope}.
//      *
//      * @return The number of tokens in this {@link OAuth2Scope}.
//      */
//     int tokenCount();
// 
//     /**
//      * Returns a string version of this scope as described in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC 6749, section 3.3</a>, i.e. a list
//      * of scope tokens separated by spaces.
//      *
//      * @return A String containing a list scope tokens, separated by spaces, or an empty String if {@link #isEmpty()} returns <code>true</code>.
//      */
//     String toString();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/scope/BasicScope.java
// public final class BasicScope implements OAuth2Scope
// {
//     private final String[] mTokens;
// 
// 
//     /**
//      * Creates a new {@link OAuth2Scope} that contains the given tokens.
//      *
//      * @param tokens
//      *         The scope tokens in this scope. Must not contain <code>null</code> or empty {@link String}s.
//      */
//     public BasicScope(String... tokens)
//     {
//         mTokens = tokens.clone();
//     }
// 
// 
//     @Override
//     public boolean isEmpty()
//     {
//         return mTokens.length == 0;
//     }
// 
// 
//     @Override
//     public boolean hasToken(String token)
//     {
//         for (String scopeToken : mTokens)
//         {
//             if (scopeToken.equals(token))
//             {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
// 
//     @Override
//     public int tokenCount()
//     {
//         return mTokens.length;
//     }
// 
// 
//     @Override
//     public String toString()
//     {
//         StringBuilder result = new StringBuilder(mTokens.length * 30);
//         boolean first = true;
// 
//         for (String token : mTokens)
//         {
//             if (first)
//             {
//                 first = false;
//             }
//             else
//             {
//                 result.append(' ');
//             }
//             result.append(token);
//         }
//         return result.toString();
//     }
// 
// 
//     @Override
//     public boolean equals(Object obj)
//     {
//         if (!(obj instanceof OAuth2Scope))
//         {
//             return false;
//         }
// 
//         OAuth2Scope other = (OAuth2Scope) obj;
//         if (isEmpty() && other.isEmpty())
//         {
//             return true;
//         }
// 
//         if (tokenCount() != other.tokenCount())
//         {
//             return false;
//         }
// 
//         for (String token : mTokens)
//         {
//             if (!other.hasToken(token))
//             {
//                 return false;
//             }
//         }
//         return true;
//     }
// }


// Path: src/test/java/org/dmfs/oauth2/client/http/requests/AuthorizationCodeTokenRequestTest.java
import org.dmfs.httpessentials.HttpMethod;
import org.dmfs.httpessentials.client.HttpRequestEntity;
import org.dmfs.httpessentials.types.MediaType;
import org.dmfs.httpessentials.types.StringMediaType;
import org.dmfs.jems.hamcrest.matchers.optional.PresentMatcher;
import org.dmfs.oauth2.client.OAuth2AuthCodeAuthorization;
import org.dmfs.oauth2.client.OAuth2Scope;
import org.dmfs.oauth2.client.scope.BasicScope;
import org.dmfs.rfc3986.encoding.Precoded;
import org.dmfs.rfc3986.parameters.ParameterList;
import org.dmfs.rfc3986.parameters.adapters.TextParameter;
import org.dmfs.rfc3986.parameters.adapters.XwfueParameterList;
import org.dmfs.rfc3986.parameters.parametertypes.BasicParameterType;
import org.dmfs.rfc3986.parameters.valuetypes.TextValueType;
import org.dmfs.rfc3986.uris.LazyUri;
import org.junit.Ignore;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

/*
 * Copyright 2017 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.oauth2.client.http.requests;





/**
 * @author Marten Gajda
 */
public class AuthorizationCodeTokenRequestTest
{
    @Test
    public void testRequestEntity() throws Exception
    {
        OAuth2AuthCodeAuthorization authorization = new OAuth2AuthCodeAuthorization()
        {
            @Override
            public CharSequence code()
            {
                return "authcode";
            }


            @Override
            public OAuth2Scope scope()
            {
                return new BasicScope("scope1", "scope2");