@Test public void testDeleteFeature() { featureContainer.getFeatureDictionary().put("feature1", mockedFeature1); featureContainer.getFeatureStorage().put(mockedFeature1.getFeatureStem(), mockedFeature1); featureContainer.deleteFeature("feature1"); Assert.assertNull(featureContainer.getFeatureDictionary().get("feature1")); }
@Test public void testAddFeatureStemmingEnabled() { Annotation mockedAnnot1 = Mockito.mock(Annotation.class); Annotation mockedAnnot2 = Mockito.mock(Annotation.class); FeatureMap mockedMap1 = Mockito.mock(FeatureMap.class); FeatureMap mockedMap2 = Mockito.mock(FeatureMap.class); Node startNode = Mockito.mock(Node.class); Node endNode = Mockito.mock(Node.class); String wholeSentence = "First Second Third Fourth."; Mockito.when(startNode.getOffset()).thenReturn((long) 0); Mockito.when(endNode.getOffset()).thenReturn((long) 11); Mockito.when(mockedAnnot1.getFeatures()).thenReturn(mockedMap1); Mockito.when(mockedMap1.get("string")).thenReturn("First"); Mockito.when(mockedMap1.get("stem")).thenReturn("stem1"); Mockito.when(mockedAnnot1.getStartNode()).thenReturn(startNode); Mockito.when(mockedAnnot2.getFeatures()).thenReturn(mockedMap2); Mockito.when(mockedMap2.get("string")).thenReturn("Second"); Mockito.when(mockedMap2.get("stem")).thenReturn("stem2"); Mockito.when(mockedAnnot2.getEndNode()).thenReturn(endNode); Document gateDocument = Mockito.mock(Document.class); Mockito.when(gateDocument.getName()).thenReturn("doc1"); ArrayList<Annotation> featureAnnots = new ArrayList<Annotation>(); featureAnnots.add(mockedAnnot1); featureAnnots.add(mockedAnnot2); Mockito.when(options.isEnableStemming()).thenReturn(true); String featureString = "First Second"; String featureStem = "stem1 stem2"; featureContainer.addFeature(featureAnnots, wholeSentence, gateDocument, "content"); Assert.assertTrue(featureContainer.getFeatureDictionary().get(featureString) != null); Assert.assertTrue(featureContainer.getFeatureStorage().get(featureStem) != null); }