### Question:
IdWorker { public boolean isValidUserAgent(final String agent) { if (!validateUserAgent) { return true; } final Matcher matcher = AGENT_PATTERN.matcher(agent); return matcher.matches(); } IdWorker(final int workerId, final int datacenterId);  IdWorker(final int workerId, final int datacenterId,
            final long startSequence);  IdWorker(final int workerId, final int datacenterId,
            final boolean validateUserAgent);  IdWorker(final int workerId, final int datacenterId,
            final long startSequence, final boolean validateUserAgent);  IdWorker(final int workerId, final int datacenterId,
            final long startSequence, final boolean validateUserAgent,
            final MetricRegistry registry); long getId(final String agent); int getWorkerId(); int getDatacenterId(); long getTimestamp(); long getSequence(); void setSequence(final long value); synchronized long nextId(); boolean isValidUserAgent(final String agent); static final long TWEPOCH; }### Answer:
@Test public void testValidUserAgent() throws Exception { final IdWorker worker = new IdWorker(1, 1); assertTrue(worker.isValidUserAgent("infra-dm")); }
@Test public void testInvalidUserAgent() throws Exception { final IdWorker worker = new IdWorker(1, 1); assertFalse(worker.isValidUserAgent("1")); assertFalse(worker.isValidUserAgent("1asdf")); }