use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class ProjectTest method constraintViolation.
@Test(expected = Exception.class)
public void constraintViolation() {
setUser(1);
SchemaDTO schema = execute(new GetSchema());
ProjectDTO project = schema.getProjectById(2);
project.setName(null);
execute(RequestChange.update(project, "name"));
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class GetSchemaTest method testDatabaseVisibilityForOwners.
@Test
public void testDatabaseVisibilityForOwners() throws CommandException {
// owners should be able to see their databases
// Alex
setUser(1);
SchemaDTO schema = execute(new GetSchema());
assertThat("database count", schema.getDatabases().size(), equalTo(3));
assertThat("database list is sorted", schema.getDatabases().get(0).getName(), equalTo("Alpha"));
// PEAR
assertTrue("ALEX(owner) in PEAR", schema.getDatabaseById(1) != null);
assertTrue("ALEX can design", schema.getDatabaseById(1).isDesignAllowed());
assertTrue("Alex can edit all", schema.getDatabaseById(1).isEditAllowed());
assertTrue("object graph is preserved", schema.getDatabaseById(1).getCountry() == schema.getDatabaseById(2).getCountry());
assertTrue("object graph is preserved (database-activity)", schema.getDatabaseById(1) == schema.getDatabaseById(1).getActivities().get(0).getDatabase());
AdminLevelDTO adminLevel = schema.getCountries().get(0).getAdminLevels().get(0);
assertThat("CountryId is not null", adminLevel.getCountryId(), not(equalTo(0)));
assertThat("CountryId is not null", adminLevel.getId(), not(equalTo(0)));
assertTrue("CountryId is not null", schema.getCountries().get(0).getAdminLevels().get(0).getCountryId() != 0);
assertThat("deleted attribute is not present", schema.getActivityById(1).getAttributeGroups().size(), equalTo(3));
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class GetSchemaTest method testDatabaseVisibilityForView.
@Test
public void testDatabaseVisibilityForView() throws CommandException {
// Bavon
setUser(2);
SchemaDTO schema = execute(new GetSchema());
assertThat(schema.getDatabases().size(), equalTo(1));
assertThat("BAVON in PEAR", schema.getDatabaseById(1), is(not(nullValue())));
assertThat(schema.getDatabaseById(1).getMyPartnerId(), equalTo(1));
assertThat(schema.getDatabaseById(1).isEditAllowed(), equalTo(true));
assertThat(schema.getDatabaseById(1).isEditAllAllowed(), equalTo(false));
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class GetSchemaTest method testAttributes.
@Test
public void testAttributes() throws CommandException {
// Alex
setUser(1);
SchemaDTO schema = execute(new GetSchema());
assertTrue("no attributes case", schema.getActivityById(3).getAttributeGroups().size() == 0);
ActivityDTO nfi = schema.getActivityById(1);
AttributeDTO[] attributes = nfi.getAttributeGroupById(1).getAttributes().toArray(new AttributeDTO[0]);
assertTrue("attributes are present", attributes.length == 2);
AttributeDTO test = nfi.getAttributeById(1);
assertEquals("property:name", "Catastrophe Naturelle", test.getName());
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class PartnerTest method testAddNewPartner.
@Test
public void testAddNewPartner() throws Exception {
PartnerDTO newPartner = new PartnerDTO();
newPartner.setName("VDE");
newPartner.setFullName("Vision d'Espoir");
CreateResult cr = execute(new AddPartner(1, newPartner));
SchemaDTO schema = execute(new GetSchema());
PartnerDTO partner = schema.getDatabaseById(1).getPartnerById(cr.getNewId());
Assert.assertNotNull(partner);
Assert.assertEquals("VDE", partner.getName());
Assert.assertEquals("Vision d'Espoir", partner.getFullName());
}
Aggregations