// Copyright (C) 2014 The Android Open Source Project
//
// 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 com.google.gerrit.acceptance.api.accounts;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.extensions.common.AccountInfo;

import org.junit.Test;

public class AccountIT extends AbstractDaemonTest {

  @Test
  public void get() throws Exception {
    AccountInfo info = gApi
        .accounts()
        .id("admin")
        .get();
    assertEquals("Administrator", info.name);
    assertEquals("admin@example.com", info.email);
    assertEquals("admin", info.username);
  }

  @Test
  public void self() throws Exception {
    AccountInfo info = gApi
        .accounts()
        .self()
        .get();
    assertEquals("Administrator", info.name);
    assertEquals("admin@example.com", info.email);
    assertEquals("admin", info.username);
  }

  @Test
  public void starUnstarChange() throws Exception {
    PushOneCommit.Result r = createChange();
    String triplet = "p~master~" + r.getChangeId();
    gApi.accounts()
        .self()
        .starChange(triplet);
    assertTrue(getChange(triplet).starred);
    gApi.accounts()
        .self()
        .unstarChange(triplet);
    assertNull(getChange(triplet).starred);
  }
}

@@ -672,120 +672,45 @@
 tic 
-org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNull;%0Aimport static org.junit.Assert
+com.google.common.truth.Truth
 .assertT
 rue;
@@ -705,19 +705,19 @@
 .assertT
-rue
+hat
 ;%0A%0Aimpor
@@ -1086,38 +1086,57 @@
 et();%0A    assert
+That(info.name).is
 Equal
-s
+To
 (%22Administrator%22
@@ -1131,35 +1131,24 @@
 ministrator%22
-, info.name
 );%0A    asser
@@ -1140,38 +1140,58 @@
 or%22);%0A    assert
+That(info.email).is
 Equal
-s
+To
 (%22admin@example.
@@ -1190,36 +1190,24 @@
 example.com%22
-, info.email
 );%0A    asser
@@ -1211,37 +1211,45 @@
 sert
-Equals(%22admin%22, info.username
+That(info.username).isEqualTo(%22admin%22
 );%0A 
@@ -1390,22 +1390,41 @@
   assert
+That(info.name).is
 Equal
-s
+To
 (%22Admini
@@ -1435,19 +1435,8 @@
 tor%22
-, info.name
 );%0A 
@@ -1440,30 +1440,50 @@
 ;%0A    assert
+That(info.email).is
 Equal
-s
+To
 (%22admin@exam
@@ -1494,20 +1494,8 @@
 com%22
-, info.email
 );%0A 
@@ -1507,37 +1507,45 @@
 sert
-Equals(%22admin%22, info.username
+That(info.username).isEqualTo(%22admin%22
 );%0A 
@@ -1786,11 +1786,11 @@
 ertT
-rue
+hat
 (get
@@ -1809,24 +1809,33 @@
 et).starred)
+.isTrue()
 ;%0A    gApi.a
@@ -1906,12 +1906,12 @@
 sert
-Null
+That
 (get
@@ -1934,16 +1934,25 @@
 starred)
+.isNull()
 ;%0A  %7D%0A%7D%0A

Convert account REST API acceptance tests to use Google Truth