Program: 89109
Project: 89109
Buggy source:
/** 
 * Check that if the reasons supplied on the classpath differ from those already persisted then a warning is logged and no change is made to the persisted reasons. <p> This test uses the underlying log4j implementation to insert a mock Appender, and tests this for the warning message. If the underlying logging framework is changed then this unit test will fail, and it may not be possible to/worth fixing.
 */
@Test public void previouslyStartedSystemShouldWarnIfConfiguredReasonsHaveChanged(){
  when(mockAttributeService.getAttribute(anyString(),anyString(),anyString())).thenReturn((Serializable)PLACEHOLDER_CLASSIFICATION_REASONS);
  when(mockClassificationServiceDAO.getConfiguredReasons()).thenReturn(ALTERNATIVE_CLASSIFICATION_REASONS);
  org.apache.log4j.Logger log4jLogger=org.apache.log4j.Logger.getLogger(ClassificationServiceBootstrap.class);
  log4jLogger.addAppender(mockAppender);
  Level normalLevel=log4jLogger.getLevel();
  log4jLogger.setLevel(Level.WARN);
  classificationServiceBootstrap.initConfiguredClassificationReasons();
  log4jLogger.setLevel(normalLevel);
  verify(mockAttributeService,never()).setAttribute(any(Serializable.class),anyString(),anyString(),anyString());
  verify(mockAppender).doAppend(loggingEventCaptor.capture());
  List<LoggingEvent> loggingEvents=loggingEventCaptor.getAllValues();
  Stream<String> messages=loggingEvents.stream().map(event -> event.getRenderedMessage());
  String expectedMessage="String_Node_Str";
  assertTrue("String_Node_Str",messages.anyMatch(message -> message == expectedMessage));
}

Fixed version (ground truth):
/** 
 * Check that if the reasons supplied on the classpath differ from those already persisted then a warning is logged and no change is made to the persisted reasons. <p> This test uses the underlying log4j implementation to insert a mock Appender, and tests this for the warning message. If the underlying logging framework is changed then this unit test will fail, and it may not be possible to/worth fixing.
 */
@Test public void previouslyStartedSystemShouldWarnIfConfiguredReasonsHaveChanged(){
  when(mockAttributeService.getAttribute(anyString(),anyString(),anyString())).thenReturn((Serializable)PLACEHOLDER_CLASSIFICATION_REASONS);
  when(mockClassificationServiceDAO.getConfiguredReasons()).thenReturn(ALTERNATIVE_CLASSIFICATION_REASONS);
  org.apache.log4j.Logger log4jLogger=org.apache.log4j.Logger.getLogger(ClassificationServiceBootstrap.class);
  log4jLogger.addAppender(mockAppender);
  Level normalLevel=log4jLogger.getLevel();
  log4jLogger.setLevel(Level.WARN);
  classificationServiceBootstrap.initConfiguredClassificationReasons();
  log4jLogger.setLevel(normalLevel);
  verify(mockAttributeService,never()).setAttribute(any(Serializable.class),anyString(),anyString(),anyString());
  verify(mockAppender).doAppend(loggingEventCaptor.capture());
  List<LoggingEvent> loggingEvents=loggingEventCaptor.getAllValues();
  Stream<String> messages=loggingEvents.stream().map(LoggingEvent::getRenderedMessage);
  String expectedMessage="String_Node_Str";
  assertTrue("String_Node_Str",messages.anyMatch(message -> expectedMessage.equals(message)));
}