+ @Ignore\r
+ @Test\r
+ public void testTitleCacheUpdate(){\r
+ String uuid = "ae787603-3070-4298-9ca6-4cbe73378122";\r
+ UUID fromString = UUID.fromString(uuid);\r
+ DefinedTermBase<?> termBase = termService.find(fromString);\r
+\r
+ // change label\r
+ String expectedTitleCache = termBase.getLabel() + "append";\r
+ termBase.setLabel(expectedTitleCache);\r
+\r
+ commitAndStartNewTransaction(null);\r
+\r
+ termBase = termService.find(fromString);\r
+ assertEquals("Title cache did not update after setting the label and saving the term", expectedTitleCache, termBase.getTitleCache());\r
+\r
+ // add new representation for default language\r
+ String expecteTitleCacheAfterRepresentationChange = "new label";\r
+ Representation representation = termBase.getRepresentation(Language.DEFAULT());\r
+ representation.setLabel(expecteTitleCacheAfterRepresentationChange);\r
+ termBase.addRepresentation(representation);\r
+\r
+ //this will create another termBase in the DB which has the same UUID -> test failure\r
+// termBase.addRepresentation(Representation.NewInstance(expecteTitleCacheAfterRepresentationChange, "", "", Language.DEFAULT()));////new Representation(expecteTitleCacheAfterRepresentationChange, "", "", Language.DEFAULT()));\r
+\r
+\r
+ commitAndStartNewTransaction(null);\r
+\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
+ @DataSets({\r
+ @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="ClearDB_with_Terms_DataSet.xml"),\r
+ @DataSet(value="TermsDataSet-with_auditing_info.xml")\r
+ })\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
+ vocs= 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).getUuid();\r
+\r
+ voc = vocabularyService.find(vocUUID);\r
+ Set<DefinedTerm> terms = voc.getTerms();\r
+ DefinedTermBase termBase =terms.iterator().next();\r
+ UUID termUUID = termBase.getUuid();\r
+ termService.delete(termBase, null);\r
+ //commitAndStartNewTransaction(tableNames);\r
+ termBase = termService.load(termUUID);\r
+ assertNull(termBase);\r
+\r
+\r
+ //TermVocabulary<DefinedTerm> voc = TermVocabulary.NewInstance(TermType.Feature, "TestFeatures", null, null, null);\r
+ voc.addTerm(DefinedTerm.NewDnaMarkerInstance("test", "marker", "t"));\r
+ vocUUID = vocabularyService.save(voc).getUuid();\r
+\r
+ voc = vocabularyService.find(vocUUID);\r
+ terms = voc.getTerms();\r
+ termBase =terms.iterator().next();\r
+ termUUID = termBase.getUuid();\r
+ termBase = termService.load(termUUID);\r
+ BotanicalName testName = BotanicalName.NewInstance(Rank.SPECIES());\r
+ Taxon testTaxon = Taxon.NewInstance(testName,null);\r
+ testTaxon.addIdentifier("Test", (DefinedTerm) termBase);\r
+ taxonService.save(testTaxon);\r
+ termService.delete(termBase, null);\r
+ //commitAndStartNewTransaction(tableNames);\r
+ termBase = termService.load(termUUID);\r
+ assertNotNull(termBase);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()\r
+ */\r
+ @Override\r
+ public void createTestDataSet() throws FileNotFoundException {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r