### Question:
LogChannel implements ILogChannel { public void println( ILogMessage logMessage, LogLevel channelLogLevel ) { String subject = null; LogLevel logLevel = logMessage.getLevel(); if ( !logLevel.isVisible( channelLogLevel ) ) { return; } if ( subject == null ) { subject = "Hop"; } if ( !logLevel.isError() && !Utils.isEmpty( filter ) ) { if ( subject.indexOf( filter ) < 0 && logMessage.toString().indexOf( filter ) < 0 ) { return; } } if ( channelLogLevel.getLevel() >= logLevel.getLevel() ) { HopLoggingEvent loggingEvent = new HopLoggingEvent( logMessage, System.currentTimeMillis(), logLevel ); HopLogStore.getAppender().addLogggingEvent( loggingEvent ); if ( this.fileWriter == null ) { this.fileWriter = LoggingRegistry.getInstance().getLogChannelFileWriterBuffer( logChannelId ); } if ( this.fileWriter != null ) { this.fileWriter.addEvent( loggingEvent ); } } } LogChannel( Object subject );  LogChannel( Object subject, boolean gatheringMetrics );  LogChannel( Object subject, ILoggingObject parentObject );  LogChannel( Object subject, ILoggingObject parentObject, boolean gatheringMetrics ); @Override String toString(); @Override String getLogChannelId(); void println( ILogMessage logMessage, LogLevel channelLogLevel ); void println( ILogMessage message, Throwable e, LogLevel channelLogLevel ); @Override void logMinimal( String s ); @Override void logBasic( String s ); @Override void logError( String s ); @Override void logError( String s, Throwable e ); @Override void logBasic( String s, Object... arguments ); @Override void logDetailed( String s, Object... arguments ); @Override void logError( String s, Object... arguments ); @Override void logDetailed( String s ); @Override void logDebug( String s ); @Override void logDebug( String message, Object... arguments ); @Override void logRowlevel( String s ); @Override void logMinimal( String message, Object... arguments ); @Override void logRowlevel( String message, Object... arguments ); @Override boolean isBasic(); @Override boolean isDebug(); @Override boolean isDetailed(); @Override boolean isRowLevel(); @Override boolean isError(); @Override LogLevel getLogLevel(); @Override void setLogLevel( LogLevel logLevel ); @Override String getContainerObjectId(); @Override void setContainerObjectId( String containerObjectId ); @Override boolean isGatheringMetrics(); @Override void setGatheringMetrics( boolean gatheringMetrics ); @Override boolean isForcingSeparateLogging(); @Override void setForcingSeparateLogging( boolean forcingSeparateLogging ); @Override void snap( IMetrics metric, long... value ); @Override void snap( IMetrics metric, String subject, long... value ); @Override String getFilter(); @Override void setFilter( String filter ); boolean isSimplified(); void setSimplified( boolean simplified ); static ILogChannel GENERAL; static ILogChannel UI; }### Answer:
@Test public void testPrintlnWithNullLogChannelFileWriterBuffer() { when( logLevel.isVisible( any( LogLevel.class ) ) ).thenReturn( true ); LoggingBuffer loggingBuffer = mock( LoggingBuffer.class ); PowerMockito.mockStatic( HopLogStore.class ); when( HopLogStore.getAppender() ).thenReturn( loggingBuffer ); logChannel.println( logMsgInterface, LogLevel.BASIC ); verify( logChFileWriterBuffer, times( 1 ) ).addEvent( any( HopLoggingEvent.class ) ); verify( loggingBuffer, times( 1 ) ).addLogggingEvent( any( HopLoggingEvent.class ) ); }
@Test public void testPrintlnLogNotVisible() { when( logLevel.isVisible( any( LogLevel.class ) ) ).thenReturn( false ); logChannel.println( logMsgInterface, LogLevel.BASIC ); verify( logChFileWriterBuffer, times( 0 ) ).addEvent( any( HopLoggingEvent.class ) ); }