use of org.activityinfo.legacy.shared.command.CreateSite in project activityinfo by bedatadriven.
the class CreateSiteTest method testAdminBoundCreate.
@Test
@Ignore("WIP")
public void testAdminBoundCreate() throws CommandException {
// create a new detached, client model
SiteDTO newSite = new SiteDTO();
newSite.setActivityId(4);
newSite.setPartner(new PartnerDTO(1, "Foobar"));
newSite.setDate1((new GregorianCalendar(2008, 12, 1)).getTime());
newSite.setDate2((new GregorianCalendar(2009, 1, 3)).getTime());
newSite.setAdminEntity(1, new AdminEntityDTO(1, 2, "Sud Kivu"));
newSite.setAdminEntity(2, new AdminEntityDTO(2, 11, "Walungu"));
newSite.setAdminEntity(3, null);
newSite.setX(27.432);
newSite.setY(1.23);
newSite.setComments("huba huba");
newSite.setProject(new ProjectDTO(1, "SomeProject"));
// create command
CreateSite cmd = new CreateSite(newSite);
// execute the command
setUser(1);
newSite.setProject(new ProjectDTO(1, "SomeProject"));
CreateResult result = execute(cmd);
newSite.setId(result.getNewId());
// try to retrieve what we've created
SiteDTO secondRead = readSite(newSite.getId());
// confirm that the changes are there
Assert.assertEquals("site.location.name", "Walungu", secondRead.getLocationName());
}
use of org.activityinfo.legacy.shared.command.CreateSite in project activityinfo by bedatadriven.
the class CreateSiteTest method unauthorized.
@Test(expected = IllegalAccessCommandException.class)
public void unauthorized() throws CommandException {
// create a new detached, client model
SiteDTO newSite = SiteDTOs.newSite();
newSite.setPartner(new PartnerDTO(2, "Not NRC"));
// create command
CreateSite cmd = new CreateSite(newSite);
// execute the command
// bavon (only has access to his own partners in database 1)
setUser(2);
execute(cmd);
}
Aggregations