### Question:
FHIRExtractors { public static Provenance.ProvenanceAgentComponent getProvenancePerformer(Provenance provenance) { return provenance .getAgent() .stream() .filter(comp -> comp.getRoleFirstRep().getCodingFirstRep().getCode().equals("AGNT")) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Cannot find Provenance performer")); } private  FHIRExtractors(); static String getProviderNPI(Practitioner provider); static String getPatientMBI(Patient patient); static String getPatientBeneId(Patient patient); static UUID getEntityUUID(String idString); static Provenance.ProvenanceAgentComponent getProvenancePerformer(Provenance provenance); static Identifier parseIDFromQueryParam(String queryParam); static Pair<String, String> parseTag(String tag); static Identifier findMatchingIdentifier(List<Identifier> identifiers, DPCIdentifierSystem system); static String getOrganizationID(IBaseResource resource); static String getAttributedNPI(Group group);  }### Answer:
@Test void testProvenanceMissingPerformer() { final Provenance noAgent = new Provenance(); final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> getProvenancePerformer(noAgent), "Should fail with missing agent"); assertEquals(PERFORMER, exception.getMessage(), "Should have correct message"); final Provenance wrongAgent = new Provenance(); wrongAgent.addAgent().addRole().addCoding().setCode("SECRETAGENT"); final IllegalArgumentException agentException = assertThrows(IllegalArgumentException.class, () -> getProvenancePerformer(wrongAgent), "Should fail with incorrect agent"); assertEquals(PERFORMER, agentException.getMessage(), "Should have correct exception message"); }
@Test void testProvenanceExtraction() { final Provenance provenance = new Provenance(); provenance.addAgent().addRole().addCoding().setCode("AGNT"); final Provenance.ProvenanceAgentComponent performer = getProvenancePerformer(provenance); assertEquals("AGNT", performer.getRoleFirstRep().getCodingFirstRep().getCode(), "Should have agent"); }