HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2013-05-27 6693502d647cf707a15aedd444cb01f0026df863
fix new error on pac.delete
2 files modified
46 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/pac/Pac.java 2 ●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/PacMigrationTest.java 44 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/Pac.java
@@ -79,7 +79,7 @@
    @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")
hsarback/test/de/hsadmin/remote/PacMigrationTest.java
@@ -5,6 +5,8 @@
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.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 @@
        }
    }
    @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";