fix failing test
authorKatja Luther <k.luther@bgbm.org>
Fri, 12 Aug 2016 10:10:09 +0000 (12:10 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 12 Aug 2016 10:10:09 +0000 (12:10 +0200)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CacheLoader.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionAwareTest.java

index 7faec2c..8b079fc 100644 (file)
@@ -355,7 +355,7 @@ public class CacheLoader {
                     CdmBase cachedCdmEntityInSubGraph = cdmCacher.getFromCache(cdmEntityInSubGraph);
 
                     if(cachedCdmEntityInSubGraph != null) {
-                        if(!cachedCdmEntityInSubGraph.equals(cdmEntityInSubGraph)) {
+                        if(cachedCdmEntityInSubGraph != cdmEntityInSubGraph) {
                             // exception : is the case where
                             // the field has been already initialised, cached and
                             // is not the same as the one in the cache, in which case we set the value
index d927cb8..db9cbc3 100644 (file)
@@ -207,7 +207,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         rootChildNode.addChild(grandChildNode);
 
 
-        polytomousKeyNodeService.merge(grandChildNode);
+        polytomousKeyNodeService.merge(grandChildNode, true);
 
 
         Assert.assertFalse(pKey.getRoot().getChildAt(0).getChildAt(0).getId() == 0);
@@ -244,7 +244,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         Taxon taxon = CdmBase.deproxy(taxonService.find(taxon1Uuid),Taxon.class);
         pkeynode.getChildAt(1).setTaxon(taxon);
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
 
         pkey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class);
 
@@ -259,7 +259,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
         Assert.assertEquals(pkeynode.getChildAt(1).getTaxon(), taxon);
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
 
         pkey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class);
 
@@ -295,7 +295,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
         Assert.assertSame(subkey1, subkey2);
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
     }
 
     @Test
@@ -321,7 +321,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
         Assert.assertSame(subkey1, subkey2);
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
     }
 
 
@@ -340,7 +340,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         label2.size();
 
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
     }
 
     @Test
@@ -460,12 +460,21 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         newTerm.setLabel("CreateTest");
 
         try {
-                if(termService.findByRepresentationText("UpdateTest", Feature.class, null, null) != null) {
-                       Pager<Feature> terms =  termService.findByRepresentationText("UpdateTest", Feature.class, null, null);
-                       if (!terms.getRecords().isEmpty()){
-                               termService.delete(terms.getRecords().get(0).getUuid());
+               List<Feature> features = termService.list(Feature.class, 100, 0, null, null);
+               List<UUID> updateTerms = new ArrayList<UUID>();
+               for (Feature feature:features){
+                       if (feature.getLabel().equals("UpdateTest")){
+                               updateTerms.add(feature.getUuid());
                        }
-             }
+               }
+               termService.delete(updateTerms);
+               
+//              if(termService.findByRepresentationText("UpdateTest", Feature.class, null, null) != null) {
+//                     Pager<Feature> terms =  termService.findByRepresentationText("UpdateTest", Feature.class, null, null);
+//                     if (!terms.getRecords().isEmpty()){
+//                             termService.delete(terms.getRecords().get(0).getUuid());
+//                     }
+//             }
 
             Assert.assertNotNull(newTerm);
             TermVocabulary vocNameFeature = vocabularyService.find(vocNameFeatureUuid);
@@ -478,8 +487,10 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
             vocNameFeature.addTerm(newTerm);
 
-            vocs = vocabularyService.merge(vocs);
-            for(TermVocabulary voc : vocs) {
+            List<MergeResult<TermVocabulary>> mergeResults = vocabularyService.merge(vocs, true);
+            
+            for(MergeResult<TermVocabulary> result : mergeResults){
+               TermVocabulary voc = result.getMergedEntity();
                 if(voc.getUuid().equals(vocNameFeatureUuid)) {
                     vocNameFeature = voc;
                 }
@@ -518,7 +529,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         // Test for #5138
         Person person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().load(personUuid);
         person.setFirstname("Me");
-        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
+        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person, true);
     }
 
 
@@ -529,7 +540,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
         person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().load(person.getUuid());
         person.setFirstname("Some");
-        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
+        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person, true);
     }
 
     @Test