@Test
@SuppressWarnings("checkstyle:IllegalCatch")
public void testGetLeaderLocation() {

    // new shard access does not know anything about leader location
    assertEquals(shardAccess.getLeaderLocation(), LeaderLocation.UNKNOWN);
    // we start getting leader location changes notifications
    shardAccess.onLeaderLocationChanged(LeaderLocation.LOCAL);
    assertEquals(shardAccess.getLeaderLocation(), LeaderLocation.LOCAL);
    shardAccess.onLeaderLocationChanged(LeaderLocation.REMOTE);
    shardAccess.onLeaderLocationChanged(LeaderLocation.UNKNOWN);
    assertEquals(shardAccess.getLeaderLocation(), LeaderLocation.UNKNOWN);
    // closed shard access throws illegal state
    shardAccess.close();
    try {
        shardAccess.getLeaderLocation();
        fail("Should have failed with IllegalStateEx");
    } catch (Exception e) {
        assertTrue(e instanceof IllegalStateException);
    }
}