static void testWithErrorCodes(Map<ServerErrorCode, Integer> serverErrorCodeCounts, MockServerLayout serverLayout,
      RouterErrorCode expectedError, ErrorCodeChecker errorCodeChecker) throws Exception {
    List<ServerErrorCode> serverErrorCodes = new ArrayList<>();
    for (Map.Entry<ServerErrorCode, Integer> entry : serverErrorCodeCounts.entrySet()) {
      for (int j = 0; j < entry.getValue(); j++) {
        serverErrorCodes.add(entry.getKey());
      }
    }
    Collections.shuffle(serverErrorCodes);
    testWithErrorCodes(serverErrorCodes.toArray(new ServerErrorCode[0]), serverLayout, expectedError, errorCodeChecker);
  }
Test that an operation returns a certain result when servers return error codes corresponding
to {@code serverErrorCodeCounts}
@param serverErrorCodeCounts A map from {@link ServerErrorCode}s to a count of how many servers should be set to
                             that error code.
@param serverLayout A {@link MockServerLayout} that is used to find the {@link MockServer}s to set error codes on.
@param expectedError The {@link RouterErrorCode} expected, or null if no error is expected.
@param errorCodeChecker Performs the checks that ensure that the expected {@link RouterErrorCode} is returned .
@throws Exception
ambry-router/src/test/java/com/github/ambry/router/RouterTestHelpers.java