/**
 *
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 *
 */

package com.microsoft.azure.credentials;

public class UserTokenCredentialsTests {

}

@@ -211,48 +211,2294 @@
 s;%0A%0A
-public class UserTokenCredentialsTests %7B%0A
+import com.microsoft.aad.adal4j.AuthenticationResult;%0A%0Aimport org.junit.Assert;%0A%0Aimport org.junit.Test;%0A%0Aimport java.io.IOException;%0Aimport java.util.Date;%0A%0Apublic class UserTokenCredentialsTests %7B%0A    MockUserTokenCredentials credentials = new MockUserTokenCredentials(%0A            %22clientId%22,%0A            %22domain%22,%0A            %22username%22,%0A            %22password%22,%0A            %22redirect%22,%0A            AzureEnvironment.AZURE%0A    );%0A%0A    @Test%0A    public void testAcquireToken() throws Exception %7B%0A        credentials.refreshToken();%0A        Assert.assertEquals(%22token1%22, credentials.getToken());%0A        Thread.sleep(1000);%0A        Assert.assertEquals(%22token2%22, credentials.getToken());%0A    %7D%0A%0A    public class MockUserTokenCredentials extends UserTokenCredentials %7B%0A        private AuthenticationResult authenticationResult;%0A%0A        public MockUserTokenCredentials(String clientId, String domain, String username, String password, String clientRedirectUri, AzureEnvironment environment) %7B%0A            super(clientId, domain, username, password, clientRedirectUri, environment);%0A        %7D%0A%0A        @Override%0A        public String getToken() throws IOException %7B%0A            if (authenticationResult != null &&%0A                    authenticationResult.getExpiresOnDate().before(new Date())) %7B%0A                acquireAccessTokenFromRefreshToken();%0A            %7D else %7B%0A                acquireAccessToken();%0A            %7D%0A            return authenticationResult.getAccessToken();%0A        %7D%0A%0A        @Override%0A        public void refreshToken() throws IOException %7B%0A            acquireAccessToken();%0A        %7D%0A%0A        private void acquireAccessToken() throws IOException %7B%0A            this.authenticationResult = new AuthenticationResult(%0A                    null,%0A                    %22token1%22,%0A                    %22refresh%22,%0A                    0,%0A                    null,%0A                    null,%0A                    false);%0A        %7D%0A%0A        private void acquireAccessTokenFromRefreshToken() throws IOException %7B%0A            this.authenticationResult = new AuthenticationResult(%0A                    null,%0A                    %22token2%22,%0A                    %22refresh%22,%0A                    0,%0A                    null,%0A                    null,%0A                    false);%0A        %7D%0A    %7D
 %0A%7D%0A

Add a test for user credentials