### Question:
LogAdvisor extends AbstractAdvisor<MethodLog> { static LogAdvisor newInstance(EclairLogger eclairLogger, List<MethodLog> methodLogs) { return methodLogs.isEmpty() ? null : new LogAdvisor(methodLogs, eclairLogger); } private  LogAdvisor(List<MethodLog> methodLogs,
                       EclairLogger eclairLogger); @Override Object invoke(MethodInvocation invocation);  }### Answer:
@Test public void newInstanceNull() { EclairLogger eclairLogger = mock(EclairLogger.class); List<MethodLog> methodLogs = emptyList(); LogAdvisor logAdvisor = LogAdvisor.newInstance(eclairLogger, methodLogs); assertNull(logAdvisor); }
@Test public void newInstance() throws NoSuchMethodException { EclairLogger eclairLogger = mock(EclairLogger.class); LogAdvisor logAdvisor = LogAdvisor.newInstance(eclairLogger, singletonList(methodLog)); assertNotNull(logAdvisor); assertThat(logAdvisor.getEclairLogger(), is(eclairLogger)); Set<Map.Entry<Method, MethodLog>> entries = logAdvisor.getMethodDefinitions().entrySet(); assertThat(entries, hasSize(1)); Map.Entry<Method, MethodLog> entry = entries.iterator().next(); assertThat(entry.getKey(), is(method)); assertThat(entry.getValue(), is(methodLog)); }