Skip to content

Commit

Permalink
Use raw types as appropriate TestMasterHbckServlet
Browse files Browse the repository at this point in the history
GSON won't deserialize back into HBase native types so don't give the wrong
impression by using them.
  • Loading branch information
apurtell committed Jun 1, 2022
1 parent 33618e7 commit cb11a74
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void setupMocks() {
doReturn(services).when(master).getMasterRpcServices();
}

@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testHbckServletWithMocks() throws Exception {
// Set up request and response mocks
Expand Down Expand Up @@ -206,33 +206,30 @@ public Void answer(InvocationOnMock invocation) throws Throwable {
assertEquals(FAKE_START_TIMESTAMP, startTimestamp);
long endTimestamp = ((Double) result.get(MasterHbckServlet.END_TIMESTAMP)).longValue();
assertEquals(FAKE_END_TIMESTAMP, endTimestamp);
Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions = (Map<String,
Pair<ServerName, List<ServerName>>>) result.get(MasterHbckServlet.INCONSISTENT_REGIONS);
Map<String, Object> inconsistentRegions =
(Map<String, Object>) result.get(MasterHbckServlet.INCONSISTENT_REGIONS);
assertNotNull(inconsistentRegions);
assertEquals(1, inconsistentRegions.size());
assertNotNull(inconsistentRegions.get(FAKE_HRI.getEncodedName()));
assertNull(inconsistentRegions.get(FAKE_HRI_3.getEncodedName()));
Map<String, ServerName> orphanRegionsOnRS =
(Map<String, ServerName>) result.get(MasterHbckServlet.ORPHAN_REGIONS_ON_RS);
Map<String, Object> orphanRegionsOnRS =
(Map<String, Object>) result.get(MasterHbckServlet.ORPHAN_REGIONS_ON_RS);
assertNull(orphanRegionsOnRS);
Map<String, Path> orphanRegionsOnFS =
(Map<String, Path>) result.get(MasterHbckServlet.ORPHAN_REGIONS_ON_FS);
Map<String, String> orphanRegionsOnFS =
(Map<String, String>) result.get(MasterHbckServlet.ORPHAN_REGIONS_ON_FS);
assertNotNull(orphanRegionsOnFS);
assertEquals(1, orphanRegionsOnFS.size());
assertNull(orphanRegionsOnFS.get(FAKE_HRI.getEncodedName()));
assertNotNull(orphanRegionsOnFS.get(FAKE_HRI_3.getEncodedName()));
List<Pair<RegionInfo, RegionInfo>> holes =
(List<Pair<RegionInfo, RegionInfo>>) result.get(MasterHbckServlet.HOLES);
List holes = (List) result.get(MasterHbckServlet.HOLES);
assertNull(holes);
List<Pair<RegionInfo, RegionInfo>> overlaps =
(List<Pair<RegionInfo, RegionInfo>>) result.get(MasterHbckServlet.OVERLAPS);
List overlaps = (List) result.get(MasterHbckServlet.OVERLAPS);
assertNotNull(overlaps);
assertEquals(1, overlaps.size());
List<Pair<RegionInfo, ServerName>> unknownServers =
(List<Pair<RegionInfo, ServerName>>) result.get(MasterHbckServlet.UNKNOWN_SERVERS);
List unknownServers = (List) result.get(MasterHbckServlet.UNKNOWN_SERVERS);
assertNotNull(unknownServers);
assertEquals(1, unknownServers.size());
List<byte[]> emptyRegionInfo = (List<byte[]>) result.get(MasterHbckServlet.EMPTY_REGIONINFO);
List emptyRegionInfo = (List) result.get(MasterHbckServlet.EMPTY_REGIONINFO);
assertNotNull(emptyRegionInfo);
assertEquals(1, emptyRegionInfo.size());
}
Expand Down

0 comments on commit cb11a74

Please sign in to comment.