Author: adamw
Date: 2008-09-21 18:00:50 -0400 (Sun, 21 Sep 2008)
New Revision: 156
Added:
trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwnedEntity.java
trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwningEntity.java
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListUniEntity.java
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/MapUniEntity.java
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetUniEntity.java
trunk/src/test/org/jboss/envers/test/integration/manytomany/BasicMap.java
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniMap.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedList.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSet.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithEmbId.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithMulId.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesDetachedSet.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleDetachedSet.java
Removed:
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListOwnedUniEntity.java
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetOwnedUniEntity.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedList.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSet.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithEmbId.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithMulId.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesNotOwnedSet.java
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleNotOwnedSet.java
Modified:
trunk/src/main/org/jboss/envers/configuration/metadata/CollectionMetadataGenerator.java
trunk/src/main/org/jboss/envers/entities/mapper/PersistentCollectionChangeData.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/AbstractCollectionMapper.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/BasicCollectionMapper.java
trunk/src/main/org/jboss/envers/entities/mapper/relation/MapCollectionMapper.java
trunk/src/main/org/jboss/envers/event/VersionsEventListener.java
trunk/src/test/org/jboss/envers/test/integration/collection/StringMap.java
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniList.java
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniSet.java
Log:
ENVERS-25: support for many-to-many relations with map-valued properties; mapping from a
simple value. Tests name refactorings to clarify meaning.
Modified:
trunk/src/main/org/jboss/envers/configuration/metadata/CollectionMetadataGenerator.java
===================================================================
---
trunk/src/main/org/jboss/envers/configuration/metadata/CollectionMetadataGenerator.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/main/org/jboss/envers/configuration/metadata/CollectionMetadataGenerator.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -332,8 +332,8 @@
// TODO: add support for enums, components, custom types
mainGenerator.getBasicMetadataGenerator().addSimpleValue(middleEntityXml,
prefix, value, null, ModificationStore.FULL, true);
- return new MiddleComponentData(new
MiddleSimpleComponentMapper(mainGenerator.getVerEntCfg(), prefix),
- queryGeneratorBuilder.getCurrentIndex());
+ // Simple values are always stored in the first entity read by the query
generator.
+ return new MiddleComponentData(new
MiddleSimpleComponentMapper(mainGenerator.getVerEntCfg(), prefix), 0);
} else {
// TODO: throw an exception
throw new RuntimeException();
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/PersistentCollectionChangeData.java
===================================================================
---
trunk/src/main/org/jboss/envers/entities/mapper/PersistentCollectionChangeData.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/main/org/jboss/envers/entities/mapper/PersistentCollectionChangeData.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -33,12 +33,12 @@
public class PersistentCollectionChangeData {
private final String entityName;
private final Map<String, Object> data;
- private final Object obj;
+ private final Object changedElement;
- public PersistentCollectionChangeData(String entityName, Map<String, Object>
data, Object obj) {
+ public PersistentCollectionChangeData(String entityName, Map<String, Object>
data, Object changedElement) {
this.entityName = entityName;
this.data = data;
- this.obj = obj;
+ this.changedElement = changedElement;
}
/**
@@ -54,10 +54,10 @@
}
/**
- *
- * @return The affected object, which was changed (added, removed, modified) in the
collection.
+ * For use by bi-directional associations.
+ * @return The affected element, which was changed (added, removed, modified) in the
collection.
*/
- public Object getObj() {
- return obj;
+ public Object getChangedElement() {
+ return changedElement;
}
}
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/AbstractCollectionMapper.java
===================================================================
---
trunk/src/main/org/jboss/envers/entities/mapper/relation/AbstractCollectionMapper.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/AbstractCollectionMapper.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -39,6 +39,7 @@
protected abstract Collection getNewCollectionContent(PersistentCollection
newCollection);
protected abstract Collection getOldCollectionContent(Serializable oldCollection);
+ protected abstract Object getElement(Object changedObject);
/**
* Maps the changed collection element to the given map.
@@ -55,7 +56,7 @@
entityData.put(commonCollectionMapperData.getVerEntCfg().getOriginalIdPropName(),
originalId);
collectionChanges.add(new PersistentCollectionChangeData(
- commonCollectionMapperData.getVersionsMiddleEntityName(), entityData,
changedObj));
+ commonCollectionMapperData.getVersionsMiddleEntityName(), entityData,
getElement(changedObj)));
// Mapping the collection owner's id.
commonCollectionMapperData.getReferencingIdData().getPrefixedMapper().mapToMapFromId(originalId,
id);
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/BasicCollectionMapper.java
===================================================================
---
trunk/src/main/org/jboss/envers/entities/mapper/relation/BasicCollectionMapper.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/BasicCollectionMapper.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -47,4 +47,8 @@
protected void mapToMapFromObject(Map<String, Object> data, Object changed) {
elementComponentData.getComponentMapper().mapToMapFromObject(data, changed);
}
+
+ protected Object getElement(Object changedObject) {
+ return changedObject;
+ }
}
Modified:
trunk/src/main/org/jboss/envers/entities/mapper/relation/MapCollectionMapper.java
===================================================================
---
trunk/src/main/org/jboss/envers/entities/mapper/relation/MapCollectionMapper.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/main/org/jboss/envers/entities/mapper/relation/MapCollectionMapper.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -52,4 +52,8 @@
elementComponentData.getComponentMapper().mapToMapFromObject(data, ((Map.Entry)
changed).getValue());
indexComponentData.getComponentMapper().mapToMapFromObject(data, ((Map.Entry)
changed).getKey());
}
+
+ protected Object getElement(Object changedObject) {
+ return ((Map.Entry) changedObject).getValue();
+ }
}
\ No newline at end of file
Modified: trunk/src/main/org/jboss/envers/event/VersionsEventListener.java
===================================================================
--- trunk/src/main/org/jboss/envers/event/VersionsEventListener.java 2008-09-21 20:42:00
UTC (rev 155)
+++ trunk/src/main/org/jboss/envers/event/VersionsEventListener.java 2008-09-21 22:00:50
UTC (rev 156)
@@ -140,7 +140,7 @@
IdMapper relatedIdMapper =
verCfg.getEntCfg().get(relatedEntityName).getIdMapper();
for (PersistentCollectionChangeData changeData :
workUnit.getCollectionChanges()) {
- Object relatedObj = changeData.getObj();
+ Object relatedObj = changeData.getChangedElement();
Serializable relatedId = (Serializable)
relatedIdMapper.mapToIdFromEntity(relatedObj);
verSync.addWorkUnit(new CollectionChangeWorkUnit(relatedEntityName,
verCfg, relatedId, relatedObj));
Copied: trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwnedEntity.java (from
rev 148, trunk/src/test/org/jboss/envers/test/entities/manytomany/SetOwnedEntity.java)
===================================================================
--- trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwnedEntity.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwnedEntity.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,84 @@
+package org.jboss.envers.test.entities.manytomany;
+
+import org.jboss.envers.Versioned;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import java.util.Set;
+
+/**
+ * Many-to-many not-owning entity
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+public class MapOwnedEntity {
+ @Id
+ private Integer id;
+
+ @Versioned
+ private String data;
+
+ @Versioned
+ @ManyToMany(mappedBy="references")
+ private Set<MapOwningEntity> referencing;
+
+ public MapOwnedEntity() {
+ }
+
+ public MapOwnedEntity(Integer id, String data) {
+ this.id = id;
+ this.data = data;
+ }
+
+ public MapOwnedEntity(String data) {
+ this.data = data;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public Set<MapOwningEntity> getReferencing() {
+ return referencing;
+ }
+
+ public void setReferencing(Set<MapOwningEntity> referencing) {
+ this.referencing = referencing;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof MapOwnedEntity)) return false;
+
+ MapOwnedEntity that = (MapOwnedEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "MapOwnedEntity(id = " + id + ", data = " + data +
")";
+ }
+}
\ No newline at end of file
Copied: trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwningEntity.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/entities/manytomany/ListOwningEntity.java)
===================================================================
--- trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwningEntity.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwningEntity.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,82 @@
+package org.jboss.envers.test.entities.manytomany;
+
+import org.jboss.envers.Versioned;
+
+import javax.persistence.*;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Entity owning the many-to-many relation
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+public class MapOwningEntity {
+ @Id
+ private Integer id;
+
+ @Versioned
+ private String data;
+
+ @Versioned
+ @ManyToMany
+ private Map<String, MapOwnedEntity> references = new HashMap<String,
MapOwnedEntity>();
+
+ public MapOwningEntity() { }
+
+ public MapOwningEntity(Integer id, String data) {
+ this.id = id;
+ this.data = data;
+ }
+
+ public MapOwningEntity(String data) {
+ this.data = data;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public Map<String, MapOwnedEntity> getReferences() {
+ return references;
+ }
+
+ public void setReferences(Map<String, MapOwnedEntity> references) {
+ this.references = references;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof MapOwningEntity)) return false;
+
+ MapOwningEntity that = (MapOwningEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "MapOwningEntity(id = " + id + ", data = " + data +
")";
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/test/org/jboss/envers/test/entities/manytomany/MapOwningEntity.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListOwnedUniEntity.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListOwnedUniEntity.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListOwnedUniEntity.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,70 +0,0 @@
-package org.jboss.envers.test.entities.manytomany.unidirectional;
-
-import org.jboss.envers.Versioned;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-/**
- * Many-to-many not-owning entity
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-public class ListOwnedUniEntity {
- @Id
- private Integer id;
-
- @Versioned
- private String data;
-
- public ListOwnedUniEntity() {
- }
-
- public ListOwnedUniEntity(Integer id, String data) {
- this.id = id;
- this.data = data;
- }
-
- public ListOwnedUniEntity(String data) {
- this.data = data;
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ListOwnedUniEntity)) return false;
-
- ListOwnedUniEntity that = (ListOwnedUniEntity) o;
-
- if (data != null ? !data.equals(that.data) : that.data != null) return false;
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = (id != null ? id.hashCode() : 0);
- result = 31 * result + (data != null ? data.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "SetOwnedEntity(id = " + id + ", data = " + data +
")";
- }
-}
\ No newline at end of file
Copied:
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListUniEntity.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListOwningUniEntity.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListUniEntity.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/ListUniEntity.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,82 @@
+package org.jboss.envers.test.entities.manytomany.unidirectional;
+
+import org.jboss.envers.Versioned;
+import org.jboss.envers.test.entities.StrTestEntity;
+
+import javax.persistence.*;
+import java.util.List;
+
+/**
+ * Entity owning the many-to-many relation
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+public class ListUniEntity {
+ @Id
+ private Integer id;
+
+ @Versioned
+ private String data;
+
+ @Versioned
+ @ManyToMany
+ private List<StrTestEntity> references;
+
+ public ListUniEntity() { }
+
+ public ListUniEntity(Integer id, String data) {
+ this.id = id;
+ this.data = data;
+ }
+
+ public ListUniEntity(String data) {
+ this.data = data;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public List<StrTestEntity> getReferences() {
+ return references;
+ }
+
+ public void setReferences(List<StrTestEntity> references) {
+ this.references = references;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ListUniEntity)) return false;
+
+ ListUniEntity that = (ListUniEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "ListUniEntity(id = " + id + ", data = " + data +
")";
+ }
+}
\ No newline at end of file
Copied:
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/MapUniEntity.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/entities/onetomany/detached/SetRefCollEntity.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/MapUniEntity.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/MapUniEntity.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,85 @@
+package org.jboss.envers.test.entities.manytomany.unidirectional;
+
+import org.jboss.envers.Versioned;
+import org.jboss.envers.test.entities.StrTestEntity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import java.util.Map;
+
+/**
+ * Entity with a map from a string to an entity
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+public class MapUniEntity {
+ @Id
+ private Integer id;
+
+ @Versioned
+ private String data;
+
+ @Versioned
+ @ManyToMany
+ private Map<String, StrTestEntity> map;
+
+ public MapUniEntity() {
+ }
+
+ public MapUniEntity(Integer id, String data) {
+ this.id = id;
+ this.data = data;
+ }
+
+ public MapUniEntity(String data) {
+ this.data = data;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public Map<String, StrTestEntity> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, StrTestEntity> map) {
+ this.map = map;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof MapUniEntity)) return false;
+
+ MapUniEntity that = (MapUniEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "MapUniEntity(id = " + id + ", data = " + data +
")";
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/MapUniEntity.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetOwnedUniEntity.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetOwnedUniEntity.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetOwnedUniEntity.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,70 +0,0 @@
-package org.jboss.envers.test.entities.manytomany.unidirectional;
-
-import org.jboss.envers.Versioned;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-/**
- * Many-to-many not-owning entity
- * @author Adam Warski (adam at warski dot org)
- */
-@Entity
-public class SetOwnedUniEntity {
- @Id
- private Integer id;
-
- @Versioned
- private String data;
-
- public SetOwnedUniEntity() {
- }
-
- public SetOwnedUniEntity(Integer id, String data) {
- this.id = id;
- this.data = data;
- }
-
- public SetOwnedUniEntity(String data) {
- this.data = data;
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof SetOwnedUniEntity)) return false;
-
- SetOwnedUniEntity that = (SetOwnedUniEntity) o;
-
- if (data != null ? !data.equals(that.data) : that.data != null) return false;
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = (id != null ? id.hashCode() : 0);
- result = 31 * result + (data != null ? data.hashCode() : 0);
- return result;
- }
-
- public String toString() {
- return "SetOwnedUniEntity(id = " + id + ", data = " + data +
")";
- }
-}
\ No newline at end of file
Copied:
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetUniEntity.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetOwningUniEntity.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetUniEntity.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/entities/manytomany/unidirectional/SetUniEntity.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,82 @@
+package org.jboss.envers.test.entities.manytomany.unidirectional;
+
+import org.jboss.envers.Versioned;
+import org.jboss.envers.test.entities.StrTestEntity;
+
+import javax.persistence.*;
+import java.util.Set;
+
+/**
+ * Entity owning the many-to-many relation
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+public class SetUniEntity {
+ @Id
+ private Integer id;
+
+ @Versioned
+ private String data;
+
+ @Versioned
+ @ManyToMany
+ private Set<StrTestEntity> references;
+
+ public SetUniEntity() { }
+
+ public SetUniEntity(Integer id, String data) {
+ this.id = id;
+ this.data = data;
+ }
+
+ public SetUniEntity(String data) {
+ this.data = data;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public Set<StrTestEntity> getReferences() {
+ return references;
+ }
+
+ public void setReferences(Set<StrTestEntity> references) {
+ this.references = references;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof SetUniEntity)) return false;
+
+ SetUniEntity that = (SetUniEntity) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (data != null ? data.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ return "SetUniEntity(id = " + id + ", data = " + data +
")";
+ }
+}
\ No newline at end of file
Modified: trunk/src/test/org/jboss/envers/test/integration/collection/StringMap.java
===================================================================
--- trunk/src/test/org/jboss/envers/test/integration/collection/StringMap.java 2008-09-21
20:42:00 UTC (rev 155)
+++ trunk/src/test/org/jboss/envers/test/integration/collection/StringMap.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -61,7 +61,7 @@
em.getTransaction().commit();
- // Revision 4 (sme1: removing a non-existing mapping, sme2: replacing with the
same value)
+ // No revision (sme1: removing a non-existing mapping, sme2: replacing with the
same value)
em.getTransaction().begin();
sme1 = em.find(StringMapEntity.class, sme1.getId());
Copied: trunk/src/test/org/jboss/envers/test/integration/manytomany/BasicMap.java (from
rev 148, trunk/src/test/org/jboss/envers/test/integration/manytomany/BasicSet.java)
===================================================================
--- trunk/src/test/org/jboss/envers/test/integration/manytomany/BasicMap.java
(rev 0)
+++ trunk/src/test/org/jboss/envers/test/integration/manytomany/BasicMap.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,163 @@
+package org.jboss.envers.test.integration.manytomany;
+
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.entities.manytomany.MapOwningEntity;
+import org.jboss.envers.test.entities.manytomany.MapOwnedEntity;
+import org.jboss.envers.test.tools.TestTools;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.hibernate.ejb.Ejb3Configuration;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicMap extends AbstractEntityTest {
+ private Integer ed1_id;
+ private Integer ed2_id;
+
+ private Integer ing1_id;
+ private Integer ing2_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(MapOwningEntity.class);
+ cfg.addAnnotatedClass(MapOwnedEntity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ MapOwnedEntity ed1 = new MapOwnedEntity(1, "data_ed_1");
+ MapOwnedEntity ed2 = new MapOwnedEntity(2, "data_ed_2");
+
+ MapOwningEntity ing1 = new MapOwningEntity(3, "data_ing_1");
+ MapOwningEntity ing2 = new MapOwningEntity(4, "data_ing_2");
+
+ // Revision 1 (ing1: initialy empty, ing2: one mapping)
+ em.getTransaction().begin();
+
+ ing2.getReferences().put("2", ed2);
+
+ em.persist(ed1);
+ em.persist(ed2);
+ em.persist(ing1);
+ em.persist(ing2);
+
+ em.getTransaction().commit();
+
+ // Revision 2 (ing1: adding two mappings, ing2: replacing an existing mapping)
+
+ em.getTransaction().begin();
+
+ ing1 = em.find(MapOwningEntity.class, ing1.getId());
+ ing2 = em.find(MapOwningEntity.class, ing2.getId());
+ ed1 = em.find(MapOwnedEntity.class, ed1.getId());
+ ed2 = em.find(MapOwnedEntity.class, ed2.getId());
+
+ ing1.getReferences().put("1", ed1);
+ ing1.getReferences().put("2", ed1);
+
+ ing2.getReferences().put("2", ed1);
+
+ em.getTransaction().commit();
+
+ // No revision (ing1: adding an existing mapping, ing2: removing a non existing
mapping)
+ em.getTransaction().begin();
+
+ ing1 = em.find(MapOwningEntity.class, ing1.getId());
+ ing2 = em.find(MapOwningEntity.class, ing2.getId());
+
+ ing1.getReferences().put("1", ed1);
+
+ ing2.getReferences().remove("3");
+
+ em.getTransaction().commit();
+
+ // Revision 3 (ing1: clearing, ing2: replacing with a new map)
+ em.getTransaction().begin();
+
+ ing1 = em.find(MapOwningEntity.class, ing1.getId());
+ ed1 = em.find(MapOwnedEntity.class, ed1.getId());
+
+ ing1.getReferences().clear();
+ ing2.setReferences(new HashMap<String, MapOwnedEntity>());
+ ing2.getReferences().put("1", ed2);
+
+ em.getTransaction().commit();
+ //
+
+ ed1_id = ed1.getId();
+ ed2_id = ed2.getId();
+
+ ing1_id = ing1.getId();
+ ing2_id = ing2.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2,
3).equals(getVersionsReader().getRevisions(MapOwnedEntity.class, ed1_id));
+ assert Arrays.asList(1, 2,
3).equals(getVersionsReader().getRevisions(MapOwnedEntity.class, ed2_id));
+
+ assert Arrays.asList(1, 2,
3).equals(getVersionsReader().getRevisions(MapOwningEntity.class, ing1_id));
+ assert Arrays.asList(1, 2,
3).equals(getVersionsReader().getRevisions(MapOwningEntity.class, ing2_id));
+ }
+
+ @Test
+ public void testHistoryOfEdId1() {
+ MapOwningEntity ing1 = getEntityManager().find(MapOwningEntity.class, ing1_id);
+ MapOwningEntity ing2 = getEntityManager().find(MapOwningEntity.class, ing2_id);
+
+ MapOwnedEntity rev1 = getVersionsReader().find(MapOwnedEntity.class, ed1_id, 1);
+ MapOwnedEntity rev2 = getVersionsReader().find(MapOwnedEntity.class, ed1_id, 2);
+ MapOwnedEntity rev3 = getVersionsReader().find(MapOwnedEntity.class, ed1_id, 3);
+
+ assert rev1.getReferencing().equals(Collections.EMPTY_SET);
+ assert rev2.getReferencing().equals(TestTools.makeSet(ing1, ing2));
+ assert rev3.getReferencing().equals(Collections.EMPTY_SET);
+ }
+
+ @Test
+ public void testHistoryOfEdId2() {
+ MapOwningEntity ing2 = getEntityManager().find(MapOwningEntity.class, ing2_id);
+
+ MapOwnedEntity rev1 = getVersionsReader().find(MapOwnedEntity.class, ed2_id, 1);
+ MapOwnedEntity rev2 = getVersionsReader().find(MapOwnedEntity.class, ed2_id, 2);
+ MapOwnedEntity rev3 = getVersionsReader().find(MapOwnedEntity.class, ed2_id, 3);
+
+ assert rev1.getReferencing().equals(TestTools.makeSet(ing2));
+ assert rev2.getReferencing().equals(Collections.EMPTY_SET);
+ assert rev3.getReferencing().equals(TestTools.makeSet(ing2));
+ }
+
+ @Test
+ public void testHistoryOfEdIng1() {
+ MapOwnedEntity ed1 = getEntityManager().find(MapOwnedEntity.class, ed1_id);
+
+ MapOwningEntity rev1 = getVersionsReader().find(MapOwningEntity.class, ing1_id,
1);
+ MapOwningEntity rev2 = getVersionsReader().find(MapOwningEntity.class, ing1_id,
2);
+ MapOwningEntity rev3 = getVersionsReader().find(MapOwningEntity.class, ing1_id,
3);
+
+ assert rev1.getReferences().equals(Collections.EMPTY_MAP);
+ assert rev2.getReferences().equals(TestTools.makeMap("1", ed1,
"2", ed1));
+ assert rev3.getReferences().equals(Collections.EMPTY_MAP);
+ }
+
+ @Test
+ public void testHistoryOfEdIng2() {
+ MapOwnedEntity ed1 = getEntityManager().find(MapOwnedEntity.class, ed1_id);
+ MapOwnedEntity ed2 = getEntityManager().find(MapOwnedEntity.class, ed2_id);
+
+ MapOwningEntity rev1 = getVersionsReader().find(MapOwningEntity.class, ing2_id,
1);
+ MapOwningEntity rev2 = getVersionsReader().find(MapOwningEntity.class, ing2_id,
2);
+ MapOwningEntity rev3 = getVersionsReader().find(MapOwningEntity.class, ing2_id,
3);
+
+ assert rev1.getReferences().equals(TestTools.makeMap("2", ed2));
+ assert rev2.getReferences().equals(TestTools.makeMap("2", ed1));
+ assert rev3.getReferences().equals(TestTools.makeMap("1", ed2));
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/test/org/jboss/envers/test/integration/manytomany/BasicMap.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniList.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniList.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniList.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,8 +1,8 @@
package org.jboss.envers.test.integration.manytomany.unidirectional;
import org.jboss.envers.test.integration.AbstractEntityTest;
-import org.jboss.envers.test.entities.manytomany.unidirectional.ListOwnedUniEntity;
-import org.jboss.envers.test.entities.manytomany.unidirectional.ListOwningUniEntity;
+import org.jboss.envers.test.entities.manytomany.unidirectional.ListUniEntity;
+import org.jboss.envers.test.entities.StrTestEntity;
import org.jboss.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -24,19 +24,19 @@
private Integer ing2_id;
public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(ListOwningUniEntity.class);
- cfg.addAnnotatedClass(ListOwnedUniEntity.class);
+ cfg.addAnnotatedClass(ListUniEntity.class);
+ cfg.addAnnotatedClass(StrTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
public void initData() {
EntityManager em = getEntityManager();
- ListOwnedUniEntity ed1 = new ListOwnedUniEntity(1, "data_ed_1");
- ListOwnedUniEntity ed2 = new ListOwnedUniEntity(2, "data_ed_2");
+ StrTestEntity ed1 = new StrTestEntity("data_ed_1");
+ StrTestEntity ed2 = new StrTestEntity("data_ed_2");
- ListOwningUniEntity ing1 = new ListOwningUniEntity(3, "data_ing_1");
- ListOwningUniEntity ing2 = new ListOwningUniEntity(4, "data_ing_2");
+ ListUniEntity ing1 = new ListUniEntity(3, "data_ing_1");
+ ListUniEntity ing2 = new ListUniEntity(4, "data_ing_2");
// Revision 1
em.getTransaction().begin();
@@ -52,15 +52,15 @@
em.getTransaction().begin();
- ing1 = em.find(ListOwningUniEntity.class, ing1.getId());
- ing2 = em.find(ListOwningUniEntity.class, ing2.getId());
- ed1 = em.find(ListOwnedUniEntity.class, ed1.getId());
- ed2 = em.find(ListOwnedUniEntity.class, ed2.getId());
+ ing1 = em.find(ListUniEntity.class, ing1.getId());
+ ing2 = em.find(ListUniEntity.class, ing2.getId());
+ ed1 = em.find(StrTestEntity.class, ed1.getId());
+ ed2 = em.find(StrTestEntity.class, ed2.getId());
- ing1.setReferences(new ArrayList<ListOwnedUniEntity>());
+ ing1.setReferences(new ArrayList<StrTestEntity>());
ing1.getReferences().add(ed1);
- ing2.setReferences(new ArrayList<ListOwnedUniEntity>());
+ ing2.setReferences(new ArrayList<StrTestEntity>());
ing2.getReferences().add(ed1);
ing2.getReferences().add(ed2);
@@ -69,9 +69,9 @@
// Revision 3
em.getTransaction().begin();
- ing1 = em.find(ListOwningUniEntity.class, ing1.getId());
- ed2 = em.find(ListOwnedUniEntity.class, ed2.getId());
- ed1 = em.find(ListOwnedUniEntity.class, ed1.getId());
+ ing1 = em.find(ListUniEntity.class, ing1.getId());
+ ed2 = em.find(StrTestEntity.class, ed2.getId());
+ ed1 = em.find(StrTestEntity.class, ed1.getId());
ing1.getReferences().add(ed2);
@@ -80,9 +80,9 @@
// Revision 4
em.getTransaction().begin();
- ing1 = em.find(ListOwningUniEntity.class, ing1.getId());
- ed2 = em.find(ListOwnedUniEntity.class, ed2.getId());
- ed1 = em.find(ListOwnedUniEntity.class, ed1.getId());
+ ing1 = em.find(ListUniEntity.class, ing1.getId());
+ ed2 = em.find(StrTestEntity.class, ed2.getId());
+ ed1 = em.find(StrTestEntity.class, ed1.getId());
ing1.getReferences().remove(ed1);
@@ -91,7 +91,7 @@
// Revision 5
em.getTransaction().begin();
- ing1 = em.find(ListOwningUniEntity.class, ing1.getId());
+ ing1 = em.find(ListUniEntity.class, ing1.getId());
ing1.setReferences(null);
@@ -108,23 +108,23 @@
@Test
public void testRevisionsCounts() {
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(ListOwnedUniEntity.class,
ed1_id));
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(ListOwnedUniEntity.class,
ed2_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, ed1_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, ed2_id));
- assert Arrays.asList(1, 2, 3, 4,
5).equals(getVersionsReader().getRevisions(ListOwningUniEntity.class, ing1_id));
- assert Arrays.asList(1,
2).equals(getVersionsReader().getRevisions(ListOwningUniEntity.class, ing2_id));
+ assert Arrays.asList(1, 2, 3, 4,
5).equals(getVersionsReader().getRevisions(ListUniEntity.class, ing1_id));
+ assert Arrays.asList(1,
2).equals(getVersionsReader().getRevisions(ListUniEntity.class, ing2_id));
}
@Test
public void testHistoryOfEdIng1() {
- ListOwnedUniEntity ed1 = getEntityManager().find(ListOwnedUniEntity.class,
ed1_id);
- ListOwnedUniEntity ed2 = getEntityManager().find(ListOwnedUniEntity.class,
ed2_id);
+ StrTestEntity ed1 = getEntityManager().find(StrTestEntity.class, ed1_id);
+ StrTestEntity ed2 = getEntityManager().find(StrTestEntity.class, ed2_id);
- ListOwningUniEntity rev1 = getVersionsReader().find(ListOwningUniEntity.class,
ing1_id, 1);
- ListOwningUniEntity rev2 = getVersionsReader().find(ListOwningUniEntity.class,
ing1_id, 2);
- ListOwningUniEntity rev3 = getVersionsReader().find(ListOwningUniEntity.class,
ing1_id, 3);
- ListOwningUniEntity rev4 = getVersionsReader().find(ListOwningUniEntity.class,
ing1_id, 4);
- ListOwningUniEntity rev5 = getVersionsReader().find(ListOwningUniEntity.class,
ing1_id, 5);
+ ListUniEntity rev1 = getVersionsReader().find(ListUniEntity.class, ing1_id, 1);
+ ListUniEntity rev2 = getVersionsReader().find(ListUniEntity.class, ing1_id, 2);
+ ListUniEntity rev3 = getVersionsReader().find(ListUniEntity.class, ing1_id, 3);
+ ListUniEntity rev4 = getVersionsReader().find(ListUniEntity.class, ing1_id, 4);
+ ListUniEntity rev5 = getVersionsReader().find(ListUniEntity.class, ing1_id, 5);
assert rev1.getReferences().equals(Collections.EMPTY_LIST);
assert TestTools.checkList(rev2.getReferences(), ed1);
@@ -135,14 +135,14 @@
@Test
public void testHistoryOfEdIng2() {
- ListOwnedUniEntity ed1 = getEntityManager().find(ListOwnedUniEntity.class,
ed1_id);
- ListOwnedUniEntity ed2 = getEntityManager().find(ListOwnedUniEntity.class,
ed2_id);
+ StrTestEntity ed1 = getEntityManager().find(StrTestEntity.class, ed1_id);
+ StrTestEntity ed2 = getEntityManager().find(StrTestEntity.class, ed2_id);
- ListOwningUniEntity rev1 = getVersionsReader().find(ListOwningUniEntity.class,
ing2_id, 1);
- ListOwningUniEntity rev2 = getVersionsReader().find(ListOwningUniEntity.class,
ing2_id, 2);
- ListOwningUniEntity rev3 = getVersionsReader().find(ListOwningUniEntity.class,
ing2_id, 3);
- ListOwningUniEntity rev4 = getVersionsReader().find(ListOwningUniEntity.class,
ing2_id, 4);
- ListOwningUniEntity rev5 = getVersionsReader().find(ListOwningUniEntity.class,
ing2_id, 5);
+ ListUniEntity rev1 = getVersionsReader().find(ListUniEntity.class, ing2_id, 1);
+ ListUniEntity rev2 = getVersionsReader().find(ListUniEntity.class, ing2_id, 2);
+ ListUniEntity rev3 = getVersionsReader().find(ListUniEntity.class, ing2_id, 3);
+ ListUniEntity rev4 = getVersionsReader().find(ListUniEntity.class, ing2_id, 4);
+ ListUniEntity rev5 = getVersionsReader().find(ListUniEntity.class, ing2_id, 5);
assert rev1.getReferences().equals(Collections.EMPTY_LIST);
assert TestTools.checkList(rev2.getReferences(), ed1, ed2);
Copied:
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniMap.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSet.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniMap.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniMap.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,115 @@
+package org.jboss.envers.test.integration.manytomany.unidirectional;
+
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.entities.manytomany.unidirectional.MapUniEntity;
+import org.jboss.envers.test.entities.StrTestEntity;
+import org.jboss.envers.test.tools.TestTools;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+import java.util.HashMap;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicUniMap extends AbstractEntityTest {
+ private Integer str1_id;
+ private Integer str2_id;
+
+ private Integer coll1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(StrTestEntity.class);
+ cfg.addAnnotatedClass(MapUniEntity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ StrTestEntity str1 = new StrTestEntity("str1");
+ StrTestEntity str2 = new StrTestEntity("str2");
+
+ MapUniEntity coll1 = new MapUniEntity(3, "coll1");
+
+ // Revision 1 (coll1: initialy one mapping)
+ em.getTransaction().begin();
+
+ em.persist(str1);
+ em.persist(str2);
+
+ coll1.setMap(new HashMap<String, StrTestEntity>());
+ coll1.getMap().put("1", str1);
+ em.persist(coll1);
+
+ em.getTransaction().commit();
+
+ // Revision 2 (coll1: adding one mapping)
+ em.getTransaction().begin();
+
+ str2 = em.find(StrTestEntity.class, str2.getId());
+ coll1 = em.find(MapUniEntity.class, coll1.getId());
+
+ coll1.getMap().put("2", str2);
+
+ em.getTransaction().commit();
+
+ // Revision 3 (coll1: replacing one mapping)
+ em.getTransaction().begin();
+
+ str1 = em.find(StrTestEntity.class, str1.getId());
+ coll1 = em.find(MapUniEntity.class, coll1.getId());
+
+ coll1.getMap().put("2", str1);
+
+ em.getTransaction().commit();
+
+ // Revision 4 (coll1: removing one mapping)
+ em.getTransaction().begin();
+
+ coll1 = em.find(MapUniEntity.class, coll1.getId());
+
+ coll1.getMap().remove("1");
+
+ em.getTransaction().commit();
+
+ //
+
+ str1_id = str1.getId();
+ str2_id = str2.getId();
+
+ coll1_id = coll1.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(MapUniEntity.class, coll1_id));
+
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str2_id));
+ }
+
+ @Test
+ public void testHistoryOfColl1() {
+ StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
+ StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);
+
+ MapUniEntity rev1 = getVersionsReader().find(MapUniEntity.class, coll1_id, 1);
+ MapUniEntity rev2 = getVersionsReader().find(MapUniEntity.class, coll1_id, 2);
+ MapUniEntity rev3 = getVersionsReader().find(MapUniEntity.class, coll1_id, 3);
+ MapUniEntity rev4 = getVersionsReader().find(MapUniEntity.class, coll1_id, 4);
+
+ assert rev1.getMap().equals(TestTools.makeMap("1", str1));
+ assert rev2.getMap().equals(TestTools.makeMap("1", str1, "2",
str2));
+ assert rev3.getMap().equals(TestTools.makeMap("1", str1, "2",
str1));
+ assert rev4.getMap().equals(TestTools.makeMap("2", str1));
+
+ assert "coll1".equals(rev1.getData());
+ assert "coll1".equals(rev2.getData());
+ assert "coll1".equals(rev3.getData());
+ assert "coll1".equals(rev4.getData());
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniMap.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniSet.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniSet.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/integration/manytomany/unidirectional/BasicUniSet.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,8 +1,8 @@
package org.jboss.envers.test.integration.manytomany.unidirectional;
import org.jboss.envers.test.integration.AbstractEntityTest;
-import org.jboss.envers.test.entities.manytomany.unidirectional.SetOwnedUniEntity;
-import org.jboss.envers.test.entities.manytomany.unidirectional.SetOwningUniEntity;
+import org.jboss.envers.test.entities.manytomany.unidirectional.SetUniEntity;
+import org.jboss.envers.test.entities.StrTestEntity;
import org.jboss.envers.test.tools.TestTools;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -24,19 +24,19 @@
private Integer ing2_id;
public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(SetOwningUniEntity.class);
- cfg.addAnnotatedClass(SetOwnedUniEntity.class);
+ cfg.addAnnotatedClass(SetUniEntity.class);
+ cfg.addAnnotatedClass(StrTestEntity.class);
}
@BeforeClass(dependsOnMethods = "init")
public void initData() {
EntityManager em = getEntityManager();
- SetOwnedUniEntity ed1 = new SetOwnedUniEntity(1, "data_ed_1");
- SetOwnedUniEntity ed2 = new SetOwnedUniEntity(2, "data_ed_2");
+ StrTestEntity ed1 = new StrTestEntity("data_ed_1");
+ StrTestEntity ed2 = new StrTestEntity("data_ed_2");
- SetOwningUniEntity ing1 = new SetOwningUniEntity(3, "data_ing_1");
- SetOwningUniEntity ing2 = new SetOwningUniEntity(4, "data_ing_2");
+ SetUniEntity ing1 = new SetUniEntity(3, "data_ing_1");
+ SetUniEntity ing2 = new SetUniEntity(4, "data_ing_2");
// Revision 1
em.getTransaction().begin();
@@ -52,15 +52,15 @@
em.getTransaction().begin();
- ing1 = em.find(SetOwningUniEntity.class, ing1.getId());
- ing2 = em.find(SetOwningUniEntity.class, ing2.getId());
- ed1 = em.find(SetOwnedUniEntity.class, ed1.getId());
- ed2 = em.find(SetOwnedUniEntity.class, ed2.getId());
+ ing1 = em.find(SetUniEntity.class, ing1.getId());
+ ing2 = em.find(SetUniEntity.class, ing2.getId());
+ ed1 = em.find(StrTestEntity.class, ed1.getId());
+ ed2 = em.find(StrTestEntity.class, ed2.getId());
- ing1.setReferences(new HashSet<SetOwnedUniEntity>());
+ ing1.setReferences(new HashSet<StrTestEntity>());
ing1.getReferences().add(ed1);
- ing2.setReferences(new HashSet<SetOwnedUniEntity>());
+ ing2.setReferences(new HashSet<StrTestEntity>());
ing2.getReferences().add(ed1);
ing2.getReferences().add(ed2);
@@ -69,9 +69,9 @@
// Revision 3
em.getTransaction().begin();
- ing1 = em.find(SetOwningUniEntity.class, ing1.getId());
- ed2 = em.find(SetOwnedUniEntity.class, ed2.getId());
- ed1 = em.find(SetOwnedUniEntity.class, ed1.getId());
+ ing1 = em.find(SetUniEntity.class, ing1.getId());
+ ed2 = em.find(StrTestEntity.class, ed2.getId());
+ ed1 = em.find(StrTestEntity.class, ed1.getId());
ing1.getReferences().add(ed2);
@@ -80,9 +80,9 @@
// Revision 4
em.getTransaction().begin();
- ing1 = em.find(SetOwningUniEntity.class, ing1.getId());
- ed2 = em.find(SetOwnedUniEntity.class, ed2.getId());
- ed1 = em.find(SetOwnedUniEntity.class, ed1.getId());
+ ing1 = em.find(SetUniEntity.class, ing1.getId());
+ ed2 = em.find(StrTestEntity.class, ed2.getId());
+ ed1 = em.find(StrTestEntity.class, ed1.getId());
ing1.getReferences().remove(ed1);
@@ -91,7 +91,7 @@
// Revision 5
em.getTransaction().begin();
- ing1 = em.find(SetOwningUniEntity.class, ing1.getId());
+ ing1 = em.find(SetUniEntity.class, ing1.getId());
ing1.setReferences(null);
@@ -108,23 +108,23 @@
@Test
public void testRevisionsCounts() {
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(SetOwnedUniEntity.class,
ed1_id));
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(SetOwnedUniEntity.class,
ed2_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, ed1_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, ed2_id));
- assert Arrays.asList(1, 2, 3, 4,
5).equals(getVersionsReader().getRevisions(SetOwningUniEntity.class, ing1_id));
- assert Arrays.asList(1,
2).equals(getVersionsReader().getRevisions(SetOwningUniEntity.class, ing2_id));
+ assert Arrays.asList(1, 2, 3, 4,
5).equals(getVersionsReader().getRevisions(SetUniEntity.class, ing1_id));
+ assert Arrays.asList(1,
2).equals(getVersionsReader().getRevisions(SetUniEntity.class, ing2_id));
}
@Test
public void testHistoryOfEdIng1() {
- SetOwnedUniEntity ed1 = getEntityManager().find(SetOwnedUniEntity.class,
ed1_id);
- SetOwnedUniEntity ed2 = getEntityManager().find(SetOwnedUniEntity.class,
ed2_id);
+ StrTestEntity ed1 = getEntityManager().find(StrTestEntity.class, ed1_id);
+ StrTestEntity ed2 = getEntityManager().find(StrTestEntity.class, ed2_id);
- SetOwningUniEntity rev1 = getVersionsReader().find(SetOwningUniEntity.class,
ing1_id, 1);
- SetOwningUniEntity rev2 = getVersionsReader().find(SetOwningUniEntity.class,
ing1_id, 2);
- SetOwningUniEntity rev3 = getVersionsReader().find(SetOwningUniEntity.class,
ing1_id, 3);
- SetOwningUniEntity rev4 = getVersionsReader().find(SetOwningUniEntity.class,
ing1_id, 4);
- SetOwningUniEntity rev5 = getVersionsReader().find(SetOwningUniEntity.class,
ing1_id, 5);
+ SetUniEntity rev1 = getVersionsReader().find(SetUniEntity.class, ing1_id, 1);
+ SetUniEntity rev2 = getVersionsReader().find(SetUniEntity.class, ing1_id, 2);
+ SetUniEntity rev3 = getVersionsReader().find(SetUniEntity.class, ing1_id, 3);
+ SetUniEntity rev4 = getVersionsReader().find(SetUniEntity.class, ing1_id, 4);
+ SetUniEntity rev5 = getVersionsReader().find(SetUniEntity.class, ing1_id, 5);
assert rev1.getReferences().equals(Collections.EMPTY_SET);
assert rev2.getReferences().equals(TestTools.makeSet(ed1));
@@ -135,14 +135,14 @@
@Test
public void testHistoryOfEdIng2() {
- SetOwnedUniEntity ed1 = getEntityManager().find(SetOwnedUniEntity.class,
ed1_id);
- SetOwnedUniEntity ed2 = getEntityManager().find(SetOwnedUniEntity.class,
ed2_id);
+ StrTestEntity ed1 = getEntityManager().find(StrTestEntity.class, ed1_id);
+ StrTestEntity ed2 = getEntityManager().find(StrTestEntity.class, ed2_id);
- SetOwningUniEntity rev1 = getVersionsReader().find(SetOwningUniEntity.class,
ing2_id, 1);
- SetOwningUniEntity rev2 = getVersionsReader().find(SetOwningUniEntity.class,
ing2_id, 2);
- SetOwningUniEntity rev3 = getVersionsReader().find(SetOwningUniEntity.class,
ing2_id, 3);
- SetOwningUniEntity rev4 = getVersionsReader().find(SetOwningUniEntity.class,
ing2_id, 4);
- SetOwningUniEntity rev5 = getVersionsReader().find(SetOwningUniEntity.class,
ing2_id, 5);
+ SetUniEntity rev1 = getVersionsReader().find(SetUniEntity.class, ing2_id, 1);
+ SetUniEntity rev2 = getVersionsReader().find(SetUniEntity.class, ing2_id, 2);
+ SetUniEntity rev3 = getVersionsReader().find(SetUniEntity.class, ing2_id, 3);
+ SetUniEntity rev4 = getVersionsReader().find(SetUniEntity.class, ing2_id, 4);
+ SetUniEntity rev5 = getVersionsReader().find(SetUniEntity.class, ing2_id, 5);
assert rev1.getReferences().equals(Collections.EMPTY_SET);
assert rev2.getReferences().equals(TestTools.makeSet(ed1, ed2));
Copied:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedList.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedList.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedList.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedList.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,115 @@
+package org.jboss.envers.test.integration.onetomany.detached;
+
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.entities.onetomany.detached.ListRefCollEntity;
+import org.jboss.envers.test.entities.StrTestEntity;
+import org.jboss.envers.test.tools.TestTools;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+import java.util.ArrayList;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicDetachedList extends AbstractEntityTest {
+ private Integer str1_id;
+ private Integer str2_id;
+
+ private Integer coll1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(StrTestEntity.class);
+ cfg.addAnnotatedClass(ListRefCollEntity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ StrTestEntity str1 = new StrTestEntity("str1");
+ StrTestEntity str2 = new StrTestEntity("str2");
+
+ ListRefCollEntity coll1 = new ListRefCollEntity(3, "coll1");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(str1);
+ em.persist(str2);
+
+ coll1.setCollection(new ArrayList<StrTestEntity>());
+ coll1.getCollection().add(str1);
+ em.persist(coll1);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+ em.getTransaction().begin();
+
+ str2 = em.find(StrTestEntity.class, str2.getId());
+ coll1 = em.find(ListRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().add(str2);
+
+ em.getTransaction().commit();
+
+ // Revision 3
+ em.getTransaction().begin();
+
+ str1 = em.find(StrTestEntity.class, str1.getId());
+ coll1 = em.find(ListRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().remove(str1);
+
+ em.getTransaction().commit();
+
+ // Revision 4
+ em.getTransaction().begin();
+
+ coll1 = em.find(ListRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().clear();
+
+ em.getTransaction().commit();
+
+ //
+
+ str1_id = str1.getId();
+ str2_id = str2.getId();
+
+ coll1_id = coll1.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(ListRefCollEntity.class, coll1_id));
+
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str2_id));
+ }
+
+ @Test
+ public void testHistoryOfColl1() {
+ StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
+ StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);
+
+ ListRefCollEntity rev1 = getVersionsReader().find(ListRefCollEntity.class,
coll1_id, 1);
+ ListRefCollEntity rev2 = getVersionsReader().find(ListRefCollEntity.class,
coll1_id, 2);
+ ListRefCollEntity rev3 = getVersionsReader().find(ListRefCollEntity.class,
coll1_id, 3);
+ ListRefCollEntity rev4 = getVersionsReader().find(ListRefCollEntity.class,
coll1_id, 4);
+
+ assert TestTools.checkList(rev1.getCollection(), str1);
+ assert TestTools.checkList(rev2.getCollection(), str1, str2);
+ assert TestTools.checkList(rev3.getCollection(), str2);
+ assert TestTools.checkList(rev4.getCollection());
+
+ assert "coll1".equals(rev1.getData());
+ assert "coll1".equals(rev2.getData());
+ assert "coll1".equals(rev3.getData());
+ assert "coll1".equals(rev4.getData());
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedList.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSet.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSet.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSet.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSet.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,115 @@
+package org.jboss.envers.test.integration.onetomany.detached;
+
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.entities.onetomany.detached.SetRefCollEntity;
+import org.jboss.envers.test.entities.StrTestEntity;
+import org.jboss.envers.test.tools.TestTools;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicDetachedSet extends AbstractEntityTest {
+ private Integer str1_id;
+ private Integer str2_id;
+
+ private Integer coll1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(StrTestEntity.class);
+ cfg.addAnnotatedClass(SetRefCollEntity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ StrTestEntity str1 = new StrTestEntity("str1");
+ StrTestEntity str2 = new StrTestEntity("str2");
+
+ SetRefCollEntity coll1 = new SetRefCollEntity(3, "coll1");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(str1);
+ em.persist(str2);
+
+ coll1.setCollection(new HashSet<StrTestEntity>());
+ coll1.getCollection().add(str1);
+ em.persist(coll1);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+ em.getTransaction().begin();
+
+ str2 = em.find(StrTestEntity.class, str2.getId());
+ coll1 = em.find(SetRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().add(str2);
+
+ em.getTransaction().commit();
+
+ // Revision 3
+ em.getTransaction().begin();
+
+ str1 = em.find(StrTestEntity.class, str1.getId());
+ coll1 = em.find(SetRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().remove(str1);
+
+ em.getTransaction().commit();
+
+ // Revision 4
+ em.getTransaction().begin();
+
+ coll1 = em.find(SetRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().clear();
+
+ em.getTransaction().commit();
+
+ //
+
+ str1_id = str1.getId();
+ str2_id = str2.getId();
+
+ coll1_id = coll1.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(SetRefCollEntity.class, coll1_id));
+
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str2_id));
+ }
+
+ @Test
+ public void testHistoryOfColl1() {
+ StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
+ StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);
+
+ SetRefCollEntity rev1 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 1);
+ SetRefCollEntity rev2 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 2);
+ SetRefCollEntity rev3 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 3);
+ SetRefCollEntity rev4 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 4);
+
+ assert rev1.getCollection().equals(TestTools.makeSet(str1));
+ assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
+ assert rev3.getCollection().equals(TestTools.makeSet(str2));
+ assert rev4.getCollection().equals(TestTools.makeSet());
+
+ assert "coll1".equals(rev1.getData());
+ assert "coll1".equals(rev2.getData());
+ assert "coll1".equals(rev3.getData());
+ assert "coll1".equals(rev4.getData());
+ }
+}
Copied:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithEmbId.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithEmbId.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithEmbId.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithEmbId.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,114 @@
+package org.jboss.envers.test.integration.onetomany.detached;
+
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.entities.onetomany.detached.ids.SetRefCollEntityEmbId;
+import org.jboss.envers.test.entities.ids.EmbIdTestEntity;
+import org.jboss.envers.test.entities.ids.EmbId;
+import org.jboss.envers.test.tools.TestTools;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicDetachedSetWithEmbId extends AbstractEntityTest {
+ private EmbId str1_id;
+ private EmbId str2_id;
+
+ private EmbId coll1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(EmbIdTestEntity.class);
+ cfg.addAnnotatedClass(SetRefCollEntityEmbId.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ str1_id = new EmbId(1, 2);
+ str2_id = new EmbId(3, 4);
+
+ coll1_id = new EmbId(5, 6);
+
+ EmbIdTestEntity str1 = new EmbIdTestEntity(str1_id, "str1");
+ EmbIdTestEntity str2 = new EmbIdTestEntity(str2_id, "str2");
+
+ SetRefCollEntityEmbId coll1 = new SetRefCollEntityEmbId(coll1_id,
"coll1");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(str1);
+ em.persist(str2);
+
+ coll1.setCollection(new HashSet<EmbIdTestEntity>());
+ coll1.getCollection().add(str1);
+ em.persist(coll1);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+ em.getTransaction().begin();
+
+ str2 = em.find(EmbIdTestEntity.class, str2.getId());
+ coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
+
+ coll1.getCollection().add(str2);
+
+ em.getTransaction().commit();
+
+ // Revision 3
+ em.getTransaction().begin();
+
+ str1 = em.find(EmbIdTestEntity.class, str1.getId());
+ coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
+
+ coll1.getCollection().remove(str1);
+
+ em.getTransaction().commit();
+
+ // Revision 4
+ em.getTransaction().begin();
+
+ coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
+
+ coll1.getCollection().clear();
+
+ em.getTransaction().commit();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(SetRefCollEntityEmbId.class, coll1_id));
+
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(EmbIdTestEntity.class,
str1_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(EmbIdTestEntity.class,
str2_id));
+ }
+
+ @Test
+ public void testHistoryOfColl1() {
+ EmbIdTestEntity str1 = getEntityManager().find(EmbIdTestEntity.class, str1_id);
+ EmbIdTestEntity str2 = getEntityManager().find(EmbIdTestEntity.class, str2_id);
+
+ SetRefCollEntityEmbId rev1 =
getVersionsReader().find(SetRefCollEntityEmbId.class, coll1_id, 1);
+ SetRefCollEntityEmbId rev2 =
getVersionsReader().find(SetRefCollEntityEmbId.class, coll1_id, 2);
+ SetRefCollEntityEmbId rev3 =
getVersionsReader().find(SetRefCollEntityEmbId.class, coll1_id, 3);
+ SetRefCollEntityEmbId rev4 =
getVersionsReader().find(SetRefCollEntityEmbId.class, coll1_id, 4);
+
+ assert rev1.getCollection().equals(TestTools.makeSet(str1));
+ assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
+ assert rev3.getCollection().equals(TestTools.makeSet(str2));
+ assert rev4.getCollection().equals(TestTools.makeSet());
+
+ assert "coll1".equals(rev1.getData());
+ assert "coll1".equals(rev2.getData());
+ assert "coll1".equals(rev3.getData());
+ assert "coll1".equals(rev4.getData());
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithEmbId.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithMulId.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithMulId.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithMulId.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicDetachedSetWithMulId.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,114 @@
+package org.jboss.envers.test.integration.onetomany.detached;
+
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.entities.onetomany.detached.ids.SetRefCollEntityMulId;
+import org.jboss.envers.test.entities.ids.MulIdTestEntity;
+import org.jboss.envers.test.entities.ids.MulId;
+import org.jboss.envers.test.tools.TestTools;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class BasicDetachedSetWithMulId extends AbstractEntityTest {
+ private MulId str1_id;
+ private MulId str2_id;
+
+ private MulId coll1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(MulIdTestEntity.class);
+ cfg.addAnnotatedClass(SetRefCollEntityMulId.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ str1_id = new MulId(1, 2);
+ str2_id = new MulId(3, 4);
+
+ coll1_id = new MulId(5, 6);
+
+ MulIdTestEntity str1 = new MulIdTestEntity(str1_id.getId1(), str1_id.getId2(),
"str1");
+ MulIdTestEntity str2 = new MulIdTestEntity(str2_id.getId1(), str2_id.getId2(),
"str2");
+
+ SetRefCollEntityMulId coll1 = new SetRefCollEntityMulId(coll1_id.getId1(),
coll1_id.getId2(), "coll1");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(str1);
+ em.persist(str2);
+
+ coll1.setCollection(new HashSet<MulIdTestEntity>());
+ coll1.getCollection().add(str1);
+ em.persist(coll1);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+ em.getTransaction().begin();
+
+ str2 = em.find(MulIdTestEntity.class, str2_id);
+ coll1 = em.find(SetRefCollEntityMulId.class, coll1_id);
+
+ coll1.getCollection().add(str2);
+
+ em.getTransaction().commit();
+
+ // Revision 3
+ em.getTransaction().begin();
+
+ str1 = em.find(MulIdTestEntity.class, str1_id);
+ coll1 = em.find(SetRefCollEntityMulId.class, coll1_id);
+
+ coll1.getCollection().remove(str1);
+
+ em.getTransaction().commit();
+
+ // Revision 4
+ em.getTransaction().begin();
+
+ coll1 = em.find(SetRefCollEntityMulId.class, coll1_id);
+
+ coll1.getCollection().clear();
+
+ em.getTransaction().commit();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(SetRefCollEntityMulId.class, coll1_id));
+
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(MulIdTestEntity.class,
str1_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(MulIdTestEntity.class,
str2_id));
+ }
+
+ @Test
+ public void testHistoryOfColl1() {
+ MulIdTestEntity str1 = getEntityManager().find(MulIdTestEntity.class, str1_id);
+ MulIdTestEntity str2 = getEntityManager().find(MulIdTestEntity.class, str2_id);
+
+ SetRefCollEntityMulId rev1 =
getVersionsReader().find(SetRefCollEntityMulId.class, coll1_id, 1);
+ SetRefCollEntityMulId rev2 =
getVersionsReader().find(SetRefCollEntityMulId.class, coll1_id, 2);
+ SetRefCollEntityMulId rev3 =
getVersionsReader().find(SetRefCollEntityMulId.class, coll1_id, 3);
+ SetRefCollEntityMulId rev4 =
getVersionsReader().find(SetRefCollEntityMulId.class, coll1_id, 4);
+
+ assert rev1.getCollection().equals(TestTools.makeSet(str1));
+ assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
+ assert rev3.getCollection().equals(TestTools.makeSet(str2));
+ assert rev4.getCollection().equals(TestTools.makeSet());
+
+ assert "coll1".equals(rev1.getData());
+ assert "coll1".equals(rev2.getData());
+ assert "coll1".equals(rev3.getData());
+ assert "coll1".equals(rev4.getData());
+ }
+}
\ No newline at end of file
Deleted:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedList.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedList.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedList.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,115 +0,0 @@
-package org.jboss.envers.test.integration.onetomany.detached;
-
-import org.jboss.envers.test.integration.AbstractEntityTest;
-import org.jboss.envers.test.entities.onetomany.detached.ListRefCollEntity;
-import org.jboss.envers.test.entities.StrTestEntity;
-import org.jboss.envers.test.tools.TestTools;
-import org.hibernate.ejb.Ejb3Configuration;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import javax.persistence.EntityManager;
-import java.util.Arrays;
-import java.util.ArrayList;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class BasicNotOwnedList extends AbstractEntityTest {
- private Integer str1_id;
- private Integer str2_id;
-
- private Integer coll1_id;
-
- public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(StrTestEntity.class);
- cfg.addAnnotatedClass(ListRefCollEntity.class);
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- StrTestEntity str1 = new StrTestEntity("str1");
- StrTestEntity str2 = new StrTestEntity("str2");
-
- ListRefCollEntity coll1 = new ListRefCollEntity(3, "coll1");
-
- // Revision 1
- em.getTransaction().begin();
-
- em.persist(str1);
- em.persist(str2);
-
- coll1.setCollection(new ArrayList<StrTestEntity>());
- coll1.getCollection().add(str1);
- em.persist(coll1);
-
- em.getTransaction().commit();
-
- // Revision 2
- em.getTransaction().begin();
-
- str2 = em.find(StrTestEntity.class, str2.getId());
- coll1 = em.find(ListRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().add(str2);
-
- em.getTransaction().commit();
-
- // Revision 3
- em.getTransaction().begin();
-
- str1 = em.find(StrTestEntity.class, str1.getId());
- coll1 = em.find(ListRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().remove(str1);
-
- em.getTransaction().commit();
-
- // Revision 4
- em.getTransaction().begin();
-
- coll1 = em.find(ListRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().clear();
-
- em.getTransaction().commit();
-
- //
-
- str1_id = str1.getId();
- str2_id = str2.getId();
-
- coll1_id = coll1.getId();
- }
-
- @Test
- public void testRevisionsCounts() {
- assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(ListRefCollEntity.class, coll1_id));
-
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str2_id));
- }
-
- @Test
- public void testHistoryOfColl1() {
- StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
- StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);
-
- ListRefCollEntity rev1 = getVersionsReader().find(ListRefCollEntity.class,
coll1_id, 1);
- ListRefCollEntity rev2 = getVersionsReader().find(ListRefCollEntity.class,
coll1_id, 2);
- ListRefCollEntity rev3 = getVersionsReader().find(ListRefCollEntity.class,
coll1_id, 3);
- ListRefCollEntity rev4 = getVersionsReader().find(ListRefCollEntity.class,
coll1_id, 4);
-
- assert TestTools.checkList(rev1.getCollection(), str1);
- assert TestTools.checkList(rev2.getCollection(), str1, str2);
- assert TestTools.checkList(rev3.getCollection(), str2);
- assert TestTools.checkList(rev4.getCollection());
-
- assert "coll1".equals(rev1.getData());
- assert "coll1".equals(rev2.getData());
- assert "coll1".equals(rev3.getData());
- assert "coll1".equals(rev4.getData());
- }
-}
\ No newline at end of file
Deleted:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSet.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSet.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSet.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,115 +0,0 @@
-package org.jboss.envers.test.integration.onetomany.detached;
-
-import org.jboss.envers.test.integration.AbstractEntityTest;
-import org.jboss.envers.test.entities.onetomany.detached.SetRefCollEntity;
-import org.jboss.envers.test.entities.StrTestEntity;
-import org.jboss.envers.test.tools.TestTools;
-import org.hibernate.ejb.Ejb3Configuration;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import javax.persistence.EntityManager;
-import java.util.Arrays;
-import java.util.HashSet;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class BasicNotOwnedSet extends AbstractEntityTest {
- private Integer str1_id;
- private Integer str2_id;
-
- private Integer coll1_id;
-
- public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(StrTestEntity.class);
- cfg.addAnnotatedClass(SetRefCollEntity.class);
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- StrTestEntity str1 = new StrTestEntity("str1");
- StrTestEntity str2 = new StrTestEntity("str2");
-
- SetRefCollEntity coll1 = new SetRefCollEntity(3, "coll1");
-
- // Revision 1
- em.getTransaction().begin();
-
- em.persist(str1);
- em.persist(str2);
-
- coll1.setCollection(new HashSet<StrTestEntity>());
- coll1.getCollection().add(str1);
- em.persist(coll1);
-
- em.getTransaction().commit();
-
- // Revision 2
- em.getTransaction().begin();
-
- str2 = em.find(StrTestEntity.class, str2.getId());
- coll1 = em.find(SetRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().add(str2);
-
- em.getTransaction().commit();
-
- // Revision 3
- em.getTransaction().begin();
-
- str1 = em.find(StrTestEntity.class, str1.getId());
- coll1 = em.find(SetRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().remove(str1);
-
- em.getTransaction().commit();
-
- // Revision 4
- em.getTransaction().begin();
-
- coll1 = em.find(SetRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().clear();
-
- em.getTransaction().commit();
-
- //
-
- str1_id = str1.getId();
- str2_id = str2.getId();
-
- coll1_id = coll1.getId();
- }
-
- @Test
- public void testRevisionsCounts() {
- assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(SetRefCollEntity.class, coll1_id));
-
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str2_id));
- }
-
- @Test
- public void testHistoryOfColl1() {
- StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
- StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);
-
- SetRefCollEntity rev1 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 1);
- SetRefCollEntity rev2 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 2);
- SetRefCollEntity rev3 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 3);
- SetRefCollEntity rev4 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 4);
-
- assert rev1.getCollection().equals(TestTools.makeSet(str1));
- assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
- assert rev3.getCollection().equals(TestTools.makeSet(str2));
- assert rev4.getCollection().equals(TestTools.makeSet());
-
- assert "coll1".equals(rev1.getData());
- assert "coll1".equals(rev2.getData());
- assert "coll1".equals(rev3.getData());
- assert "coll1".equals(rev4.getData());
- }
-}
Deleted:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithEmbId.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithEmbId.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithEmbId.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,114 +0,0 @@
-package org.jboss.envers.test.integration.onetomany.detached;
-
-import org.jboss.envers.test.integration.AbstractEntityTest;
-import org.jboss.envers.test.entities.onetomany.detached.ids.SetRefCollEntityEmbId;
-import org.jboss.envers.test.entities.ids.EmbIdTestEntity;
-import org.jboss.envers.test.entities.ids.EmbId;
-import org.jboss.envers.test.tools.TestTools;
-import org.hibernate.ejb.Ejb3Configuration;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import javax.persistence.EntityManager;
-import java.util.Arrays;
-import java.util.HashSet;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class BasicNotOwnedSetWithEmbId extends AbstractEntityTest {
- private EmbId str1_id;
- private EmbId str2_id;
-
- private EmbId coll1_id;
-
- public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(EmbIdTestEntity.class);
- cfg.addAnnotatedClass(SetRefCollEntityEmbId.class);
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- str1_id = new EmbId(1, 2);
- str2_id = new EmbId(3, 4);
-
- coll1_id = new EmbId(5, 6);
-
- EmbIdTestEntity str1 = new EmbIdTestEntity(str1_id, "str1");
- EmbIdTestEntity str2 = new EmbIdTestEntity(str2_id, "str2");
-
- SetRefCollEntityEmbId coll1 = new SetRefCollEntityEmbId(coll1_id,
"coll1");
-
- // Revision 1
- em.getTransaction().begin();
-
- em.persist(str1);
- em.persist(str2);
-
- coll1.setCollection(new HashSet<EmbIdTestEntity>());
- coll1.getCollection().add(str1);
- em.persist(coll1);
-
- em.getTransaction().commit();
-
- // Revision 2
- em.getTransaction().begin();
-
- str2 = em.find(EmbIdTestEntity.class, str2.getId());
- coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
-
- coll1.getCollection().add(str2);
-
- em.getTransaction().commit();
-
- // Revision 3
- em.getTransaction().begin();
-
- str1 = em.find(EmbIdTestEntity.class, str1.getId());
- coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
-
- coll1.getCollection().remove(str1);
-
- em.getTransaction().commit();
-
- // Revision 4
- em.getTransaction().begin();
-
- coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
-
- coll1.getCollection().clear();
-
- em.getTransaction().commit();
- }
-
- @Test
- public void testRevisionsCounts() {
- assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(SetRefCollEntityEmbId.class, coll1_id));
-
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(EmbIdTestEntity.class,
str1_id));
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(EmbIdTestEntity.class,
str2_id));
- }
-
- @Test
- public void testHistoryOfColl1() {
- EmbIdTestEntity str1 = getEntityManager().find(EmbIdTestEntity.class, str1_id);
- EmbIdTestEntity str2 = getEntityManager().find(EmbIdTestEntity.class, str2_id);
-
- SetRefCollEntityEmbId rev1 =
getVersionsReader().find(SetRefCollEntityEmbId.class, coll1_id, 1);
- SetRefCollEntityEmbId rev2 =
getVersionsReader().find(SetRefCollEntityEmbId.class, coll1_id, 2);
- SetRefCollEntityEmbId rev3 =
getVersionsReader().find(SetRefCollEntityEmbId.class, coll1_id, 3);
- SetRefCollEntityEmbId rev4 =
getVersionsReader().find(SetRefCollEntityEmbId.class, coll1_id, 4);
-
- assert rev1.getCollection().equals(TestTools.makeSet(str1));
- assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
- assert rev3.getCollection().equals(TestTools.makeSet(str2));
- assert rev4.getCollection().equals(TestTools.makeSet());
-
- assert "coll1".equals(rev1.getData());
- assert "coll1".equals(rev2.getData());
- assert "coll1".equals(rev3.getData());
- assert "coll1".equals(rev4.getData());
- }
-}
\ No newline at end of file
Deleted:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithMulId.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithMulId.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/BasicNotOwnedSetWithMulId.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,114 +0,0 @@
-package org.jboss.envers.test.integration.onetomany.detached;
-
-import org.jboss.envers.test.integration.AbstractEntityTest;
-import org.jboss.envers.test.entities.onetomany.detached.ids.SetRefCollEntityMulId;
-import org.jboss.envers.test.entities.ids.MulIdTestEntity;
-import org.jboss.envers.test.entities.ids.MulId;
-import org.jboss.envers.test.tools.TestTools;
-import org.hibernate.ejb.Ejb3Configuration;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import javax.persistence.EntityManager;
-import java.util.Arrays;
-import java.util.HashSet;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class BasicNotOwnedSetWithMulId extends AbstractEntityTest {
- private MulId str1_id;
- private MulId str2_id;
-
- private MulId coll1_id;
-
- public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(MulIdTestEntity.class);
- cfg.addAnnotatedClass(SetRefCollEntityMulId.class);
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- str1_id = new MulId(1, 2);
- str2_id = new MulId(3, 4);
-
- coll1_id = new MulId(5, 6);
-
- MulIdTestEntity str1 = new MulIdTestEntity(str1_id.getId1(), str1_id.getId2(),
"str1");
- MulIdTestEntity str2 = new MulIdTestEntity(str2_id.getId1(), str2_id.getId2(),
"str2");
-
- SetRefCollEntityMulId coll1 = new SetRefCollEntityMulId(coll1_id.getId1(),
coll1_id.getId2(), "coll1");
-
- // Revision 1
- em.getTransaction().begin();
-
- em.persist(str1);
- em.persist(str2);
-
- coll1.setCollection(new HashSet<MulIdTestEntity>());
- coll1.getCollection().add(str1);
- em.persist(coll1);
-
- em.getTransaction().commit();
-
- // Revision 2
- em.getTransaction().begin();
-
- str2 = em.find(MulIdTestEntity.class, str2_id);
- coll1 = em.find(SetRefCollEntityMulId.class, coll1_id);
-
- coll1.getCollection().add(str2);
-
- em.getTransaction().commit();
-
- // Revision 3
- em.getTransaction().begin();
-
- str1 = em.find(MulIdTestEntity.class, str1_id);
- coll1 = em.find(SetRefCollEntityMulId.class, coll1_id);
-
- coll1.getCollection().remove(str1);
-
- em.getTransaction().commit();
-
- // Revision 4
- em.getTransaction().begin();
-
- coll1 = em.find(SetRefCollEntityMulId.class, coll1_id);
-
- coll1.getCollection().clear();
-
- em.getTransaction().commit();
- }
-
- @Test
- public void testRevisionsCounts() {
- assert Arrays.asList(1, 2, 3,
4).equals(getVersionsReader().getRevisions(SetRefCollEntityMulId.class, coll1_id));
-
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(MulIdTestEntity.class,
str1_id));
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(MulIdTestEntity.class,
str2_id));
- }
-
- @Test
- public void testHistoryOfColl1() {
- MulIdTestEntity str1 = getEntityManager().find(MulIdTestEntity.class, str1_id);
- MulIdTestEntity str2 = getEntityManager().find(MulIdTestEntity.class, str2_id);
-
- SetRefCollEntityMulId rev1 =
getVersionsReader().find(SetRefCollEntityMulId.class, coll1_id, 1);
- SetRefCollEntityMulId rev2 =
getVersionsReader().find(SetRefCollEntityMulId.class, coll1_id, 2);
- SetRefCollEntityMulId rev3 =
getVersionsReader().find(SetRefCollEntityMulId.class, coll1_id, 3);
- SetRefCollEntityMulId rev4 =
getVersionsReader().find(SetRefCollEntityMulId.class, coll1_id, 4);
-
- assert rev1.getCollection().equals(TestTools.makeSet(str1));
- assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
- assert rev3.getCollection().equals(TestTools.makeSet(str2));
- assert rev4.getCollection().equals(TestTools.makeSet());
-
- assert "coll1".equals(rev1.getData());
- assert "coll1".equals(rev2.getData());
- assert "coll1".equals(rev3.getData());
- assert "coll1".equals(rev4.getData());
- }
-}
\ No newline at end of file
Copied:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesDetachedSet.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesNotOwnedSet.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesDetachedSet.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesDetachedSet.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,84 @@
+package org.jboss.envers.test.integration.onetomany.detached;
+
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.entities.onetomany.detached.SetRefCollEntity;
+import org.jboss.envers.test.entities.StrTestEntity;
+import org.jboss.envers.test.tools.TestTools;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class DataChangesDetachedSet extends AbstractEntityTest {
+ private Integer str1_id;
+
+ private Integer coll1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(StrTestEntity.class);
+ cfg.addAnnotatedClass(SetRefCollEntity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ StrTestEntity str1 = new StrTestEntity("str1");
+
+ SetRefCollEntity coll1 = new SetRefCollEntity(3, "coll1");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(str1);
+
+ coll1.setCollection(new HashSet<StrTestEntity>());
+ em.persist(coll1);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+ em.getTransaction().begin();
+
+ str1 = em.find(StrTestEntity.class, str1.getId());
+ coll1 = em.find(SetRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().add(str1);
+ coll1.setData("coll2");
+
+ em.getTransaction().commit();
+
+ //
+
+ str1_id = str1.getId();
+
+ coll1_id = coll1.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1,
2).equals(getVersionsReader().getRevisions(SetRefCollEntity.class, coll1_id));
+
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
+ }
+
+ @Test
+ public void testHistoryOfColl1() {
+ StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
+
+ SetRefCollEntity rev1 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 1);
+ SetRefCollEntity rev2 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 2);
+
+ assert rev1.getCollection().equals(TestTools.makeSet());
+ assert rev2.getCollection().equals(TestTools.makeSet(str1));
+
+ assert "coll1".equals(rev1.getData());
+ assert "coll2".equals(rev2.getData());
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesDetachedSet.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesNotOwnedSet.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesNotOwnedSet.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DataChangesNotOwnedSet.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,84 +0,0 @@
-package org.jboss.envers.test.integration.onetomany.detached;
-
-import org.jboss.envers.test.integration.AbstractEntityTest;
-import org.jboss.envers.test.entities.onetomany.detached.SetRefCollEntity;
-import org.jboss.envers.test.entities.StrTestEntity;
-import org.jboss.envers.test.tools.TestTools;
-import org.hibernate.ejb.Ejb3Configuration;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import javax.persistence.EntityManager;
-import java.util.Arrays;
-import java.util.HashSet;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class DataChangesNotOwnedSet extends AbstractEntityTest {
- private Integer str1_id;
-
- private Integer coll1_id;
-
- public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(StrTestEntity.class);
- cfg.addAnnotatedClass(SetRefCollEntity.class);
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- StrTestEntity str1 = new StrTestEntity("str1");
-
- SetRefCollEntity coll1 = new SetRefCollEntity(3, "coll1");
-
- // Revision 1
- em.getTransaction().begin();
-
- em.persist(str1);
-
- coll1.setCollection(new HashSet<StrTestEntity>());
- em.persist(coll1);
-
- em.getTransaction().commit();
-
- // Revision 2
- em.getTransaction().begin();
-
- str1 = em.find(StrTestEntity.class, str1.getId());
- coll1 = em.find(SetRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().add(str1);
- coll1.setData("coll2");
-
- em.getTransaction().commit();
-
- //
-
- str1_id = str1.getId();
-
- coll1_id = coll1.getId();
- }
-
- @Test
- public void testRevisionsCounts() {
- assert Arrays.asList(1,
2).equals(getVersionsReader().getRevisions(SetRefCollEntity.class, coll1_id));
-
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
- }
-
- @Test
- public void testHistoryOfColl1() {
- StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
-
- SetRefCollEntity rev1 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 1);
- SetRefCollEntity rev2 = getVersionsReader().find(SetRefCollEntity.class,
coll1_id, 2);
-
- assert rev1.getCollection().equals(TestTools.makeSet());
- assert rev2.getCollection().equals(TestTools.makeSet(str1));
-
- assert "coll1".equals(rev1.getData());
- assert "coll2".equals(rev2.getData());
- }
-}
\ No newline at end of file
Copied:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleDetachedSet.java
(from rev 148,
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleNotOwnedSet.java)
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleDetachedSet.java
(rev 0)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleDetachedSet.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -0,0 +1,108 @@
+package org.jboss.envers.test.integration.onetomany.detached;
+
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.entities.onetomany.detached.DoubleSetRefCollEntity;
+import org.jboss.envers.test.entities.StrTestEntity;
+import org.jboss.envers.test.tools.TestTools;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class DoubleDetachedSet extends AbstractEntityTest {
+ private Integer str1_id;
+ private Integer str2_id;
+
+ private Integer coll1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(StrTestEntity.class);
+ cfg.addAnnotatedClass(DoubleSetRefCollEntity.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ StrTestEntity str1 = new StrTestEntity("str1");
+ StrTestEntity str2 = new StrTestEntity("str2");
+
+ DoubleSetRefCollEntity coll1 = new DoubleSetRefCollEntity(3, "coll1");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(str1);
+ em.persist(str2);
+
+ coll1.setCollection(new HashSet<StrTestEntity>());
+ coll1.getCollection().add(str1);
+ em.persist(coll1);
+
+ coll1.setCollection2(new HashSet<StrTestEntity>());
+ coll1.getCollection2().add(str2);
+ em.persist(coll1);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+ em.getTransaction().begin();
+
+ str2 = em.find(StrTestEntity.class, str2.getId());
+ coll1 = em.find(DoubleSetRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().add(str2);
+
+ em.getTransaction().commit();
+
+ // Revision 3
+ em.getTransaction().begin();
+
+ str1 = em.find(StrTestEntity.class, str1.getId());
+ coll1 = em.find(DoubleSetRefCollEntity.class, coll1.getId());
+
+ coll1.getCollection().remove(str1);
+ coll1.getCollection2().add(str1);
+
+ em.getTransaction().commit();
+
+ //
+
+ str1_id = str1.getId();
+ str2_id = str2.getId();
+
+ coll1_id = coll1.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2,
3).equals(getVersionsReader().getRevisions(DoubleSetRefCollEntity.class, coll1_id));
+
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
+ assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str2_id));
+ }
+
+ @Test
+ public void testHistoryOfColl1() {
+ StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
+ StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);
+
+ DoubleSetRefCollEntity rev1 =
getVersionsReader().find(DoubleSetRefCollEntity.class, coll1_id, 1);
+ DoubleSetRefCollEntity rev2 =
getVersionsReader().find(DoubleSetRefCollEntity.class, coll1_id, 2);
+ DoubleSetRefCollEntity rev3 =
getVersionsReader().find(DoubleSetRefCollEntity.class, coll1_id, 3);
+
+ assert rev1.getCollection().equals(TestTools.makeSet(str1));
+ assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
+ assert rev3.getCollection().equals(TestTools.makeSet(str2));
+
+ assert rev1.getCollection2().equals(TestTools.makeSet(str2));
+ assert rev2.getCollection2().equals(TestTools.makeSet(str2));
+ assert rev3.getCollection2().equals(TestTools.makeSet(str1, str2));
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleDetachedSet.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleNotOwnedSet.java
===================================================================
---
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleNotOwnedSet.java 2008-09-21
20:42:00 UTC (rev 155)
+++
trunk/src/test/org/jboss/envers/test/integration/onetomany/detached/DoubleNotOwnedSet.java 2008-09-21
22:00:50 UTC (rev 156)
@@ -1,108 +0,0 @@
-package org.jboss.envers.test.integration.onetomany.detached;
-
-import org.jboss.envers.test.integration.AbstractEntityTest;
-import org.jboss.envers.test.entities.onetomany.detached.DoubleSetRefCollEntity;
-import org.jboss.envers.test.entities.StrTestEntity;
-import org.jboss.envers.test.tools.TestTools;
-import org.hibernate.ejb.Ejb3Configuration;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import javax.persistence.EntityManager;
-import java.util.Arrays;
-import java.util.HashSet;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class DoubleNotOwnedSet extends AbstractEntityTest {
- private Integer str1_id;
- private Integer str2_id;
-
- private Integer coll1_id;
-
- public void configure(Ejb3Configuration cfg) {
- cfg.addAnnotatedClass(StrTestEntity.class);
- cfg.addAnnotatedClass(DoubleSetRefCollEntity.class);
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- StrTestEntity str1 = new StrTestEntity("str1");
- StrTestEntity str2 = new StrTestEntity("str2");
-
- DoubleSetRefCollEntity coll1 = new DoubleSetRefCollEntity(3, "coll1");
-
- // Revision 1
- em.getTransaction().begin();
-
- em.persist(str1);
- em.persist(str2);
-
- coll1.setCollection(new HashSet<StrTestEntity>());
- coll1.getCollection().add(str1);
- em.persist(coll1);
-
- coll1.setCollection2(new HashSet<StrTestEntity>());
- coll1.getCollection2().add(str2);
- em.persist(coll1);
-
- em.getTransaction().commit();
-
- // Revision 2
- em.getTransaction().begin();
-
- str2 = em.find(StrTestEntity.class, str2.getId());
- coll1 = em.find(DoubleSetRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().add(str2);
-
- em.getTransaction().commit();
-
- // Revision 3
- em.getTransaction().begin();
-
- str1 = em.find(StrTestEntity.class, str1.getId());
- coll1 = em.find(DoubleSetRefCollEntity.class, coll1.getId());
-
- coll1.getCollection().remove(str1);
- coll1.getCollection2().add(str1);
-
- em.getTransaction().commit();
-
- //
-
- str1_id = str1.getId();
- str2_id = str2.getId();
-
- coll1_id = coll1.getId();
- }
-
- @Test
- public void testRevisionsCounts() {
- assert Arrays.asList(1, 2,
3).equals(getVersionsReader().getRevisions(DoubleSetRefCollEntity.class, coll1_id));
-
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str1_id));
- assert
Arrays.asList(1).equals(getVersionsReader().getRevisions(StrTestEntity.class, str2_id));
- }
-
- @Test
- public void testHistoryOfColl1() {
- StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
- StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);
-
- DoubleSetRefCollEntity rev1 =
getVersionsReader().find(DoubleSetRefCollEntity.class, coll1_id, 1);
- DoubleSetRefCollEntity rev2 =
getVersionsReader().find(DoubleSetRefCollEntity.class, coll1_id, 2);
- DoubleSetRefCollEntity rev3 =
getVersionsReader().find(DoubleSetRefCollEntity.class, coll1_id, 3);
-
- assert rev1.getCollection().equals(TestTools.makeSet(str1));
- assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
- assert rev3.getCollection().equals(TestTools.makeSet(str2));
-
- assert rev1.getCollection2().equals(TestTools.makeSet(str2));
- assert rev2.getCollection2().equals(TestTools.makeSet(str2));
- assert rev3.getCollection2().equals(TestTools.makeSet(str1, str2));
- }
-}
\ No newline at end of file