/*
 * 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.block.policy.options;

import alluxio.CommonTestUtils;
import alluxio.Constants;
import alluxio.client.block.BlockWorkerInfo;

import alluxio.wire.WorkerNetAddress;

import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Tests for the {@link GetWorkerOptions} class.
 */
public final class GetWorkerOptionsTest {
  private static final int PORT = 1;

  private final List<BlockWorkerInfo> mWorkerInfos = new ArrayList<>();

  /**
   * Tests for defaults {@link CreateOptions}.
   */
  @Test
  public void defaults() throws IOException {
    GetWorkerOptions options = GetWorkerOptions.defaults();
    Assert.assertEquals(null, options.getBlockWorkerInfos());
    Assert.assertEquals(0, options.getBlockId());
    Assert.assertEquals(0, options.getBlockSize());
  }

  /**
   * Tests for setBlockWorkerInfo.
   */
  @Test
  public void setBlockWorkerInfoTest() {
    mWorkerInfos.clear();
    mWorkerInfos.add(new BlockWorkerInfo(
            new WorkerNetAddress().setHost("worker1").setRpcPort(PORT).setDataPort(PORT)
                    .setWebPort(PORT), Constants.GB, 0));
    mWorkerInfos.add(new BlockWorkerInfo(
            new WorkerNetAddress().setHost("worker2").setRpcPort(PORT).setDataPort(PORT)
                    .setWebPort(PORT), 2 * (long) Constants.GB, 0));
    GetWorkerOptions options = GetWorkerOptions.defaults();
    options.setBlockWorkerInfos(mWorkerInfos);
    Assert.assertEquals(mWorkerInfos, options.getBlockWorkerInfos());
  }

  /**
   * Tests for setBlockId and setBlockSize.
   */
  @Test
  public void fields() {
    Random rand = new Random();
    long blockId = rand.nextLong();
    long blockSize = rand.nextLong();
    GetWorkerOptions options = GetWorkerOptions.defaults();
    options.setBlockId(blockId);
    options.setBlockSize(blockSize);
    Assert.assertEquals(blockId, options.getBlockId());
    Assert.assertEquals(blockSize, options.getBlockSize());
  }

  @Test
  public void equalTest() throws Exception {
    CommonTestUtils.testEquals(GetWorkerOptions.class);
  }
}

@@ -549,24 +549,70 @@
 y.options;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 import allux
@@ -631,16 +631,16 @@
 tUtils;%0A
-
 import a
@@ -746,33 +746,8 @@
 s;%0A%0A
-import org.junit.Assert;%0A
 impo
@@ -1254,31 +1254,24 @@
 ults();%0A    
-Assert.
 assertEquals
@@ -1305,39 +1305,32 @@
 erInfos());%0A    
-Assert.
 assertEquals(0, 
@@ -1348,39 +1348,32 @@
 BlockId());%0A    
-Assert.
 assertEquals(0, 
@@ -2020,31 +2020,24 @@
 Infos);%0A    
-Assert.
 assertEquals
@@ -2413,31 +2413,24 @@
 kSize);%0A    
-Assert.
 assertEquals
@@ -2466,23 +2466,16 @@
 ));%0A    
-Assert.
 assertEq

Use static imports for standard test utilities