import static org.junit.Assert.assertEquals;\r
import static org.junit.Assert.assertNotNull;\r
import static org.junit.Assert.assertNull;\r
+import static org.junit.Assert.assertTrue;\r
\r
import java.net.URI;\r
+import java.util.Set;\r
import java.util.UUID;\r
\r
+import org.junit.Assert;\r
import org.apache.log4j.Logger;\r
import org.junit.Ignore;\r
import org.junit.Test;\r
+import org.unitils.dbunit.annotation.DataSet;\r
import org.unitils.spring.annotation.SpringBeanByType;\r
\r
+import eu.etaxonomy.cdm.api.service.DeleteResult.DeleteStatus;\r
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
+import eu.etaxonomy.cdm.model.common.DefinedTerm;\r
import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
import eu.etaxonomy.cdm.model.common.Language;\r
import eu.etaxonomy.cdm.model.common.Representation;\r
+import eu.etaxonomy.cdm.model.common.TermType;\r
import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.cdm.model.location.NamedArea;\r
import eu.etaxonomy.cdm.model.name.Rank;\r
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;\r
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;\r
+import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;\r
\r
/**\r
* @author a.mueller\r
termBase = termService.find(fromString);\r
assertEquals("Title cache did not update after adding a new representation for default language and saving the term", expecteTitleCacheAfterRepresentationChange, termBase.getTitleCache());\r
}\r
+ \r
+ \r
+ @Test\r
+ public void testDeleteTerms(){\r
+ final String[] tableNames = new String[]{\r
+ "DefinedTermBase","Representation"};\r
+ \r
+ //commitAndStartNewTransaction(tableNames);\r
+ /*TermVocabulary<DefinedTerm> vocs = TermVocabulary.NewInstance(TermType.Feature, "TestFeatures", null, null, null);\r
+ vocs.addTerm(DefinedTerm.NewInstance(TermType.State, "green", "green", "gn"));\r
+ UUID vocUUIDs = vocabularyService.save(vocs);*/\r
+ Pager<DefinedTermBase> term = termService.findByRepresentationText("green", DefinedTermBase.class, null, null);\r
+ if (term.getCount() != 0){\r
+ \r
+ DeleteResult result = termService.delete(term.getRecords().get(0));\r
+ assertTrue(result.isOk());\r
+ commitAndStartNewTransaction(tableNames);\r
+ }\r
+ TermVocabulary<DefinedTerm> voc = TermVocabulary.NewInstance(TermType.Feature, "TestFeatures", null, null, null);\r
+ voc.addTerm(DefinedTerm.NewDnaMarkerInstance("test", "marker", "t"));\r
+ UUID vocUUID = vocabularyService.save(voc);\r
+ \r
+ voc = (TermVocabulary)vocabularyService.find(vocUUID);\r
+ Set<DefinedTerm> terms = voc.getTerms();\r
+ DefinedTermBase termBase =(DefinedTerm)terms.iterator().next();\r
+ UUID termUUID = termBase.getUuid();\r
+ termService.delete(termBase, null);\r
+ //commitAndStartNewTransaction(tableNames);\r
+ termBase = (DefinedTerm)termService.load(termUUID);\r
+ assertNull(termBase);\r
+ \r
+ }\r
\r
}\r