rendered paste bodyLocationMapperTest.java
-----------------------
package persistency;
import models.Location;
import junit.framework.TestCase;
public class LocationMapperTest extends TestCase {
LocationMapper lm = new LocationMapper();
public void testAddLocation() {
Location l = new Location(10, 1000, "locationtest1", "body", 0);
PersLocation pl = lm.addLocation(l);
assertEquals(l.getTopic(), pl.getTopic());
assertEquals(l.getBody(), pl.getBody());
assertEquals(l.getCreatedBy(), pl.getCreatedBy());
assertEquals(l.getX(), pl.getX());
assertEquals(l.getY(), pl.getY());
}
public void testGetLocationIdByName() {
int id = lm.getLocationIdByName("locationtest1");
PersLocation l = lm.getLocation(id);
assertEquals("locationtest1", l.getTopic());
}
public void testEditLocation() {
int id = lm.getLocationIdByName("locationtest1");
PersLocation l = lm.getLocation(id);
l.setTopic("locationedited");
l.setBody("edited");
l.setVisible(1);
l.setCreatedBy(10);
lm.editLocation(l);
PersLocation l2 = lm.getLocation(id);
assertEquals(l.getTopic(), l2.getTopic());
assertEquals(l.getBody(), l2.getBody());
assertEquals(l.isVisible(), l2.isVisible());
assertEquals(l.getCreatedBy(), l2.getCreatedBy());
}
public void testDeleteLocation() {
int id = lm.getLocationIdByName("locationedited");
int updateCount = lm.deleteLocation(id);
assertEquals(1, updateCount);
}
}