CopyPresentKlvProcessor implements KlvProcessor { @Override public void process( Map<String, KlvHandler> handlers, Metacard metacard, Configuration configuration) { handlers.values().stream() .distinct() .forEach( handler -> { handler.asAttribute().ifPresent(attribute -> safelySetAttribute(metacard, attribute)); }); }  @Override void process(
      Map<String, KlvHandler> handlers, Metacard metacard, Configuration configuration); @Override void accept(Visitor visitor);  }
@Test public void testProcess() { String name = "point-of-contact"; String value = "John Doe"; Attribute attribute = new AttributeImpl(name, value); KlvHandler klvHandler = mock(KlvHandler.class); when(klvHandler.asAttribute()).thenReturn(Optional.of(attribute)); Map<String, KlvHandler> handlers = Collections.singletonMap("someStanagFieldName", klvHandler); MetacardImpl metacard = new MetacardImpl(); KlvProcessor.Configuration klvConfiguration = new KlvProcessor.Configuration(); copyPresentKlvProcessor.process(handlers, metacard, klvConfiguration); assertThat(metacard.getAttribute(name).getValue(), is(value)); }