/** * Test coding scheme restriction search. * * @throws Exception the exception */ public void testCodingSchemeRestrictionSearch() throws Exception { LexBIGServiceMetadata md = ServiceHolder.instance().getLexBIGService().getServiceMetadata(); md = md.restrictToValue("English", "LuceneQuery"); MetadataProperty[] result = md.resolve().getMetadataProperty(); HashSet<String> temp = new HashSet<String>(); for (int i = 0; i < result.length; i++) { temp.add(result[i].getCodingSchemeURI() + ":" + result[i].getCodingSchemeVersion()); } // should contain this assertTrue(temp.contains(THES_URN + ":" + THES_METADATA_VERSION)); // now do the restriction, and retest. md = ServiceHolder.instance().getLexBIGService().getServiceMetadata(); md = md.restrictToValue("English", "LuceneQuery"); md = md.restrictToCodingScheme( Constructors.createAbsoluteCodingSchemeVersionReference( THES_URN, THES_METADATA_VERSION)); result = md.resolve().getMetadataProperty(); temp = new HashSet<String>(); for (int i = 0; i < result.length; i++) { temp.add(result[i].getCodingSchemeURI() + ":" + result[i].getCodingSchemeVersion()); } // should be more than 1 unique code system. assertTrue(temp.size() >= 1); // should contain this assertTrue(temp.contains(THES_URN + ":" + THES_METADATA_VERSION)); }
/** * Test map synonymto preferred names. * * @throws LBException the LB exception */ public void testMapSynonymtoPreferredNames() throws LBException { CodedNodeSet cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null); cns = cns.restrictToMatchingDesignations( "skeleton", SearchDesignationOption.ALL, "exactMatch", null); ResolvedConceptReference[] rcr = cns.resolveToList(null, null, null, 0).getResolvedConceptReference(); assertTrue(rcr.length == 2); boolean found = false; for (int i = 0; i < rcr.length; i++) { if (rcr[i].getConceptCode().equals("C12788")) { found = true; assertTrue(rcr[i].getReferencedEntry().getPropertyCount() == 5); assertTrue( rcr[i] .getReferencedEntry() .getEntityDescription() .getContent() .equals("Skeletal System")); } } assertTrue(found); }
/** * Testfor current or obsolete conceptb. * * @throws LBException the LB exception */ public void testforCurrentOrObsoleteConceptb() throws LBException { // same as above, but this time, using the new methods (that aren't deprecated) CodedNodeSet cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null); cns = cns.restrictToStatus(ActiveOption.ACTIVE_ONLY, null); cns = cns.restrictToCodes( Constructors.createConceptReferenceList(new String[] {"C38389"}, THES_SCHEME)); ResolvedConceptReference[] rcr = cns.resolveToList(null, null, null, 0).getResolvedConceptReference(); assertTrue("1", rcr.length == 0); cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null); cns = cns.restrictToStatus(ActiveOption.ALL, null); cns = cns.restrictToCodes( Constructors.createConceptReferenceList(new String[] {"C38389"}, THES_SCHEME)); rcr = cns.resolveToList(null, null, null, 0).getResolvedConceptReference(); assertTrue("2", rcr.length == 1); // same test again - no status restriction cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null); cns = cns.restrictToCodes( Constructors.createConceptReferenceList(new String[] {"C38389"}, THES_SCHEME)); rcr = cns.resolveToList(null, null, null, 0).getResolvedConceptReference(); assertTrue("3", rcr.length == 1); // add a status restriction cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null); cns = cns.restrictToMatchingDesignations( "Sex Not Known", SearchDesignationOption.ALL, "exactMatch", null); cns = cns.restrictToStatus(ActiveOption.INACTIVE_ONLY, null); rcr = cns.resolveToList(null, null, null, 0).getResolvedConceptReference(); assertTrue("4", rcr.length == 1); assertFalse("6", rcr[0].getReferencedEntry().getIsActive().booleanValue()); }
/** * Test list coding schemes. * * @throws Exception the exception */ public void testListCodingSchemes() throws Exception { LexBIGServiceMetadata md = ServiceHolder.instance().getLexBIGService().getServiceMetadata(); AbsoluteCodingSchemeVersionReference[] acsvrl = md.listCodingSchemes().getAbsoluteCodingSchemeVersionReference(); assertTrue(acsvrl.length >= 1); assertTrue( contains( acsvrl, Constructors.createAbsoluteCodingSchemeVersionReference( THES_URN, THES_METADATA_VERSION))); }
/** * Test container restriction search. * * @throws Exception the exception */ public void testContainerRestrictionSearch() throws Exception { LexBIGServiceMetadata md = ServiceHolder.instance().getLexBIGService().getServiceMetadata(); md = md.restrictToValue("OWL-FULL", "LuceneQuery"); md = md.restrictToCodingScheme( Constructors.createAbsoluteCodingSchemeVersionReference( THES_URN, THES_METADATA_VERSION)); MetadataProperty[] result = md.resolve().getMetadataProperty(); assertTrue(result.length >= 1); assertTrue(contains(result, THES_URN, THES_METADATA_VERSION, "format", "OWL-FULL")); }
/** * Test retrieve most recent versionof concept. * * @throws LBException the LB exception */ public void testRetrieveMostRecentVersionofConcept() throws LBException { // not providing a version number gets you the PRODUCTION (which can be assumed to be the latest // good version) CodedNodeSet cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null); cns = cns.restrictToCodes( Constructors.createConceptReferenceList(new String[] {"C12223"}, THES_SCHEME)); assertTrue(cns.resolveToList(null, null, null, 0).getResolvedConceptReference().length == 1); }
/** * Test limit returned values. * * @throws LBException the LB exception */ public void testLimitReturnedValues() throws LBException { CodedNodeSet cns = ServiceHolder.instance().getLexBIGService().getCodingSchemeConcepts(THES_SCHEME, null); cns = cns.restrictToMatchingDesignations( "heaart", SearchDesignationOption.ALL, "DoubleMetaphoneLuceneQuery", null); ResolvedConceptReference[] rcr = cns.resolveToList(null, null, null, 1).getResolvedConceptReference(); assertTrue(rcr.length == 1); }
public void testNextInt() { try { LexBIGService lbs = ServiceHolder.instance().getLexBIGService(); CodedNodeSet cns = lbs.getCodingSchemeConcepts("NCI Thesaurus", null); cns = cns.restrictToMatchingDesignations("heart", null, "startsWith", null); ResolvedConceptReferencesIterator rcrl = cns.resolve(null, null, null, null, false); ResolvedConceptReferenceList list1 = rcrl.next(10); ResolvedConceptReferenceList list2 = rcrl.next(10); assertFalse(compareResolvedConceptReferenceList(list1, list2)); } catch (Exception e) { fail("Exception Thrown: " + e.getMessage()); e.printStackTrace(); } }
/** * Test value restriction. * * @throws Exception the exception */ public void testValueRestriction() throws Exception { LexBIGServiceMetadata md = ServiceHolder.instance().getLexBIGService().getServiceMetadata(); md = md.restrictToCodingScheme( Constructors.createAbsoluteCodingSchemeVersionReference( THES_URN, THES_METADATA_VERSION)); md = md.restrictToValue(".*core.*", "RegExp"); MetadataProperty[] result = md.resolve().getMetadataProperty(); assertTrue(result.length >= 2); assertTrue( contains( result, THES_URN, THES_METADATA_VERSION, "homepage", "http://ncicb.nci.nih.gov/core/EVS")); }
public void testNext() { try { LexBIGService lbs = ServiceHolder.instance().getLexBIGService(); CodedNodeSet cns = lbs.getCodingSchemeConcepts("NCI Thesaurus", null); cns = cns.restrictToMatchingDesignations("heart", null, "startsWith", null); ResolvedConceptReferencesIterator rcrl = cns.resolve(null, null, null, null, false); String conceptCode = null; while (rcrl.hasNext()) { ResolvedConceptReference ref = rcrl.next(); String currentCode = ref.getConceptCode(); assertFalse(currentCode.equals(conceptCode)); conceptCode = currentCode; } } catch (Exception e) { fail("Exception Thrown: " + e.getMessage()); e.printStackTrace(); } }