### Question:
AssignmentManager extends ZooKeeperListener { void processDeadServersAndRegionsInTransition() throws KeeperException, IOException, InterruptedException { processDeadServersAndRegionsInTransition(null); } AssignmentManager(Server master, ServerManager serverManager,
      CatalogTracker catalogTracker, final LoadBalancer balancer,
      final ExecutorService service); ZKTable getZKTable(); ServerName getRegionServerOfRegion(HRegionInfo hri); boolean isRegionAssigned(HRegionInfo hri); List<HRegionInfo> getEnablingTableRegions(String tableName); void addPlan(String encodedName, RegionPlan plan); void addPlans(Map<String, RegionPlan> plans); void setRegionsToReopen(List <HRegionInfo> regions); Pair<Integer, Integer> getReopenStatus(byte[] tableName); void removeClosedRegion(HRegionInfo hri); @Override void nodeCreated(String path); @Override void nodeDataChanged(String path); @Override void nodeDeleted(final String path); @Override void nodeChildrenChanged(String path); void regionOffline(final HRegionInfo regionInfo); void setOffline(HRegionInfo regionInfo); void offlineDisabledRegion(HRegionInfo regionInfo); void assign(HRegionInfo region, boolean setOfflineInZK); void assign(HRegionInfo region, boolean setOfflineInZK,
      boolean forceNewPlan); void assign(HRegionInfo region, boolean setOfflineInZK,
      boolean forceNewPlan, boolean hijack); void removeDeadNotExpiredServers(List<ServerName> servers); void unassign(List<HRegionInfo> regions); void unassign(HRegionInfo region); void unassign(HRegionInfo region, boolean force); void deleteClosingOrClosedNode(HRegionInfo region); void waitForAssignment(HRegionInfo regionInfo); void assignRoot(); void assignMeta(); void assignUserRegionsToOnlineServers(List<HRegionInfo> regions); void assignUserRegions(List<HRegionInfo> regions, List<ServerName> servers); void assignAllUserRegions(); NavigableMap<String, RegionState> getRegionsInTransition(); boolean isRegionsInTransition(); RegionState isRegionInTransition(final HRegionInfo hri); void clearRegionFromTransition(HRegionInfo hri); void waitOnRegionToClearRegionsInTransition(final HRegionInfo hri); List<HRegionInfo> getRegionsOfTable(byte[] tableName); boolean isCarryingRoot(ServerName serverName); boolean isCarryingMeta(ServerName serverName); boolean isCarryingRegion(ServerName serverName, HRegionInfo hri); Pair<Set<HRegionInfo>, List<RegionState>> processServerShutdown(final ServerName sn); void handleSplitReport(final ServerName sn, final HRegionInfo parent,
      final HRegionInfo a, final HRegionInfo b); void stop(); boolean isServerOnline(ServerName serverName); void shutdown();  }### Answer:
@Test(timeout = 5000) public void testProcessDeadServersAndRegionsInTransitionShouldNotFailWithNPE() throws IOException, KeeperException, InterruptedException, ServiceException { final RecoverableZooKeeper recoverableZk = Mockito .mock(RecoverableZooKeeper.class); AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager( this.server, this.serverManager); Watcher zkw = new ZooKeeperWatcher(HBaseConfiguration.create(), "unittest", null) { public RecoverableZooKeeper getRecoverableZooKeeper() { return recoverableZk; } }; ((ZooKeeperWatcher) zkw).registerListener(am); Mockito.doThrow(new InterruptedException()).when(recoverableZk) .getChildren("/hbase/unassigned", zkw); am.setWatcher((ZooKeeperWatcher) zkw); try { am.processDeadServersAndRegionsInTransition(); fail("Expected to abort"); } catch (NullPointerException e) { fail("Should not throw NPE"); } catch (RuntimeException e) { assertEquals("Aborted", e.getLocalizedMessage()); } }