### Question:
DefaultKeyGenerator implements KeyGenerator { public static void setWorkerId(final long workerId) { Preconditions.checkArgument(workerId >= 0L && workerId < WORKER_ID_MAX_VALUE); DefaultKeyGenerator.workerId = workerId; }  static void setWorkerId(final long workerId); @Override synchronized Number generateKey(); static final long EPOCH; }### Answer:
@Test(expected = IllegalArgumentException.class) public void assertSetWorkerIdFailureWhenNegative() { DefaultKeyGenerator.setWorkerId(-1L); }
@Test(expected = IllegalArgumentException.class) public void assertSetWorkerIdFailureWhenTooMuch() { DefaultKeyGenerator.setWorkerId(-Long.MAX_VALUE); }
@Test public void assertSetWorkerIdSuccess() throws NoSuchFieldException, IllegalAccessException { DefaultKeyGenerator.setWorkerId(1L); Field workerIdField = DefaultKeyGenerator.class.getDeclaredField("workerId"); workerIdField.setAccessible(true); assertThat(workerIdField.getLong(DefaultKeyGenerator.class), is(1L)); DefaultKeyGenerator.setWorkerId(0L); }