### Question:
FHIRExtractors { public static String getAttributedNPI(Group group) { final Group.GroupCharacteristicComponent component = group .getCharacteristic() .stream() .filter(concept -> concept.getCode().getCodingFirstRep().getCode().equals("attributed-to")) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Must have 'attributed-to' concept")); if (component.getValue() == null) { throw new IllegalArgumentException("Roster MUST have attributed Provider"); } return ((CodeableConcept) component.getValue()).getCoding() .stream() .filter(code -> code.getSystem().equals(DPCIdentifierSystem.NPPES.getSystem())) .map(Coding::getCode) .filter(Objects::nonNull) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Roster MUST have attributed Provider")); } 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 testGroupAttributedExtraction() { final Group group = new Group(); final IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> getAttributedNPI(group), "Should throw with no concepts"); assertEquals("Must have 'attributed-to' concept", e1.getMessage(), "Should have correct error message"); final CodeableConcept linkedTo = new CodeableConcept(); linkedTo.addCoding().setCode("linked-to").setSystem("http: group.addCharacteristic().setCode(linkedTo); final IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> getAttributedNPI(group), "Should throw with incorrect characteristic"); assertEquals("Must have 'attributed-to' concept", e2.getMessage(), "Should have correct error message"); final CodeableConcept attributedTo = new CodeableConcept(); attributedTo.addCoding().setCode("attributed-to").setSystem("http: final Group.GroupCharacteristicComponent gc = new Group.GroupCharacteristicComponent(); gc.setCode(attributedTo); group.addCharacteristic(gc); final IllegalArgumentException e3 = assertThrows(IllegalArgumentException.class, () -> getAttributedNPI(group), "Should throw with missing value"); assertEquals("Roster MUST have attributed Provider", e3.getMessage(), "Should have correct error message"); final CodeableConcept c = new CodeableConcept(); c.addCoding().setSystem(DPCIdentifierSystem.PECOS.getSystem()).setCode("1"); gc.setValue(c); final IllegalArgumentException e4 = assertThrows(IllegalArgumentException.class, () -> getAttributedNPI(group), "Should throw with missing value"); assertEquals("Roster MUST have attributed Provider", e4.getMessage(), "Should have correct error message"); final CodeableConcept cc = new CodeableConcept(); cc.addCoding().setSystem(DPCIdentifierSystem.NPPES.getSystem()).setCode("123345"); gc.setValue(cc); assertEquals("123345", getAttributedNPI(group), "Should have correct NPI"); }