fix new error on pac.delete

This commit is contained in:
Peter Hormanns 2013-05-27 19:54:29 +02:00
parent ae9911808f
commit 6693502d64
2 changed files with 45 additions and 1 deletions

View File

@ -79,7 +79,7 @@ public class Pac extends AbstractEntity implements Serializable {
@ManyToOne(fetch = EAGER)
private INetAddress oldINetAddr;
@OneToMany(fetch = EAGER, cascade = ALL, mappedBy="pac", orphanRemoval=true)
@OneToMany(fetch = EAGER, cascade = ALL, mappedBy="pac")
private Set<PacComponent> pacComponents;
@OneToMany(fetch = LAZY, cascade = ALL, mappedBy="pac")

View File

@ -5,6 +5,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -15,6 +17,7 @@ import org.junit.Before;
import org.junit.Test;
import de.hsadmin.core.util.Config;
import de.hsadmin.core.util.TextUtil;
import de.hsadmin.hostsharing.BasePacType;
public class PacMigrationTest {
@ -154,6 +157,47 @@ public class PacMigrationTest {
}
}
@Test
public void testDeleteSW() {
String user = "ad";
try {
int count = getPacsCount();
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, Object> setParams = new HashMap<String, Object>();
setParams.put("created", TextUtil.format(daysBack(10)));
Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "aaa05");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams, whereParams };
Object execute = client.execute(MODULE + ".update", params);
assertNotNull(execute);
setParams = new HashMap<String, Object>();
setParams.put("cancelled", TextUtil.format(daysBack(1)));
whereParams = new HashMap<String, String>();
whereParams.put("name", "aaa05");
params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams, whereParams };
execute = client.execute(MODULE + ".update", params);
assertNotNull(execute);
whereParams.put("name", "aaa05");
params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
execute = client.execute(MODULE + ".delete", params);
assertEquals(count - 1, getPacsCount());
} catch (XmlRpcException e) {
fail(e.getMessage());
}
}
private Date daysBack(int days) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, -days);
return calendar.getTime();
}
private int getPacsCount() {
int count = 0;
String user = "hsh00-aaa";