### Question:
MacroFilter implements ISOFilter, Configurable { public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; try { String seqName = cfg.get ("sequencer", null); unsetFields = ISOUtil.toStringArray(cfg.get ("unset", "")); validFields = ISOUtil.toStringArray(cfg.get ("valid", "")); if (seqName != null) { seq = NameRegistrar.get ( "sequencer."+cfg.get("sequencer") ); } else if (seq == null) { seq = new VolatileSequencer(); } } catch (NameRegistrar.NotFoundException e) { throw new ConfigurationException (e); } } MacroFilter(); void setConfiguration(Configuration cfg); ISOMsg filter(ISOChannel channel, ISOMsg m, LogEvent evt);  }### Answer:
@Test public void testSetConfiguration() throws Throwable { MacroFilter macroFilter = new MacroFilter(); Configuration cfg = new SimpleConfiguration(); macroFilter.setConfiguration(cfg); assertNotNull(macroFilter.seq, "macroFilter.seq"); assertSame(cfg, macroFilter.cfg, "macroFilter.cfg"); assertEquals(0, macroFilter.unsetFields.length, "macroFilter.unsetFields.length"); assertEquals(0, macroFilter.validFields.length, "macroFilter.validFields.length"); }
@Test public void testSetConfiguration1() throws Throwable { MacroFilter macroFilter = new MacroFilter(); Configuration cfg = new SimpleConfiguration(); macroFilter.setConfiguration(cfg); macroFilter.setConfiguration(cfg); assertSame(cfg, macroFilter.cfg, "macroFilter.cfg"); assertEquals(0, macroFilter.unsetFields.length, "macroFilter.unsetFields.length"); assertEquals(0, macroFilter.validFields.length, "macroFilter.validFields.length"); }
@Test public void testSetConfigurationThrowsNullPointerException() throws Throwable { MacroFilter macroFilter = new MacroFilter(); Configuration cfg = new SubConfiguration(); try { macroFilter.setConfiguration(cfg); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertSame(cfg, macroFilter.cfg, "macroFilter.cfg"); if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.get(String, String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertEquals(0, macroFilter.unsetFields.length, "macroFilter.unsetFields.length"); assertEquals(0, macroFilter.validFields.length, "macroFilter.validFields.length"); assertNull(macroFilter.seq, "macroFilter.seq"); } }