public enum GerritChangeStatus {
    /**
     * Change is open.
     */
    NEW,
    /**
     * Change was merged.
     */
    MERGED,
    /**
     * Change was abandoned.
     */
    ABANDONED,
    /**
     * Catch-all type if Gerrit adds a new ChangeStatus we don't know about.
     */
    UNKNOWN;

    /**
     * Look up the GerritChangeStatus from a string representation.
     * @param status the GerritChangeStatus returned in JSON
     * @return GerritChangeStatus enum value
     */
    public static GerritChangeStatus fromString(String status) {
        for (GerritChangeStatus s : GerritChangeStatus.values()) {
            if (s.name().equals(status)) {
                return s;
            }
        }
        return UNKNOWN;
    }
} public static final String PROJECT = "project"; public static final String BRANCH = "branch"; public static final String ID = "id"; public static final String NUMBER = "number"; public static final String SUBJECT = "subject"; public static final String OWNER = "owner"; public static final String URL = "url"; public static final String EMAIL = "email"; public static final String NAME = "name"; public static final String COMMENTS = "comments"; public static final String MESSAGE = "message"; public static final String REVIEWER = "reviewer"; public static final String CREATED_ON = "createdOn"; public static final String LAST_UPDATED = "lastUpdated"; public static final String STATUS = "status"; public static final String HASHTAGS = "hashtags";
import com.sonymobile.tools.gerrit.gerritevents.dto.GerritChangeStatus;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.PROJECT;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.BRANCH;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.ID;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.NUMBER;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.SUBJECT;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.OWNER;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.URL;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.EMAIL;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.NAME;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.COMMENTS;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.MESSAGE;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.REVIEWER;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.CREATED_ON;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.LAST_UPDATED;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.STATUS;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.HASHTAGS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/*
 * The MIT License
 *
 * Copyright 2010 Sony Mobile Communications Inc. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.sonymobile.tools.gerrit.gerritevents.dto.attr;





/**
 * JUnit tests for {@link com.sonymobile.tools.gerrit.gerritevents.dto.attr.Change}.
 * @author Robert Sandell &lt;robert.sandell@sonyericsson.com&gt;
 */
public class ChangeTest {
    private Account account;
    private JSONObject jsonAccount;

    /**
     * Sets up a dummy Account object and a JSON version before each test.
     */
    @Before
    public void setUp() {
        account = new Account();
        account.setEmail("robert.sandell@sonyericsson.com");
        account.setName("Bobby");
        jsonAccount = new JSONObject();
        jsonAccount.put(EMAIL, account.getEmail());
        jsonAccount.put(NAME, account.getName());
    }

    /**
     * Tests {@link Change#fromJson(net.sf.json.JSONObject)}.
     * @throws Exception if so.
     */
    @Test
    public void testFromJson() throws Exception {
        JSONObject json = new JSONObject();
        json.put(PROJECT, "project");
        json.put(BRANCH, "branch");
        json.put(ID, "I2343434344");
        json.put(NUMBER, "100");
        json.put(SUBJECT, "subject");
        json.put(OWNER, jsonAccount);