<commit_before>/**
 * Created by edjiang on 3/30/16.
 */
package com.stormpath.tck.util

import com.jayway.restassured.http.ContentType
import static com.jayway.restassured.RestAssured.*

class TestAccount {
    final String randomUUID = UUID.randomUUID().toString()
    final String email = "fooemail-" + randomUUID + "@stormpath.com"
    final String givenName = "GivenName-" + randomUUID
    final String surname = "Surname-" + randomUUID
    final String middleName = "Foobar"
    final String password = "<PASSWORD>!"
    final String username = "foo-" + randomUUID
    String href

    public static TestAccount create() {
        def result = new TestAccount()

        result.href = given()
            .accept(ContentType.JSON)
            .contentType(ContentType.JSON)
            .body(result.getPropertiesMap())
        .when()
            .post(FrameworkConstants.RegisterRoute)
        .then()
            .statusCode(200)
        .extract()
            .path("account.href")

        return result
    }

    def getPropertiesMap() {
        def accountMap = [email: email,
                       password: password,
                       givenName: givenName,
                       surname: surname,
                       middleName: middleName,
                       username: username]

        return accountMap
    }
}<commit_msg>Refactor TestAccount per discussion with @edjiang<commit_after>/**
 * Created by edjiang on 3/30/16.
 */
package com.stormpath.tck.util

import com.jayway.restassured.http.ContentType
import static com.jayway.restassured.RestAssured.*

class TestAccount {
    final String randomUUID = UUID.randomUUID().toString()
    final String email = "fooemail-" + randomUUID + "@stormpath.com"
    final String givenName = "GivenName-" + randomUUID
    final String surname = "Surname-" + randomUUID
    final String middleName = "Foobar"
    final String password = "<PASSWORD>!"
    final String username = "foo-" + randomUUID
    String href

    public void registerOnServer() {
        href = given()
            .accept(ContentType.JSON)
            .contentType(ContentType.JSON)
            .body(getPropertiesMap())
        .when()
            .post(FrameworkConstants.RegisterRoute)
        .then()
            .statusCode(200)
        .extract()
            .path("account.href")
    }

    def getPropertiesMap() {
        return [email: email,
                password: password,
                givenName: givenName,
                surname: surname,
                middleName: middleName,
                username: username]
    }
}
{'fraction_non_alphanumeric': 0.0998843038951022, 'fraction_numerical': 0.006170458927882761, 'mean_word_length': 2.0734597156398102, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4552479', 'n_tokens_mistral': 729, 'n_tokens_neox': 685, 'n_words': 173}