### Question:
MDCBasedDiscriminator extends AbstractDiscriminator<ILoggingEvent> { public String getDiscriminatingValue(ILoggingEvent event) { Map<String, String> mdcMap = event.getMDCPropertyMap(); if (mdcMap == null) { return defaultValue; } String mdcValue = mdcMap.get(key); if (mdcValue == null) { return defaultValue; } else { return mdcValue; } }  String getDiscriminatingValue(ILoggingEvent event); @Override void start(); String getKey(); void setKey(String key); String getDefaultValue(); void setDefaultValue(String defaultValue);  }### Answer:
@Test public void nullMDC() { event = new LoggingEvent("a", logger, Level.DEBUG, "", null, null); assertTrue(event.getMDCPropertyMap().isEmpty()); String discriminatorValue = discriminator.getDiscriminatingValue(event); assertEquals(DEFAULT_VAL, discriminatorValue); }
@Test public void smoke() { MDC.put(key, value); event = new LoggingEvent("a", logger, Level.DEBUG, "", null, null); String discriminatorValue = discriminator.getDiscriminatingValue(event); assertEquals(value, discriminatorValue); }
@Test public void nullMDC() { event = new LoggingEvent("a", logger, Level.DEBUG, "", null, null); assertEquals(new HashMap<String, String>(), event.getMDCPropertyMap()); String discriminatorValue = discriminator.getDiscriminatingValue(event); assertEquals(DEFAULT_VAL, discriminatorValue); }