### Question:
Cohort extends BaseChangeableOpenmrsData { public boolean contains(Integer patientId) { return getMemberships() != null && getMemberships().stream().anyMatch(m -> m.getPatientId().equals(patientId) && m.isActive()); } Cohort();  Cohort(Integer cohortId);  Cohort(String name, String description, Integer[] ids);  Cohort(String name, String description, Patient[] patients);  Cohort(Collection<?> patientsOrIds);  Cohort(String name, String description, Collection<?> patientsOrIds);  Cohort(String commaSeparatedIds); @Deprecated String getCommaSeparatedPatientIds(); boolean contains(Integer patientId); @Override String toString(); void addMember(Integer memberId); boolean addMembership(CohortMembership cohortMembership); boolean removeMembership(CohortMembership cohortMembership); Collection<CohortMembership> getMemberships(boolean includeVoided); Collection<CohortMembership> getMemberships(); Collection<CohortMembership> getActiveMemberships(Date asOfDate); Collection<CohortMembership> getActiveMemberships(); CohortMembership getActiveMembership(Patient patient); int size(); @Deprecated int getSize(); boolean isEmpty(); static Cohort union(Cohort a, Cohort b); static Cohort intersect(Cohort a, Cohort b); static Cohort subtract(Cohort a, Cohort b); Integer getCohortId(); void setCohortId(Integer cohortId); String getDescription(); void setDescription(String description); String getName(); void setName(String name); @Deprecated Set<Integer> getMemberIds(); @Deprecated void setMemberIds(Set<Integer> memberIds); void setMemberships(Collection<CohortMembership> members); @Override Integer getId(); @Override void setId(Integer id); static final long serialVersionUID; }### Answer:
@Test public void constructorWithIntegers_shouldAddMembersToCohort() { Cohort cohort = new Cohort("name", "description", ids); Arrays.stream(ids).forEach(id -> assertTrue(cohort.contains(id))); }
@Test public void constructorWithPatients_shouldAddMembersToCohort() { List<Patient> patients = new ArrayList<>(); Arrays.stream(ids).forEach(id -> patients.add(new Patient(id))); Cohort cohort = new Cohort("name", "description", patients); Arrays.stream(ids).forEach(id -> assertTrue(cohort.contains(id))); }
@Test public void constructorWithCommaSeparatedIntegers_shouldAddMembersToCohort() { Cohort cohort = new Cohort("1,2,3"); Arrays.stream(ids).forEach(id -> assertTrue(cohort.contains(id))); }