Search in sources :

Example 61 with GetSchema

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"));
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 62 with GetSchema

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));
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 63 with GetSchema

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));
}
Also used : SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 64 with GetSchema

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());
}
Also used : AttributeDTO(org.activityinfo.shared.dto.AttributeDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 65 with GetSchema

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());
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) AddPartner(org.activityinfo.shared.command.AddPartner) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Aggregations

GetSchema (org.activityinfo.shared.command.GetSchema)65 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)56 Test (org.junit.Test)42 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)15 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)10 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)9 CreateResult (org.activityinfo.shared.command.result.CreateResult)8 CreateEntity (org.activityinfo.shared.command.CreateEntity)5 Filter (org.activityinfo.shared.command.Filter)5 HashMap (java.util.HashMap)4 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)4 Delete (org.activityinfo.shared.command.Delete)4 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)4 OnDataSet (org.activityinfo.server.database.OnDataSet)3 BatchCommand (org.activityinfo.shared.command.BatchCommand)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2