<commit_before>/*
  Copyright 2012 <NAME>

   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.scribe.up.test.provider.impl;

import java.util.Locale;

import org.scribe.up.profile.Gender;
import org.scribe.up.profile.ProfileHelper;
import org.scribe.up.profile.UserProfile;
import org.scribe.up.profile.windowslive.WindowsLiveProfile;
import org.scribe.up.provider.OAuthProvider;
import org.scribe.up.provider.impl.WindowsLiveProvider;
import org.scribe.up.test.util.CommonHelper;

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;

/**
 * This class tests the {@link org.scribe.up.provider.impl.WindowsLiveProvider} class by simulating a complete authentication.
 * 
 * @author <NAME>
 * @since 1.1.0
 */
public class TestWindowsLiveProvider extends TestProvider {
    
    @Override
    protected boolean isJavascriptEnabled() {
        return true;
    }
    
    @Override
    protected OAuthProvider getProvider() {
        final WindowsLiveProvider liveProvider = new WindowsLiveProvider();
        liveProvider.setKey("00000000400BFE75");
        liveProvider.setSecret("<KEY>");
        liveProvider.setCallbackUrl("http://javadoc.leleuj.cloudbees.net/");
        return liveProvider;
    }
    
    @Override
    protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception {
        final HtmlTextInput login = authorizationPage.getElementByName("login");
        login.setValueAttribute("<EMAIL>");
        final HtmlPasswordInput password = authorizationPage.getElementByName("passwd");
        password.setValueAttribute("<PASSWORD>");
        final HtmlSubmitInput submit = authorizationPage.getElementByName("SI");
        final HtmlPage callbackPage = submit.click();
        final String callbackUrl = callbackPage.getUrl().toString();
        logger.debug("callbackUrl : {}", callbackUrl);
        return callbackUrl;
    }
    
    @Override
    protected void verifyProfile(final UserProfile userProfile) {
        final WindowsLiveProfile profile = (WindowsLiveProfile) userProfile;
        logger.debug("userProfile : {}", profile);
        assertEquals("416c383b220392d8", profile.getId());
        assertEquals(WindowsLiveProfile.class.getSimpleName() + UserProfile.SEPARATOR + "416c383b220392d8",
                     profile.getTypedId());
        assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), WindowsLiveProfile.class));
        assertCommonProfile(userProfile, null, "Test", "ScribeUP", "Test ScribeUP", null, Gender.MALE, Locale.FRANCE,
                            null, "https://profile.live.com/", null);
        assertEquals(CommonHelper.getFormattedDate(1335878042000L, "yyyy-MM-dd'T'HH:mm:ssz", null), profile
            .getUpdatedTime().toString());
        assertEquals(8, profile.getAttributes().size());
    }
}<commit_msg>gender is no more returned for windows live<commit_after>/*
  Copyright 2012 <NAME>

   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.scribe.up.test.provider.impl;

import java.util.Locale;

import org.scribe.up.profile.ProfileHelper;
import org.scribe.up.profile.UserProfile;
import org.scribe.up.profile.windowslive.WindowsLiveProfile;
import org.scribe.up.provider.OAuthProvider;
import org.scribe.up.provider.impl.WindowsLiveProvider;
import org.scribe.up.test.util.CommonHelper;

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;

/**
 * This class tests the {@link org.scribe.up.provider.impl.WindowsLiveProvider} class by simulating a complete authentication.
 * 
 * @author <NAME>
 * @since 1.1.0
 */
public class TestWindowsLiveProvider extends TestProvider {
    
    @Override
    protected boolean isJavascriptEnabled() {
        return true;
    }
    
    @Override
    protected OAuthProvider getProvider() {
        final WindowsLiveProvider liveProvider = new WindowsLiveProvider();
        liveProvider.setKey("00000000400BFE75");
        liveProvider.setSecret("<KEY>");
        liveProvider.setCallbackUrl("http://javadoc.leleuj.cloudbees.net/");
        return liveProvider;
    }
    
    @Override
    protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception {
        final HtmlTextInput login = authorizationPage.getElementByName("login");
        login.setValueAttribute("<EMAIL>");
        final HtmlPasswordInput password = authorizationPage.getElementByName("passwd");
        password.setValueAttribute("<PASSWORD>");
        final HtmlSubmitInput submit = authorizationPage.getElementByName("SI");
        final HtmlPage callbackPage = submit.click();
        final String callbackUrl = callbackPage.getUrl().toString();
        logger.debug("callbackUrl : {}", callbackUrl);
        return callbackUrl;
    }
    
    @Override
    protected void verifyProfile(final UserProfile userProfile) {
        final WindowsLiveProfile profile = (WindowsLiveProfile) userProfile;
        logger.debug("userProfile : {}", profile);
        assertEquals("416c383b220392d8", profile.getId());
        assertEquals(WindowsLiveProfile.class.getSimpleName() + UserProfile.SEPARATOR + "416c383b220392d8",
                     profile.getTypedId());
        assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), WindowsLiveProfile.class));
        assertCommonProfile(userProfile, null, "Test", "ScribeUP", "Test ScribeUP", null, null, Locale.FRANCE, null,
                            "https://profile.live.com/", null);
        assertEquals(CommonHelper.getFormattedDate(1335878042000L, "yyyy-MM-dd'T'HH:mm:ssz", null), profile
            .getUpdatedTime().toString());
        assertEquals(7, profile.getAttributes().size());
    }
}
{'fraction_non_alphanumeric': 0.10011474469305795, 'fraction_numerical': 0.01835915088927137, 'mean_word_length': 3.7662337662337664, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4826140', 'n_tokens_mistral': 1943, 'n_tokens_neox': 1865, 'n_words': 451}