<NME> UrlGroupTest.java
<BEF> /*
 * Copyright 2015 Google Inc. All rights reserved.
 *
 * 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 org.physical_web.collection;

import static org.junit.Assert.*;

import java.util.Comparator;

import org.junit.Before;
import org.junit.Test;

/**
 * UrlGroup unit test class.
 */
public class UrlGroupTest {
  private static final String ID1 = "id1";
  private static final String ID2 = "id2";
  private static final String URL1 = "http://physical-web.org/#a";
  private static final String URL2 = "http://physical-web.org/#b";
  private static final String GROUPID1 = "group1";
  private static final String GROUPID2 = "group2";
  private static final double RANK1 = 0.5d;
  private static final double RANK2 = 0.9d;

  private PwPair mPwPair1;
  private PwPair mPwPair2;

  private static Comparator<PwPair> testComparator = new Comparator<PwPair>() {
    @Override
    public int compare(PwPair lhs, PwPair rhs) {
      return lhs.getUrlDevice().getId().compareTo(rhs.getUrlDevice().getId());
    }
  };

  public static PwPair createRankedPair(String id, String url, String groupId) {
    UrlDevice urlDevice = new UrlDevice(id, url);
    PwsResult pwsResult = new PwsResult.Builder(url, url)
        .setTitle("title1")
        .setDescription("description1")
        .setGroupId(groupId)
        .build();
    return new PwPair(urlDevice, pwsResult);
  }

  @Before
  public void setUp() {
    mPwPair1 = createRankedPair(ID1, URL1, GROUPID1);
    mPwPair2 = createRankedPair(ID2, URL2, GROUPID1);
  }

  @Test
  public void constructorCreatesProperObject() {
    UrlGroup urlGroup = new UrlGroup(GROUPID1);
    assertEquals(urlGroup.getGroupId(), GROUPID1);
  }

  @Test
  public void addPairAndGetTopPairWorks() {
    UrlGroup urlGroup = new UrlGroup(GROUPID1);
    urlGroup.addPair(mPwPair1);

    PwPair pwPair = urlGroup.getTopPair(testComparator);
    assertEquals(pwPair.getUrlDevice().getId(), ID1);
    assertEquals(pwPair.getUrlDevice().getUrl(), URL1);
    assertEquals(pwPair.getPwsResult().getRequestUrl(), URL1);
    assertEquals(pwPair.getPwsResult().getSiteUrl(), URL1);
    assertEquals(pwPair.getPwsResult().getGroupId(), GROUPID1);
  }

  @Test
  public void addPairTwiceAndGetTopPairWorks() {
    UrlGroup urlGroup = new UrlGroup(GROUPID1);
    urlGroup.addPair(mPwPair1);
    urlGroup.addPair(mPwPair2); // higher rank
    PwPair pwPair = urlGroup.getTopPair(testComparator);
    assertEquals(pwPair.getUrlDevice().getId(), ID1);
  }
}

<MSG> Fix checkstyle errors in collections library

<DFF> @@ -17,11 +17,11 @@ package org.physical_web.collection;
 
 import static org.junit.Assert.*;
 
-import java.util.Comparator;
-
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.Comparator;
+
 /**
  * UrlGroup unit test class.
  */

{'commit': 'diff --git a/java/libs/src/main/java/org/physical_web/collection/EddystoneBeacon.java b/java/libs/src/main/java/org/physical_web/collection/EddystoneBeacon.java\nindex 3598330..0e957e2 100644\n--- a/java/libs/src/main/java/org/physical_web/collection/EddystoneBeacon.java\n+++ b/java/libs/src/main/java/org/physical_web/collection/EddystoneBeacon.java\n@@ -23,6 +23,10 @@ import java.util.Arrays;\n import java.util.HashMap;\n import java.util.UUID;\n \n+/**\n+ * Eddystone beacon class.\n+ * This class represents the Eddystone broadcasting format.\n+ */\n public class EddystoneBeacon {\n   private static final byte URL_FRAME_TYPE = 0x10;\n   private static final byte TITLE_TYPE = 0x0e;\n@@ -65,7 +69,7 @@ public class EddystoneBeacon {\n   }\n \n   /**\n-   * Reads the title of a fat beacon broadcast\n+   * Reads the title of a fat beacon broadcast.\n    * @param serviceData The ble advertised Eddystone URL Service UUID service data\n    * @return Title encoded in the broadcast\n    */\n@@ -78,7 +82,7 @@ public class EddystoneBeacon {\n   }\n \n   /**\n-   * Checks if the broadcast is a fat beacon\n+   * Checks if the broadcast is a fat beacon.\n    * @param serviceData The ble advertised Eddystone URL Service UUID service data\n    * @return true if it is a fat beacon, false otherwise\n    */\n@@ -88,7 +92,7 @@ public class EddystoneBeacon {\n   }\n \n   /**\n-   * Checks if the broadcast is a Eddystone URL\n+   * Checks if the broadcast is a Eddystone URL.\n    * @param serviceData The ble advertised Eddystone URL Service UUID service data\n    * @return true if it is a URL, false otherwise\n    */\n@@ -169,7 +173,7 @@ public class EddystoneBeacon {\n \n \n   /**\n-   * Getter for the Eddystone URL\n+   * Getter for the Eddystone URL.\n    * @return Eddystone URL\n    */\n   public String getUrl() {\n@@ -177,7 +181,7 @@ public class EddystoneBeacon {\n   }\n \n   /**\n-   * Getter for the Tx Power Level\n+   * Getter for the Tx Power Level.\n    * @return Tx Power Level\n    */\n   public byte getTxPowerLevel() {\n@@ -185,7 +189,7 @@ public class EddystoneBeacon {\n   }\n \n   /**\n-   * Getter for the flags\n+   * Getter for the flags.\n    * @return flags\n    */\n   public byte getFlags() {\ndiff --git a/java/libs/src/main/java/org/physical_web/collection/PhysicalWebCollection.java b/java/libs/src/main/java/org/physical_web/collection/PhysicalWebCollection.java\nindex 5691977..e5eae74 100644\n--- a/java/libs/src/main/java/org/physical_web/collection/PhysicalWebCollection.java\n+++ b/java/libs/src/main/java/org/physical_web/collection/PhysicalWebCollection.java\n@@ -72,8 +72,8 @@ public class PhysicalWebCollection {\n     mDeviceIdToUrlDeviceMap.put(urlDevice.getId(), urlDevice);\n     return alreadyFound;\n   }\n-  \n-  /** \n+\n+  /**\n    * Remove a UrlDevice from the collection.\n    * @param urlDevice The UrlDevice to remove.\n    */\ndiff --git a/java/libs/src/test/java/org/physical_web/collection/EddystoneBeaconTest.java b/java/libs/src/test/java/org/physical_web/collection/EddystoneBeaconTest.java\nindex c6c90a1..366a043 100644\n--- a/java/libs/src/test/java/org/physical_web/collection/EddystoneBeaconTest.java\n+++ b/java/libs/src/test/java/org/physical_web/collection/EddystoneBeaconTest.java\n@@ -17,9 +17,11 @@ package org.physical_web.collection;\n \n import static org.junit.Assert.*;\n \n-import org.junit.Before;\n import org.junit.Test;\n \n+/**\n+ * Tests for the EddystoneBeacon class.\n+ */\n public class EddystoneBeaconTest {\n \n   @Test\ndiff --git a/java/libs/src/test/java/org/physical_web/collection/PhysicalWebCollectionTest.java b/java/libs/src/test/java/org/physical_web/collection/PhysicalWebCollectionTest.java\nindex bf84c02..afdef30 100644\n--- a/java/libs/src/test/java/org/physical_web/collection/PhysicalWebCollectionTest.java\n+++ b/java/libs/src/test/java/org/physical_web/collection/PhysicalWebCollectionTest.java\n@@ -22,11 +22,11 @@ import org.json.JSONObject;\n import org.junit.Before;\n import org.junit.Test;\n \n+import org.skyscreamer.jsonassert.JSONAssert;\n+\n import java.util.Comparator;\n import java.util.List;\n \n-import org.skyscreamer.jsonassert.JSONAssert;\n-\n /**\n  * PhysicalWebCollection unit test class.\n  */\ndiff --git a/java/libs/src/test/java/org/physical_web/collection/UrlGroupTest.java b/java/libs/src/test/java/org/physical_web/collection/UrlGroupTest.java\nindex bf7890b..4fedc72 100644\n--- a/java/libs/src/test/java/org/physical_web/collection/UrlGroupTest.java\n+++ b/java/libs/src/test/java/org/physical_web/collection/UrlGroupTest.java\n@@ -17,11 +17,11 @@ package org.physical_web.collection;\n \n import static org.junit.Assert.*;\n \n-import java.util.Comparator;\n-\n import org.junit.Before;\n import org.junit.Test;\n \n+import java.util.Comparator;\n+\n /**\n  * UrlGroup unit test class.\n  */\n', 'commit_subject': 'Fix checkstyle errors in collections library', 'repo_name': 'google/physical-web', 'committer': {'name': 'Conley Owens', 'email': 'c80ad0d5ba1eee75e1702847d361abd6ce4bc7b0@google.com', 'time_sec': '1474401010', 'tz_offset': '-420', 'date': {'seconds': '1474401010'}}, 'commit_tree': 'ec2ac1a343e5cb2f08c02841049de48d94ff1421', 'commit_message': 'Fix checkstyle errors in collections library\n', 'language_name': 'JavaScript', 'license': 'apache-2.0', 'hunks': '@@ -17,11 +17,11 @@ package org.physical_web.collection;\n \n import static org.junit.Assert.*;\n \n-import java.util.Comparator;\n-\n import org.junit.Before;\n import org.junit.Test;\n \n+import java.util.Comparator;\n+\n /**\n  * UrlGroup unit test class.\n  */\n', 'addition_count': 2, 'deletion_count': 2, 'src_file': 'a/java/libs/src/test/java/org/physical_web/collection/UrlGroupTest.java', 'tgt_file': 'b/java/libs/src/test/java/org/physical_web/collection/UrlGroupTest.java', 'file_extension': '.java', 'before_file': '/*\n * Copyright 2015 Google Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage org.physical_web.collection;\n\nimport static org.junit.Assert.*;\n\nimport java.util.Comparator;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\n/**\n * UrlGroup unit test class.\n */\npublic class UrlGroupTest {\n  private static final String ID1 = "id1";\n  private static final String ID2 = "id2";\n  private static final String URL1 = "http://physical-web.org/#a";\n  private static final String URL2 = "http://physical-web.org/#b";\n  private static final String GROUPID1 = "group1";\n  private static final String GROUPID2 = "group2";\n  private static final double RANK1 = 0.5d;\n  private static final double RANK2 = 0.9d;\n\n  private PwPair mPwPair1;\n  private PwPair mPwPair2;\n\n  private static Comparator<PwPair> testComparator = new Comparator<PwPair>() {\n    @Override\n    public int compare(PwPair lhs, PwPair rhs) {\n      return lhs.getUrlDevice().getId().compareTo(rhs.getUrlDevice().getId());\n    }\n  };\n\n  public static PwPair createRankedPair(String id, String url, String groupId) {\n    UrlDevice urlDevice = new UrlDevice(id, url);\n    PwsResult pwsResult = new PwsResult.Builder(url, url)\n        .setTitle("title1")\n        .setDescription("description1")\n        .setGroupId(groupId)\n        .build();\n    return new PwPair(urlDevice, pwsResult);\n  }\n\n  @Before\n  public void setUp() {\n    mPwPair1 = createRankedPair(ID1, URL1, GROUPID1);\n    mPwPair2 = createRankedPair(ID2, URL2, GROUPID1);\n  }\n\n  @Test\n  public void constructorCreatesProperObject() {\n    UrlGroup urlGroup = new UrlGroup(GROUPID1);\n    assertEquals(urlGroup.getGroupId(), GROUPID1);\n  }\n\n  @Test\n  public void addPairAndGetTopPairWorks() {\n    UrlGroup urlGroup = new UrlGroup(GROUPID1);\n    urlGroup.addPair(mPwPair1);\n\n    PwPair pwPair = urlGroup.getTopPair(testComparator);\n    assertEquals(pwPair.getUrlDevice().getId(), ID1);\n    assertEquals(pwPair.getUrlDevice().getUrl(), URL1);\n    assertEquals(pwPair.getPwsResult().getRequestUrl(), URL1);\n    assertEquals(pwPair.getPwsResult().getSiteUrl(), URL1);\n    assertEquals(pwPair.getPwsResult().getGroupId(), GROUPID1);\n  }\n\n  @Test\n  public void addPairTwiceAndGetTopPairWorks() {\n    UrlGroup urlGroup = new UrlGroup(GROUPID1);\n    urlGroup.addPair(mPwPair1);\n    urlGroup.addPair(mPwPair2); // higher rank\n    PwPair pwPair = urlGroup.getTopPair(testComparator);\n    assertEquals(pwPair.getUrlDevice().getId(), ID1);\n  }\n}\n', 'message': 'Fix checkstyle errors in collections library\n', 'author_name': 'Conley Owens', 'lang': 'java'}