### Question:
AppVersionService { public List<VersionInfo> getDistinctVersions(String cluster, String user, String appId) throws IOException { Get get = new Get(getRowKey(cluster, user, appId)); List<VersionInfo> versions = Lists.newArrayList(); Long ts = 0L; Table versionsTable = null; try { versionsTable = hbaseConnection .getTable(TableName.valueOf(Constants.HISTORY_APP_VERSION_TABLE)); Result r = versionsTable.get(get); if (r != null && !r.isEmpty()) { for (Cell c : r.listCells()) { ts = 0L; try { ts = Bytes.toLong(CellUtil.cloneValue(c)); versions.add(new VersionInfo( Bytes.toString(CellUtil.cloneQualifier(c)), ts)); } catch (IllegalArgumentException e1) { LOG.error( "Caught conversion error while converting timestamp to long value " + e1.getMessage()); throw e1; } } } if (versions.size() > 0) { Collections.sort(versions); } } finally { if (versionsTable != null) { versionsTable.close(); } } return versions; } AppVersionService(Connection hbaseConnection); String getLatestVersion(String cluster, String user, String appId); List<VersionInfo> getDistinctVersions(String cluster, String user,
      String appId); boolean addVersion(String cluster, String user, String appId,
      String version, long timestamp);  }### Answer:
@Test public void testGetDistinctVersions() throws Exception { Configuration c = UTIL.getConfiguration(); { String appId = "getDistinctVersions"; AppVersionService service = null; service = new AppVersionService(hbaseConnection); List<VersionInfo> latest = service.getDistinctVersions(cluster, user, appId); assertEquals(latest.size(), 0); } { String appId = "getDistinctVersions"; AppVersionService service = null; service = new AppVersionService(hbaseConnection); service.addVersion(cluster, user, appId, "v1", 10); service.addVersion(cluster, user, appId, "v2", 30); service.addVersion(cluster, user, appId, "v1", 8390); service.addVersion(cluster, user, appId, "v1", 90); service.addVersion(cluster, user, appId, "v1", 80); List<VersionInfo> latest = service.getDistinctVersions(cluster, user, appId); assertEquals(latest.size(), 2); HashSet<String> expVersions = new HashSet<String>(); expVersions.add("v1"); expVersions.add("v2"); for (int i = 0; i < latest.size(); i++) { assertTrue(expVersions.contains(latest.get(i).getVersion())); } } }