/*
 * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
 * (the "License"). You may not use this work except in compliance with the License, which is
 * available at www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied, as more fully set forth in the License.
 *
 * See the NOTICE file distributed with this work for information regarding copyright ownership.
 */

package alluxio.client.file;

import alluxio.wire.FileInfo;
import alluxio.wire.FileInfoTest;

import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;

/**
 * Tests for the {@link URIStatus} class.
 */
public final class URIStatusTest {

  @Test
  public void constructor() {
    try {
      new URIStatus(null);
      Assert.fail("Cannot create a URIStatus from a null FileInfo");
    } catch (Exception e) {
      Assert.assertTrue(e instanceof NullPointerException);
      Assert.assertThat(e.getMessage(),
          CoreMatchers.containsString("Cannot create a URIStatus from a null FileInfo"));
    }
  }

  /**
   * Tests getting and setting fields.
   */
  @Test
  public void fields() {
    FileInfo fileInfo = FileInfoTest.createRandom();
    URIStatus uriStatus = new URIStatus(fileInfo);
    Assert.assertEquals(uriStatus.getBlockIds(), fileInfo.getBlockIds());
    Assert.assertEquals(uriStatus.getBlockSizeBytes(),
        fileInfo.getBlockSizeBytes());
    Assert.assertEquals(uriStatus.getCreationTimeMs(),
        fileInfo.getCreationTimeMs());
    Assert.assertEquals(uriStatus.getFileId(), fileInfo.getFileId());
    Assert.assertEquals(uriStatus.getGroup(), fileInfo.getGroup());
    Assert.assertEquals(uriStatus.getInMemoryPercentage(),
        fileInfo.getInMemoryPercentage());
    Assert.assertEquals(uriStatus.getLastModificationTimeMs(),
        fileInfo.getLastModificationTimeMs());
    Assert.assertEquals(uriStatus.getLength(), fileInfo.getLength());
    Assert.assertEquals(uriStatus.getName(), fileInfo.getName());
    Assert.assertEquals(uriStatus.getPath(), fileInfo.getPath());
    Assert.assertEquals(uriStatus.getMode(), fileInfo.getMode());
    Assert.assertEquals(uriStatus.getPersistenceState(),
        fileInfo.getPersistenceState());
    Assert.assertEquals(uriStatus.getTtl(), fileInfo.getTtl());
    Assert.assertEquals(uriStatus.getTtlAction(), fileInfo.getTtlAction());
    Assert.assertEquals(uriStatus.getUfsPath(), fileInfo.getUfsPath());
    Assert.assertEquals(uriStatus.getOwner(), fileInfo.getOwner());
    Assert.assertEquals(uriStatus.isCacheable(), fileInfo.isCacheable());
    Assert.assertEquals(uriStatus.isCompleted(), fileInfo.isCompleted());
    Assert.assertEquals(uriStatus.isFolder(), fileInfo.isFolder());
    Assert.assertEquals(uriStatus.isPersisted(), fileInfo.isPersisted());
    Assert.assertEquals(uriStatus.isPinned(), fileInfo.isPinned());
    Assert.assertEquals(uriStatus.isMountPoint(), fileInfo.isMountPoint());
    Assert.assertEquals(uriStatus.getFileBlockInfos(),
        fileInfo.getFileBlockInfos());
    Assert.assertEquals(uriStatus.toString(), fileInfo.toString());
  }

  @Test
  public void testEquals() throws Exception {
    FileInfo fileInfo = FileInfoTest.createRandom();
    URIStatus uriStatus1 = new URIStatus(fileInfo);
    URIStatus uriStatus2 = new URIStatus(fileInfo);
    Assert.assertTrue(uriStatus1.equals(uriStatus2));
    Assert.assertEquals(uriStatus1.hashCode(), uriStatus2.hashCode());
  }
}

@@ -537,16 +537,185 @@
 .file;%0A%0A
+import static org.junit.Assert.assertTrue;%0Aimport static org.junit.Assert.fail;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.junit.Assert.assertEquals;%0A%0A
 import a
@@ -809,32 +809,8 @@
 rs;%0A
-import org.junit.Assert;
 %0Aimp
@@ -997,23 +997,16 @@
 ;%0A      
-Assert.
 fail(%22Ca
@@ -1083,31 +1083,24 @@
  e) %7B%0A      
-Assert.
 assertTrue(e
@@ -1136,31 +1136,24 @@
 ion);%0A      
-Assert.
 assertThat(e
@@ -1456,31 +1456,24 @@
 eInfo);%0A    
-Assert.
 assertEquals
@@ -1519,39 +1519,32 @@
 lockIds());%0A    
-Assert.
 assertEquals(uri
@@ -1606,39 +1606,32 @@
 zeBytes());%0A    
-Assert.
 assertEquals(uri
@@ -1693,39 +1693,32 @@
 nTimeMs());%0A    
-Assert.
 assertEquals(uri
@@ -1756,39 +1756,32 @@
 tFileId());%0A    
-Assert.
 assertEquals(uri
@@ -1817,39 +1817,32 @@
 etGroup());%0A    
-Assert.
 assertEquals(uri
@@ -1912,39 +1912,32 @@
 centage());%0A    
-Assert.
 assertEquals(uri
@@ -2015,39 +2015,32 @@
 nTimeMs());%0A    
-Assert.
 assertEquals(uri
@@ -2078,39 +2078,32 @@
 tLength());%0A    
-Assert.
 assertEquals(uri
@@ -2137,39 +2137,32 @@
 getName());%0A    
-Assert.
 assertEquals(uri
@@ -2196,39 +2196,32 @@
 getPath());%0A    
-Assert.
 assertEquals(uri
@@ -2255,39 +2255,32 @@
 getMode());%0A    
-Assert.
 assertEquals(uri
@@ -2346,39 +2346,32 @@
 ceState());%0A    
-Assert.
 assertEquals(uri
@@ -2403,39 +2403,32 @@
 .getTtl());%0A    
-Assert.
 assertEquals(uri
@@ -2472,39 +2472,32 @@
 lAction());%0A    
-Assert.
 assertEquals(uri
@@ -2537,39 +2537,32 @@
 UfsPath());%0A    
-Assert.
 assertEquals(uri
@@ -2598,39 +2598,32 @@
 etOwner());%0A    
-Assert.
 assertEquals(uri
@@ -2665,39 +2665,32 @@
 cheable());%0A    
-Assert.
 assertEquals(uri
@@ -2732,39 +2732,32 @@
 mpleted());%0A    
-Assert.
 assertEquals(uri
@@ -2793,39 +2793,32 @@
 sFolder());%0A    
-Assert.
 assertEquals(uri
@@ -2860,39 +2860,32 @@
 rsisted());%0A    
-Assert.
 assertEquals(uri
@@ -2921,39 +2921,32 @@
 sPinned());%0A    
-Assert.
 assertEquals(uri
@@ -2990,39 +2990,32 @@
 ntPoint());%0A    
-Assert.
 assertEquals(uri
@@ -3077,39 +3077,32 @@
 ckInfos());%0A    
-Assert.
 assertEquals(uri
@@ -3358,31 +3358,24 @@
 eInfo);%0A    
-Assert.
 assertTrue(u
@@ -3409,23 +3409,16 @@
 ));%0A    
-Assert.
 assertEq

Use static imports for standard test utilities (#516)