een keer moeten we dat beter aanpakken … nu heb je RandomPopulator gekoppeld aan een toevallige logica van het ebrim domain.
Wat je ook zou kunnen doen is eerst (met ID en al) genereren met RandomPopulator, en daarna de IDs weer leegmaken met ObjectGraphVisitor, zie FixerTest.java die precies dat soort dingen doet …
On Fri, Jan 16, 2009 at 2:16 PM, <erikvaningen@anonymised.com> wrote:
Revision: 1973
http://geonetwork.svn.sourceforge.net/geonetwork/?rev=1973&view=rev
Author: erikvaningen
Date: 2009-01-16 13:16:31 +0000 (Fri, 16 Jan 2009)Log Message:
added logic for not filling id’s from the objects in the object graph
Modified Paths:
sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/utils/RandomPopulator.java
sandbox/3.0.x/geonetwork-domain-ebrim/src/test/java/org/geonetwork/utils/RandomHelperBase.java
sandbox/3.0.x/geonetwork-domain-ebrim/src/test/java/org/geonetwork/utils/RandomPopulatorTest.javaModified: sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/utils/RandomPopulator.java
— sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/utils/RandomPopulator.java 2009-01-16 12:17:03 UTC (rev 1972)
+++ sandbox/3.0.x/geonetwork-domain-ebrim/src/main/java/org/geonetwork/utils/RandomPopulator.java 2009-01-16 13:16:31 UTC (rev 1973)
@@ -116,7 +116,9 @@
// examine methods in object o
for (Method method : o.getClass().getMethods()) {
// a candidate setter method
- if (method.getName().startsWith(“set”)) {
- if (method.getName().startsWith(“set”) && !method.getName().equals(“setHibernateId”)
- && !method.getName().equals(“setId”)) {
Class<?> parameterTypes = method.getParameterTypes();
Type genericParameterTypes = method.getGenericParameterTypes();
// unsupported set method: takes zero or more than one parameter, or is not voidModified: sandbox/3.0.x/geonetwork-domain-ebrim/src/test/java/org/geonetwork/utils/RandomHelperBase.java
— sandbox/3.0.x/geonetwork-domain-ebrim/src/test/java/org/geonetwork/utils/RandomHelperBase.java 2009-01-16 12:17:03 UTC (rev 1972)
+++ sandbox/3.0.x/geonetwork-domain-ebrim/src/test/java/org/geonetwork/utils/RandomHelperBase.java 2009-01-16 13:16:31 UTC (rev 1973)
@@ -5,6 +5,11 @@
public class RandomHelperBase {
- private long hibernateId;
- private long id;
Set randomHelperAttributeSet;
public Set getRandomHelperAttributeSet() {
@@ -14,6 +19,22 @@
public void setRandomHelperAttributeSet(Set randomHelperAttributeSet) {
this.randomHelperAttributeSet = randomHelperAttributeSet;
}
+
- public long getHibernateId() {
- return hibernateId;
- }
- public void setHibernateId(long hibernateId) {
- this.hibernateId = hibernateId;
- }
- public long getId() {
- return id;
- }
- public void setId(long id) {
- this.id = id;
- }
}
Modified: sandbox/3.0.x/geonetwork-domain-ebrim/src/test/java/org/geonetwork/utils/RandomPopulatorTest.java
— sandbox/3.0.x/geonetwork-domain-ebrim/src/test/java/org/geonetwork/utils/RandomPopulatorTest.java 2009-01-16 12:17:03 UTC (rev 1972)
+++ sandbox/3.0.x/geonetwork-domain-ebrim/src/test/java/org/geonetwork/utils/RandomPopulatorTest.java 2009-01-16 13:16:31 UTC (rev 1973)
@@ -1,6 +1,8 @@
package org.geonetwork.utils;import static org.junit.Assert.*;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
@@ -16,7 +18,7 @@public class RandomPopulatorTest {
- @Test
- //@Test
public void testInstantiate1() throws Exception {
ExtrinsicObject eo = (ExtrinsicObject) RandomPopulator.instantiate(ExtrinsicObject.class, null);
// set up JiBX marshalling context
@@ -29,7 +31,7 @@
marshallingContext.marshalDocument(eo, “UTF-8”, null);
}
- @Test
- //@Test
public void testInstantiate2() throws Exception {
Annotates eo = (Annotates) RandomPopulator.instantiate(Annotates.class, null);
assertNotNull(eo);
@@ -40,7 +42,7 @@
assertNotNull(eo.getDescription());
}
- @Test
- //@Test
public void testInstantiate3() throws Exception {for (int i = 0; i < 10; i++) {
@@ -50,7 +52,7 @@
}
}
- @Test
- //@Test
public void testInstantiate4() throws Exception {for (int i = 0; i < 10; i++) {
@@ -60,4 +62,12 @@
}
}
- @Test
- public void testInstantiate5() throws Exception {
- RandomHelperChild randomHelperChild = (RandomHelperChild) RandomPopulator.instantiate(RandomHelperChild.class,
- null);
- assertEquals(0l, randomHelperChild.getHibernateId());
- assertEquals(0l, randomHelperChild.getId());
- }
}
This was sent by the SourceForge.net collaborative development platform, the world’s largest Open Source development site.
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
GeoNetwork-commit mailing list
GeoNetwork-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-commit