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 7faec2c9ad514e24af5684aa2d54eeb4d02e7ba9..8b079fcfaa7467cca279c51dc2f6a42c1277ae71 100644 (file)
@@ -355,7 +355,7 @@ public class CacheLoader {
                     CdmBase cachedCdmEntityInSubGraph = cdmCacher.getFromCache(cdmEntityInSubGraph);
 
                     if(cachedCdmEntityInSubGraph != null) {
                     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
                             // 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 d927cb8e5dfbe508bfa65436275ddf203daed9df..db9cbc3649a4c9eedf4345a60fa0600fd327daa4 100644 (file)
@@ -207,7 +207,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         rootChildNode.addChild(grandChildNode);
 
 
         rootChildNode.addChild(grandChildNode);
 
 
-        polytomousKeyNodeService.merge(grandChildNode);
+        polytomousKeyNodeService.merge(grandChildNode, true);
 
 
         Assert.assertFalse(pKey.getRoot().getChildAt(0).getChildAt(0).getId() == 0);
 
 
         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);
 
         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);
 
 
         pkey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class);
 
@@ -259,7 +259,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
         Assert.assertEquals(pkeynode.getChildAt(1).getTaxon(), taxon);
 
 
         Assert.assertEquals(pkeynode.getChildAt(1).getTaxon(), taxon);
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
 
         pkey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class);
 
 
         pkey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class);
 
@@ -295,7 +295,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
         Assert.assertSame(subkey1, subkey2);
 
 
         Assert.assertSame(subkey1, subkey2);
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
     }
 
     @Test
     }
 
     @Test
@@ -321,7 +321,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
         Assert.assertSame(subkey1, subkey2);
 
 
         Assert.assertSame(subkey1, subkey2);
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
     }
 
 
     }
 
 
@@ -340,7 +340,7 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         label2.size();
 
 
         label2.size();
 
 
-        polytomousKeyService.merge(pkey);
+        polytomousKeyService.merge(pkey, true);
     }
 
     @Test
     }
 
     @Test
@@ -460,12 +460,21 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         newTerm.setLabel("CreateTest");
 
         try {
         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);
 
             Assert.assertNotNull(newTerm);
             TermVocabulary vocNameFeature = vocabularyService.find(vocNameFeatureUuid);
@@ -478,8 +487,10 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
             vocNameFeature.addTerm(newTerm);
 
 
             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;
                 }
                 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");
         // 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");
         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
     }
 
     @Test