Revision ae7e2680
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/session/MockSessionOwner.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.session; |
2 | 2 |
|
3 |
import java.util.HashSet; |
|
3 | 4 |
import java.util.List; |
5 |
import java.util.Set; |
|
4 | 6 |
|
7 |
import org.junit.Assert; |
|
8 |
|
|
9 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent; |
|
5 | 10 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
6 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
|
7 | 11 |
import eu.etaxonomy.taxeditor.session.mock.MockCdmEntitySession; |
8 | 12 |
|
9 | 13 |
public class MockSessionOwner<T extends CdmBase> implements ICdmEntitySessionEnabled { |
10 | 14 |
|
11 | 15 |
List<T> rootEntities; |
12 |
|
|
16 |
Set<T> updatedObjects; |
|
13 | 17 |
|
14 | 18 |
public MockSessionOwner() { |
15 |
rootEntities = null; |
|
19 |
this.rootEntities = null; |
|
20 |
} |
|
21 |
|
|
22 |
public MockSessionOwner(Set<T> updatedObjects) { |
|
23 |
this.rootEntities = null; |
|
24 |
this.updatedObjects = updatedObjects; |
|
16 | 25 |
} |
17 | 26 |
|
18 | 27 |
public MockSessionOwner(List<T> rootEntities) { |
19 | 28 |
this.rootEntities = rootEntities; |
20 | 29 |
} |
21 |
/* (non-Javadoc) |
|
22 |
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap) |
|
23 |
*/ |
|
24 |
@Override |
|
25 |
public void update(CdmDataChangeMap arg0) { |
|
26 | 30 |
|
31 |
public void setUpdatedObjects(Set<T> updatedObjects) { |
|
32 |
this.updatedObjects = updatedObjects; |
|
33 |
} |
|
34 |
|
|
35 |
public void addUpdatedObject(T updatedObject) { |
|
36 |
if(updatedObjects == null) { |
|
37 |
updatedObjects = new HashSet<T>(); |
|
38 |
} |
|
39 |
updatedObjects.add(updatedObject); |
|
27 | 40 |
} |
28 | 41 |
|
29 | 42 |
/* (non-Javadoc) |
... | ... | |
42 | 55 |
return rootEntities; |
43 | 56 |
} |
44 | 57 |
|
58 |
/* (non-Javadoc) |
|
59 |
* @see eu.etaxonomy.cdm.api.application.ICdmChangeListener#onChange(eu.etaxonomy.cdm.api.application.CdmChangeEvent) |
|
60 |
*/ |
|
61 |
@Override |
|
62 |
public void onChange(CdmChangeEvent event) { |
|
63 |
if(updatedObjects != null && !updatedObjects.isEmpty()) { |
|
64 |
for(CdmBase cb : updatedObjects) { |
|
65 |
Assert.assertTrue(event.getChangedObjects().contains(cb)); |
|
66 |
} |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
45 | 70 |
} |
Also available in: Unified diff
ICdmDataChangeService, CdmUIDataChangeService, CdmDataChangeService : added new data change service with different services for the ui and non-ui states
CdmApplicationState, CdmStore : added data change service to app state
CdmChangeEvent, ICdmChangeListener : added change listener and even to fire in case of data changes
ICdmEntitySessionEnabled : extends new change service interface
ICdmEntitySession, CdmEntitySession : removed data change un/registration since this is now handled by the new data change service
BaseRemotingTest, MockCdmEntitySession, *Editor, *ViewPart, *Navigator : refactoring with new change listener
RemotingCdmHandler, RemotingCdmOperation, RemotingCdmUpdateOperation : added new handler / operation architecture base classes
AbstractUtility : added method for running async operation with callback to handler
RemotingChangeAcceptedTaxonToSynonymHandler,RemotingChangeAcceptedTaxonToSynonymOperation : first implementations of new handler / operation architecture
plugin.xml : added standalone and remoting handlers for ChangeAcceptedTaxonToSynonym
*Test : adapted for new handler / operation and change service