class DroolsDescriptionService implements DescriptionService {

	@Override
	public Set<String> getFSNs(Set<String> conceptIds, String... languageRefsetIds) {
		Set<String> fsns = new HashSet<>();
		for (String conceptId : conceptIds) {
			DroolsConcept concept = repository.getConcept(conceptId);
			if(concept != null) {
				Collection<DroolsDescription> descriptions = concept.getDescriptions();
				for (DroolsDescription description : descriptions) {
					if (description.isActive() && description.getTypeId().equals(FULLY_SPECIFIED_NAME)) {
						if(languageRefsetIds != null && languageRefsetIds.length > 0) {
							for (String languageRefsetId : languageRefsetIds) {
								if (PREFERRED_ACCEPTABILITY.equals(description.getAcceptabilityMap().get(languageRefsetId))) {
									fsns.add(description.getTerm());
								}
							}
						} else {
							fsns.add(description.getTerm());
						}
					}
				}
			}
		}
		return fsns;
	}

}

class DroolsDescriptionServiceTest  {

    private DroolsDescriptionService droolsDescriptionService;

    @Test
    public void testFindFSNs() {

        repository.getConcept("1263005").getDescriptions().stream()
                .filter(d -> ConceptConstants.FSN.equals(d.getTypeId()))
                .forEach(d -> d.getAcceptabilityMap().put(ConceptConstants.US_EN_LANGUAGE_REFERENCE_SET, Constants.ACCEPTABILITY_PREFERRED));

        Set<String> conceptsIds = new HashSet<>();
        conceptsIds.add("1263005");
        Set<String> results = droolsDescriptionService.getFSNs(conceptsIds, ConceptConstants.US_EN_LANGUAGE_REFERENCE_SET);
        Assert.assertEquals(1, results.size());
        for (String result : results) {
            Assert.assertEquals("Distinctive arrangement of microtubules (cell structure)", result);
        }

    }

}